--- a/.hgtags Mon Apr 13 17:03:11 2015 -0700
+++ b/.hgtags Tue Apr 14 12:10:00 2015 -0700
@@ -300,3 +300,5 @@
c97e2d1bad9708d379793ba2a4c848eda14c741e jdk9-b55
47544495db2d3d2edf0f85862d8715592fdb919f jdk9-b56
ddb95d8f169b09544cc17e72a6baaff2400092f5 jdk9-b57
+f40752db7773ca0c737f2ad88371e35c57fdfed7 jdk9-b58
+da950f343762a856d69751570a4c07cfa68a415b jdk9-b59
--- a/.hgtags-top-repo Mon Apr 13 17:03:11 2015 -0700
+++ b/.hgtags-top-repo Tue Apr 14 12:10:00 2015 -0700
@@ -300,3 +300,5 @@
0c37a832458f0e0b7d2a3f1a6f69aeae311aeb18 jdk9-b55
eb7febe45865ba6b81f2ea68082262d0708a0b22 jdk9-b56
f25ee9f62427a9ba27418e5531a89754791a305b jdk9-b57
+6e78dd9b121037719a065fe8fb25b936babdfecb jdk9-b58
+39e8a131289e8386aa4c3e4b184faa812a7c0421 jdk9-b59
--- a/common/autoconf/basics.m4 Mon Apr 13 17:03:11 2015 -0700
+++ b/common/autoconf/basics.m4 Tue Apr 14 12:10:00 2015 -0700
@@ -700,9 +700,13 @@
BASIC_FIXUP_PATH(OUTPUT_ROOT)
+ CONFIGURESUPPORT_OUTPUTDIR="$OUTPUT_ROOT/configure-support"
+ $MKDIR -p "$CONFIGURESUPPORT_OUTPUTDIR"
+
AC_SUBST(SPEC, $OUTPUT_ROOT/spec.gmk)
AC_SUBST(CONF_NAME, $CONF_NAME)
AC_SUBST(OUTPUT_ROOT, $OUTPUT_ROOT)
+ AC_SUBST(CONFIGURESUPPORT_OUTPUTDIR)
# The spec.gmk file contains all variables for the make system.
AC_CONFIG_FILES([$OUTPUT_ROOT/spec.gmk:$AUTOCONF_DIR/spec.gmk.in])
--- a/common/autoconf/basics_windows.m4 Mon Apr 13 17:03:11 2015 -0700
+++ b/common/autoconf/basics_windows.m4 Tue Apr 14 12:10:00 2015 -0700
@@ -383,45 +383,46 @@
if test "x$OPENJDK_BUILD_OS" = xwindows; then
AC_MSG_CHECKING([if fixpath can be created])
FIXPATH_SRC="$SRC_ROOT/common/src/fixpath.c"
- FIXPATH_BIN="$OUTPUT_ROOT/fixpath.exe"
+ FIXPATH_BIN="$CONFIGURESUPPORT_OUTPUTDIR/bin/fixpath.exe"
+ FIXPATH_DIR="$CONFIGURESUPPORT_OUTPUTDIR/fixpath"
if test "x$OPENJDK_BUILD_OS_ENV" = xwindows.cygwin; then
- FIXPATH_SRC=`$CYGPATH -m $FIXPATH_SRC`
- FIXPATH_BIN=`$CYGPATH -m $FIXPATH_BIN`
# Important to keep the .exe suffix on Cygwin for Hotspot makefiles
- FIXPATH="$OUTPUT_ROOT/fixpath.exe -c"
+ FIXPATH="$FIXPATH_BIN -c"
elif test "x$OPENJDK_BUILD_OS_ENV" = xwindows.msys; then
- FIXPATH_SRC=`cmd //c echo $FIXPATH_SRC`
- FIXPATH_BIN=`cmd //c echo $FIXPATH_BIN`
-
# Take all collected prefixes and turn them into a -m/c/foo@/c/bar@... command line
# @ was chosen as separator to minimize risk of other tools messing around with it
- all_unique_prefixes=`echo "${all_fixpath_prefixes@<:@@@:>@}" | tr ' ' '\n' | grep '^/./' | sort | uniq`
+ all_unique_prefixes=`echo "${all_fixpath_prefixes@<:@@@:>@}" \
+ | tr ' ' '\n' | grep '^/./' | sort | uniq`
fixpath_argument_list=`echo $all_unique_prefixes | tr ' ' '@'`
-
- FIXPATH="$OUTPUT_ROOT/fixpath -m$fixpath_argument_list"
+ FIXPATH="$FIXPATH_BIN -m$fixpath_argument_list"
fi
- rm -f $OUTPUT_ROOT/fixpath*
- cd $OUTPUT_ROOT
- $CC $FIXPATH_SRC -Fe$FIXPATH_BIN > $OUTPUT_ROOT/fixpath1.log 2>&1
+ FIXPATH_SRC_W="$FIXPATH_SRC"
+ FIXPATH_BIN_W="$FIXPATH_BIN"
+ BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([FIXPATH_SRC_W])
+ BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH([FIXPATH_BIN_W])
+ $RM -rf $FIXPATH_BIN $FIXPATH_DIR
+ $MKDIR -p $FIXPATH_DIR $CONFIGURESUPPORT_OUTPUTDIR/bin
+ cd $FIXPATH_DIR
+ $CC $FIXPATH_SRC_W -Fe$FIXPATH_BIN_W > $FIXPATH_DIR/fixpath1.log 2>&1
cd $CURDIR
- if test ! -x $OUTPUT_ROOT/fixpath.exe; then
+ if test ! -x $FIXPATH_BIN; then
AC_MSG_RESULT([no])
- cat $OUTPUT_ROOT/fixpath1.log
- AC_MSG_ERROR([Could not create $OUTPUT_ROOT/fixpath.exe])
+ cat $FIXPATH_DIR/fixpath1.log
+ AC_MSG_ERROR([Could not create $FIXPATH_BIN])
fi
AC_MSG_RESULT([yes])
AC_MSG_CHECKING([if fixpath.exe works])
- cd $OUTPUT_ROOT
- $FIXPATH $CC $SRC_ROOT/common/src/fixpath.c -Fe$OUTPUT_ROOT/fixpath2.exe > $OUTPUT_ROOT/fixpath2.log 2>&1
+ cd $FIXPATH_DIR
+ $FIXPATH $CC $FIXPATH_SRC -Fe$FIXPATH_DIR/fixpath2.exe \
+ > $FIXPATH_DIR/fixpath2.log 2>&1
cd $CURDIR
- if test ! -x $OUTPUT_ROOT/fixpath2.exe; then
+ if test ! -x $FIXPATH_DIR/fixpath2.exe; then
AC_MSG_RESULT([no])
- cat $OUTPUT_ROOT/fixpath2.log
+ cat $FIXPATH_DIR/fixpath2.log
AC_MSG_ERROR([fixpath did not work!])
fi
AC_MSG_RESULT([yes])
- rm -f $OUTPUT_ROOT/fixpath?.??? $OUTPUT_ROOT/fixpath.obj
fi
AC_SUBST(FIXPATH)
--- a/common/autoconf/build-performance.m4 Mon Apr 13 17:03:11 2015 -0700
+++ b/common/autoconf/build-performance.m4 Tue Apr 14 12:10:00 2015 -0700
@@ -336,11 +336,4 @@
AC_MSG_CHECKING([whether to use sjavac])
AC_MSG_RESULT([$ENABLE_SJAVAC])
AC_SUBST(ENABLE_SJAVAC)
-
- if test "x$ENABLE_SJAVAC" = xyes; then
- SJAVAC_SERVER_DIR="$OUTPUT_ROOT/javacservers"
- else
- SJAVAC_SERVER_DIR=
- fi
- AC_SUBST(SJAVAC_SERVER_DIR)
])
--- a/common/autoconf/configure.ac Mon Apr 13 17:03:11 2015 -0700
+++ b/common/autoconf/configure.ac Tue Apr 14 12:10:00 2015 -0700
@@ -261,7 +261,7 @@
# We're messing a bit with internal autoconf variables to put the config.status
# in the output directory instead of the current directory.
-CONFIG_STATUS="$OUTPUT_ROOT/config.status"
+CONFIG_STATUS="$CONFIGURESUPPORT_OUTPUTDIR/config.status"
# Create the actual output files. Now the main work of configure is done.
AC_OUTPUT
@@ -269,7 +269,7 @@
# Try to move the config.log file to the output directory.
if test -e ./config.log; then
- $MV -f ./config.log "$OUTPUT_ROOT/config.log" 2> /dev/null
+ $MV -f ./config.log "$CONFIGURESUPPORT_OUTPUTDIR/config.log" 2> /dev/null
fi
# Make the compare script executable
--- a/common/autoconf/generated-configure.sh Mon Apr 13 17:03:11 2015 -0700
+++ b/common/autoconf/generated-configure.sh Tue Apr 14 12:10:00 2015 -0700
@@ -632,7 +632,6 @@
CFLAGS_CCACHE
CCACHE
USE_PRECOMPILED_HEADER
-SJAVAC_SERVER_DIR
ENABLE_SJAVAC
SJAVAC_SERVER_JAVA_FLAGS
SJAVAC_SERVER_JAVA
@@ -884,6 +883,7 @@
CHECK_MAKE
CHECK_GMAKE
PKGHANDLER
+CONFIGURESUPPORT_OUTPUTDIR
OUTPUT_ROOT
CONF_NAME
SPEC
@@ -4365,7 +4365,7 @@
#CUSTOM_AUTOCONF_INCLUDE
# Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1428017006
+DATE_WHEN_GENERATED=1428904416
###############################################################################
#
@@ -15443,6 +15443,9 @@
fi
+ CONFIGURESUPPORT_OUTPUTDIR="$OUTPUT_ROOT/configure-support"
+ $MKDIR -p "$CONFIGURESUPPORT_OUTPUTDIR"
+
SPEC=$OUTPUT_ROOT/spec.gmk
CONF_NAME=$CONF_NAME
@@ -15450,6 +15453,7 @@
OUTPUT_ROOT=$OUTPUT_ROOT
+
# The spec.gmk file contains all variables for the make system.
ac_config_files="$ac_config_files $OUTPUT_ROOT/spec.gmk:$AUTOCONF_DIR/spec.gmk.in"
@@ -27622,7 +27626,7 @@
$as_echo "$as_me: Trying to extract Visual Studio environment variables" >&6;}
# We need to create a couple of temporary files.
- VS_ENV_TMP_DIR="$OUTPUT_ROOT/vs-env"
+ VS_ENV_TMP_DIR="$CONFIGURESUPPORT_OUTPUTDIR/vs-env"
$MKDIR -p $VS_ENV_TMP_DIR
# Cannot use the VS10 setup script directly (since it only updates the DOS subshell environment).
@@ -43136,50 +43140,69 @@
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if fixpath can be created" >&5
$as_echo_n "checking if fixpath can be created... " >&6; }
FIXPATH_SRC="$SRC_ROOT/common/src/fixpath.c"
- FIXPATH_BIN="$OUTPUT_ROOT/fixpath.exe"
+ FIXPATH_BIN="$CONFIGURESUPPORT_OUTPUTDIR/bin/fixpath.exe"
+ FIXPATH_DIR="$CONFIGURESUPPORT_OUTPUTDIR/fixpath"
if test "x$OPENJDK_BUILD_OS_ENV" = xwindows.cygwin; then
- FIXPATH_SRC=`$CYGPATH -m $FIXPATH_SRC`
- FIXPATH_BIN=`$CYGPATH -m $FIXPATH_BIN`
# Important to keep the .exe suffix on Cygwin for Hotspot makefiles
- FIXPATH="$OUTPUT_ROOT/fixpath.exe -c"
+ FIXPATH="$FIXPATH_BIN -c"
elif test "x$OPENJDK_BUILD_OS_ENV" = xwindows.msys; then
- FIXPATH_SRC=`cmd //c echo $FIXPATH_SRC`
- FIXPATH_BIN=`cmd //c echo $FIXPATH_BIN`
-
# Take all collected prefixes and turn them into a -m/c/foo@/c/bar@... command line
# @ was chosen as separator to minimize risk of other tools messing around with it
- all_unique_prefixes=`echo "${all_fixpath_prefixes[@]}" | tr ' ' '\n' | grep '^/./' | sort | uniq`
+ all_unique_prefixes=`echo "${all_fixpath_prefixes[@]}" \
+ | tr ' ' '\n' | grep '^/./' | sort | uniq`
fixpath_argument_list=`echo $all_unique_prefixes | tr ' ' '@'`
-
- FIXPATH="$OUTPUT_ROOT/fixpath -m$fixpath_argument_list"
- fi
- rm -f $OUTPUT_ROOT/fixpath*
- cd $OUTPUT_ROOT
- $CC $FIXPATH_SRC -Fe$FIXPATH_BIN > $OUTPUT_ROOT/fixpath1.log 2>&1
+ FIXPATH="$FIXPATH_BIN -m$fixpath_argument_list"
+ fi
+ FIXPATH_SRC_W="$FIXPATH_SRC"
+ FIXPATH_BIN_W="$FIXPATH_BIN"
+
+ unix_path="$FIXPATH_SRC_W"
+ if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+ windows_path=`$CYGPATH -m "$unix_path"`
+ FIXPATH_SRC_W="$windows_path"
+ elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+ windows_path=`cmd //c echo $unix_path`
+ FIXPATH_SRC_W="$windows_path"
+ fi
+
+
+ unix_path="$FIXPATH_BIN_W"
+ if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+ windows_path=`$CYGPATH -m "$unix_path"`
+ FIXPATH_BIN_W="$windows_path"
+ elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+ windows_path=`cmd //c echo $unix_path`
+ FIXPATH_BIN_W="$windows_path"
+ fi
+
+ $RM -rf $FIXPATH_BIN $FIXPATH_DIR
+ $MKDIR -p $FIXPATH_DIR $CONFIGURESUPPORT_OUTPUTDIR/bin
+ cd $FIXPATH_DIR
+ $CC $FIXPATH_SRC_W -Fe$FIXPATH_BIN_W > $FIXPATH_DIR/fixpath1.log 2>&1
cd $CURDIR
- if test ! -x $OUTPUT_ROOT/fixpath.exe; then
+ if test ! -x $FIXPATH_BIN; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
- cat $OUTPUT_ROOT/fixpath1.log
- as_fn_error $? "Could not create $OUTPUT_ROOT/fixpath.exe" "$LINENO" 5
+ cat $FIXPATH_DIR/fixpath1.log
+ as_fn_error $? "Could not create $FIXPATH_BIN" "$LINENO" 5
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if fixpath.exe works" >&5
$as_echo_n "checking if fixpath.exe works... " >&6; }
- cd $OUTPUT_ROOT
- $FIXPATH $CC $SRC_ROOT/common/src/fixpath.c -Fe$OUTPUT_ROOT/fixpath2.exe > $OUTPUT_ROOT/fixpath2.log 2>&1
+ cd $FIXPATH_DIR
+ $FIXPATH $CC $FIXPATH_SRC -Fe$FIXPATH_DIR/fixpath2.exe \
+ > $FIXPATH_DIR/fixpath2.log 2>&1
cd $CURDIR
- if test ! -x $OUTPUT_ROOT/fixpath2.exe; then
+ if test ! -x $FIXPATH_DIR/fixpath2.exe; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
- cat $OUTPUT_ROOT/fixpath2.log
+ cat $FIXPATH_DIR/fixpath2.log
as_fn_error $? "fixpath did not work!" "$LINENO" 5
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
- rm -f $OUTPUT_ROOT/fixpath?.??? $OUTPUT_ROOT/fixpath.obj
fi
@@ -51415,13 +51438,6 @@
$as_echo "$ENABLE_SJAVAC" >&6; }
- if test "x$ENABLE_SJAVAC" = xyes; then
- SJAVAC_SERVER_DIR="$OUTPUT_ROOT/javacservers"
- else
- SJAVAC_SERVER_DIR=
- fi
-
-
# Can the C/C++ compiler use precompiled headers?
@@ -51849,7 +51865,7 @@
# We're messing a bit with internal autoconf variables to put the config.status
# in the output directory instead of the current directory.
-CONFIG_STATUS="$OUTPUT_ROOT/config.status"
+CONFIG_STATUS="$CONFIGURESUPPORT_OUTPUTDIR/config.status"
# Create the actual output files. Now the main work of configure is done.
cat >confcache <<\_ACEOF
@@ -53017,7 +53033,7 @@
# Try to move the config.log file to the output directory.
if test -e ./config.log; then
- $MV -f ./config.log "$OUTPUT_ROOT/config.log" 2> /dev/null
+ $MV -f ./config.log "$CONFIGURESUPPORT_OUTPUTDIR/config.log" 2> /dev/null
fi
# Make the compare script executable
--- a/common/autoconf/spec.gmk.in Mon Apr 13 17:03:11 2015 -0700
+++ b/common/autoconf/spec.gmk.in Tue Apr 14 12:10:00 2015 -0700
@@ -59,7 +59,7 @@
MAKE := @MAKE@
# The default make arguments
-MAKE_ARGS = $(MAKE_LOG_FLAGS) -R -I $(TOPDIR)/make/common SPEC=$(SPEC) \
+MAKE_ARGS = $(MAKE_LOG_FLAGS) -r -R -I $(TOPDIR)/make/common SPEC=$(SPEC) \
MAKE_LOG_FLAGS="$(MAKE_LOG_FLAGS)" LOG_LEVEL=$(LOG_LEVEL)
OUTPUT_SYNC_SUPPORTED:=@OUTPUT_SYNC_SUPPORTED@
@@ -231,13 +231,14 @@
# Colon left out to be able to override IMAGES_OUTPUTDIR for bootcycle-images
SUPPORT_OUTPUTDIR=$(BUILD_OUTPUT)/support
BUILDTOOLS_OUTPUTDIR=$(BUILD_OUTPUT)/buildtools
-MAKESUPPORT_OUTPUTDIR=$(BUILD_OUTPUT)/makesupport
HOTSPOT_OUTPUTDIR=$(BUILD_OUTPUT)/hotspot
JDK_OUTPUTDIR=$(BUILD_OUTPUT)/jdk
IMAGES_OUTPUTDIR=$(BUILD_OUTPUT)/images
TESTMAKE_OUTPUTDIR=$(BUILD_OUTPUT)/test-make
MAKESUPPORT_OUTPUTDIR=$(BUILD_OUTPUT)/make-support
+# This does not get overridden in a bootcycle build
+CONFIGURESUPPORT_OUTPUTDIR:=@CONFIGURESUPPORT_OUTPUTDIR@
HOTSPOT_DIST=@HOTSPOT_DIST@
@@ -259,7 +260,7 @@
ENABLE_SJAVAC:=@ENABLE_SJAVAC@
# Store sjavac server synchronization files here, and
# the sjavac server log files.
-SJAVAC_SERVER_DIR:=@SJAVAC_SERVER_DIR@
+SJAVAC_SERVER_DIR=$(MAKESUPPORT_OUTPUTDIR)/javacservers
# Number of parallel jobs to use for compilation
JOBS?=@JOBS@
--- a/common/autoconf/toolchain_windows.m4 Mon Apr 13 17:03:11 2015 -0700
+++ b/common/autoconf/toolchain_windows.m4 Tue Apr 14 12:10:00 2015 -0700
@@ -270,7 +270,7 @@
AC_MSG_NOTICE([Trying to extract Visual Studio environment variables])
# We need to create a couple of temporary files.
- VS_ENV_TMP_DIR="$OUTPUT_ROOT/vs-env"
+ VS_ENV_TMP_DIR="$CONFIGURESUPPORT_OUTPUTDIR/vs-env"
$MKDIR -p $VS_ENV_TMP_DIR
# Cannot use the VS10 setup script directly (since it only updates the DOS subshell environment).
--- a/common/bin/unshuffle_list.txt Mon Apr 13 17:03:11 2015 -0700
+++ b/common/bin/unshuffle_list.txt Tue Apr 14 12:10:00 2015 -0700
@@ -1294,6 +1294,9 @@
jdk/src/jdk.crypto.pkcs11/windows/native/libj2pkcs11/p11_md.c : jdk/src/windows/native/sun/security/pkcs11/wrapper/p11_md.c
jdk/src/jdk.crypto.pkcs11/windows/native/libj2pkcs11/p11_md.h : jdk/src/windows/native/sun/security/pkcs11/wrapper/p11_md.h
jdk/src/jdk.deploy.osx/macosx/classes/com/apple/concurrent/package.html : jdk/src/macosx/classes/com/apple/concurrent/package.html
+jdk/src/jdk.deploy.osx/macosx/classes/apple/applescript : jdk/src/macosx/classes/apple/applescript
+jdk/src/jdk.deploy.osx/macosx/classes/apple/security : jdk/src/macosx/classes/apple/security
+jdk/src/jdk.deploy.osx/macosx/classes/com/apple/concurrent : jdk/src/macosx/classes/com/apple/concurrent
jdk/src/jdk.deploy.osx/macosx/native/libapplescriptengine : jdk/src/macosx/native/apple/applescript
jdk/src/jdk.deploy.osx/macosx/native/libosx/CFileManager.m : jdk/src/macosx/native/com/apple/eio/CFileManager.m
jdk/src/jdk.deploy.osx/macosx/native/libosx/Dispatch.m : jdk/src/macosx/native/com/apple/concurrent/Dispatch.m
--- a/corba/.hgtags Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/.hgtags Tue Apr 14 12:10:00 2015 -0700
@@ -300,3 +300,5 @@
734ca5311a225711b79618f3e92f47f07c82154a jdk9-b55
ef4afd6832b00b8687832c2a36c90e43750ebe40 jdk9-b56
d8ebf1a5b18ccbc849f5bf0f80aa3d78583eee68 jdk9-b57
+86dd5de1f5cb09073019bd629e22cfcd012d8b4b jdk9-b58
+cda6ae062f85fac5555f4e1318885b0ecd998bd1 jdk9-b59
--- a/corba/src/java.corba/share/classes/javax/activity/package.html Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/javax/activity/package.html Tue Apr 14 12:10:00 2015 -0700
@@ -2,7 +2,7 @@
<html>
<head>
<!--
-Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
<body bgcolor="white">
Contains Activity service related exceptions thrown by the ORB machinery during
unmarshalling.
-<p>
+
@since 1.5
</body>
</html>
--- a/corba/src/java.corba/share/classes/javax/rmi/CORBA/Util.java Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/javax/rmi/CORBA/Util.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -232,6 +232,8 @@
* and <tt>loader</tt> is non-null, then call <tt>loader.loadClass(className)</tt>.
* <LI>If a class was successfully loaded by step 1, 2, 3, or 4, then
* return the loaded class, else throw <tt>ClassNotFoundException</tt>.
+ * </UL>
+ *
* @param className the name of the class.
* @param remoteCodebase a space-separated list of URLs at which
* the class might be found. May be null.
--- a/corba/src/java.corba/share/classes/org/omg/CORBA/Any.java Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/CORBA/Any.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -52,21 +52,21 @@
* </OL>
*
* <P>
- * <a name="anyOps"</a>
+ * <a name="anyOps"></a>
* A large part of the <code>Any</code> class consists of pairs of methods
* for inserting values into and extracting values from an
* <code>Any</code> object.
* <P>
* For a given primitive type X, these methods are:
* <dl>
- * <dt><code><bold> void insert_X(X x)</bold></code>
+ * <dt><code><b>void insert_X(X x)</b></code>
* <dd> This method allows the insertion of
* an instance <code>x</code> of primitive type <code>X</code>
* into the <code>value</code> field of the <code>Any</code> object.
* Note that the method
* <code>insert_X</code> also resets the <code>Any</code> object's
* <code>type</code> field if necessary.
- * <dt> <code><bold>X extract_X()</bold></code>
+ * <dt> <code><b>X extract_X()</b></code>
* <dd> This method allows the extraction of an instance of
* type <code>X</code> from the <code>Any</code> object.
* <BR>
--- a/corba/src/java.corba/share/classes/org/omg/CORBA/CompletionStatus.java Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/CORBA/CompletionStatus.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2000, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -40,10 +40,10 @@
* <P>
* The class also contains two methods:
* <UL>
- * <LI><code>public int <bold>value</bold>()</code> -- which accesses the
+ * <LI><code>public int <b>value</b>()</code> -- which accesses the
* <code>value</code> field of a <code>CompletionStatus</code> object
* <LI><code>public static CompletionStatus
- * <bold>from_int</bold>(int i)</code> --
+ * <b>from_int</b>(int i)</code> --
* for creating an instance from one of the <code>int</code> members
* </UL>
* @see org.omg.CORBA.SystemException
--- a/corba/src/java.corba/share/classes/org/omg/CORBA/DataInputStream.java Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/CORBA/DataInputStream.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,7 @@
{
/** Reads an IDL <code>Any</code> value from the input stream.
* @return the <code>Any</code> read.
- * @throws <code>org.omg.CORBA.MARSHAL</code>
+ * @throws org.omg.CORBA.MARSHAL
* If an inconsistency is detected, including not having registered
* a streaming policy, then the standard system exception MARSHAL is raised.
*/
@@ -43,7 +43,7 @@
/** Reads an IDL boolean value from the input stream.
* @return the boolean read.
- * @throws <code>org.omg.CORBA.MARSHAL</code>
+ * @throws org.omg.CORBA.MARSHAL
* If an inconsistency is detected, including not having registered
* a streaming policy, then the standard system exception MARSHAL is raised.
*/
@@ -51,7 +51,7 @@
/** Reads an IDL character value from the input stream.
* @return the character read.
- * @throws <code>org.omg.CORBA.MARSHAL</code>
+ * @throws org.omg.CORBA.MARSHAL
* If an inconsistency is detected, including not having registered
* a streaming policy, then the standard system exception MARSHAL is raised.
*/
@@ -59,7 +59,7 @@
/** Reads an IDL wide character value from the input stream.
* @return the wide character read.
- * @throws <code>org.omg.CORBA.MARSHAL</code>
+ * @throws org.omg.CORBA.MARSHAL
* If an inconsistency is detected, including not having registered
* a streaming policy, then the standard system exception MARSHAL is raised.
*/
@@ -67,7 +67,7 @@
/** Reads an IDL octet value from the input stream.
* @return the octet value read.
- * @throws <code>org.omg.CORBA.MARSHAL</code>
+ * @throws org.omg.CORBA.MARSHAL
* If an inconsistency is detected, including not having registered
* a streaming policy, then the standard system exception MARSHAL is raised.
*/
@@ -75,7 +75,7 @@
/** Reads an IDL short from the input stream.
* @return the short read.
- * @throws <code>org.omg.CORBA.MARSHAL</code>
+ * @throws org.omg.CORBA.MARSHAL
* If an inconsistency is detected, including not having registered
* a streaming policy, then the standard system exception MARSHAL is raised.
*/
@@ -83,7 +83,7 @@
/** Reads an IDL unsigned short from the input stream.
* @return the unsigned short read.
- * @throws <code>org.omg.CORBA.MARSHAL</code>
+ * @throws org.omg.CORBA.MARSHAL
* If an inconsistency is detected, including not having registered
* a streaming policy, then the standard system exception MARSHAL is raised.
*/
@@ -91,7 +91,7 @@
/** Reads an IDL long from the input stream.
* @return the long read.
- * @throws <code>org.omg.CORBA.MARSHAL</code>
+ * @throws org.omg.CORBA.MARSHAL
* If an inconsistency is detected, including not having registered
* a streaming policy, then the standard system exception MARSHAL is raised.
*/
@@ -99,7 +99,7 @@
/** Reads an IDL unsigned long from the input stream.
* @return the unsigned long read.
- * @throws <code>org.omg.CORBA.MARSHAL</code>
+ * @throws org.omg.CORBA.MARSHAL
* If an inconsistency is detected, including not having registered
* a streaming policy, then the standard system exception MARSHAL is raised.
*/
@@ -107,7 +107,7 @@
/** Reads an IDL long long from the input stream.
* @return the long long read.
- * @throws <code>org.omg.CORBA.MARSHAL</code>
+ * @throws org.omg.CORBA.MARSHAL
* If an inconsistency is detected, including not having registered
* a streaming policy, then the standard system exception MARSHAL is raised.
*/
@@ -115,7 +115,7 @@
/** Reads an unsigned IDL long long from the input stream.
* @return the unsigned long long read.
- * @throws <code>org.omg.CORBA.MARSHAL</code>
+ * @throws org.omg.CORBA.MARSHAL
* If an inconsistency is detected, including not having registered
* a streaming policy, then the standard system exception MARSHAL is raised.
*/
@@ -123,7 +123,7 @@
/** Reads an IDL float from the input stream.
* @return the float read.
- * @throws <code>org.omg.CORBA.MARSHAL</code>
+ * @throws org.omg.CORBA.MARSHAL
* If an inconsistency is detected, including not having registered
* a streaming policy, then the standard system exception MARSHAL is raised.
*/
@@ -131,7 +131,7 @@
/** Reads an IDL double from the input stream.
* @return the double read.
- * @throws <code>org.omg.CORBA.MARSHAL</code>
+ * @throws org.omg.CORBA.MARSHAL
* If an inconsistency is detected, including not having registered
* a streaming policy, then the standard system exception MARSHAL is raised.
*/
@@ -140,7 +140,7 @@
/** Reads an IDL string from the input stream.
* @return the string read.
- * @throws <code>org.omg.CORBA.MARSHAL</code>
+ * @throws org.omg.CORBA.MARSHAL
* If an inconsistency is detected, including not having registered
* a streaming policy, then the standard system exception MARSHAL is raised.
*/
@@ -148,7 +148,7 @@
/** Reads an IDL wide string from the input stream.
* @return the wide string read.
- * @throws <code>org.omg.CORBA.MARSHAL</code>
+ * @throws org.omg.CORBA.MARSHAL
* If an inconsistency is detected, including not having registered
* a streaming policy, then the standard system exception MARSHAL is raised.
*/
@@ -156,7 +156,7 @@
/** Reads an IDL CORBA::Object from the input stream.
* @return the CORBA::Object read.
- * @throws <code>org.omg.CORBA.MARSHAL</code>
+ * @throws org.omg.CORBA.MARSHAL
* If an inconsistency is detected, including not having registered
* a streaming policy, then the standard system exception MARSHAL is raised.
*/
@@ -164,7 +164,7 @@
/** Reads an IDL Abstract interface from the input stream.
* @return the Abstract interface read.
- * @throws <code>org.omg.CORBA.MARSHAL</code>
+ * @throws org.omg.CORBA.MARSHAL
* If an inconsistency is detected, including not having registered
* a streaming policy, then the standard system exception MARSHAL is raised.
*/
@@ -172,7 +172,7 @@
/** Reads an IDL value type from the input stream.
* @return the value type read.
- * @throws <code>org.omg.CORBA.MARSHAL</code>
+ * @throws org.omg.CORBA.MARSHAL
* If an inconsistency is detected, including not having registered
* a streaming policy, then the standard system exception MARSHAL is raised.
*/
@@ -180,7 +180,7 @@
/** Reads an IDL typecode from the input stream.
* @return the typecode read.
- * @throws <code>org.omg.CORBA.MARSHAL</code>
+ * @throws org.omg.CORBA.MARSHAL
* If an inconsistency is detected, including not having registered
* a streaming policy, then the standard system exception MARSHAL is raised.
*/
@@ -192,7 +192,7 @@
* @param offset The index into seq of the first element to read from the
* input stream.
* @param length The number of elements to read from the input stream.
- * @throws <code>org.omg.CORBA.MARSHAL</code>
+ * @throws org.omg.CORBA.MARSHAL
* If an inconsistency is detected, including not having registered
* a streaming policy, then the standard system exception MARSHAL is raised.
*/
@@ -204,7 +204,7 @@
* @param offset The index into seq of the first element to read from the
* input stream.
* @param length The number of elements to read from the input stream.
- * @throws <code>org.omg.CORBA.MARSHAL</code>
+ * @throws org.omg.CORBA.MARSHAL
* If an inconsistency is detected, including not having registered
* a streaming policy, then the standard system exception MARSHAL is raised.
*/
@@ -216,7 +216,7 @@
* @param offset The index into seq of the first element to read from the
* input stream.
* @param length The number of elements to read from the input stream.
- * @throws <code>org.omg.CORBA.MARSHAL</code>
+ * @throws org.omg.CORBA.MARSHAL
* If an inconsistency is detected, including not having registered
* a streaming policy, then the standard system exception MARSHAL is raised.
*/
@@ -228,7 +228,7 @@
* @param offset The index into seq of the first element to read from the
* input stream.
* @param length The number of elements to read from the input stream.
- * @throws <code>org.omg.CORBA.MARSHAL</code>
+ * @throws org.omg.CORBA.MARSHAL
* If an inconsistency is detected, including not having registered
* a streaming policy, then the standard system exception MARSHAL is raised.
*/
@@ -240,7 +240,7 @@
* @param offset The index into seq of the first element to read from the
* input stream.
* @param length The number of elements to read from the input stream.
- * @throws <code>org.omg.CORBA.MARSHAL</code>
+ * @throws org.omg.CORBA.MARSHAL
* If an inconsistency is detected, including not having registered
* a streaming policy, then the standard system exception MARSHAL is raised.
*/
@@ -252,7 +252,7 @@
* @param offset The index into seq of the first element to read from the
* input stream.
* @param length The number of elements to read from the input stream.
- * @throws <code>org.omg.CORBA.MARSHAL</code>
+ * @throws org.omg.CORBA.MARSHAL
* If an inconsistency is detected, including not having registered
* a streaming policy, then the standard system exception MARSHAL is raised.
*/
@@ -264,7 +264,7 @@
* @param offset The index into seq of the first element to read from the
* input stream.
* @param length The number of elements to read from the input stream.
- * @throws <code>org.omg.CORBA.MARSHAL</code>
+ * @throws org.omg.CORBA.MARSHAL
* If an inconsistency is detected, including not having registered
* a streaming policy, then the standard system exception MARSHAL is raised.
*/
@@ -276,7 +276,7 @@
* @param offset The index into seq of the first element to read from the
* input stream.
* @param length The number of elements to read from the input stream.
- * @throws <code>org.omg.CORBA.MARSHAL</code>
+ * @throws org.omg.CORBA.MARSHAL
* If an inconsistency is detected, including not having registered
* a streaming policy, then the standard system exception MARSHAL is raised.
*/
@@ -288,7 +288,7 @@
* @param offset The index into seq of the first element to read from the
* input stream.
* @param length The number of elements to read from the input stream.
- * @throws <code>org.omg.CORBA.MARSHAL</code>
+ * @throws org.omg.CORBA.MARSHAL
* If an inconsistency is detected, including not having registered
* a streaming policy, then the standard system exception MARSHAL is raised.
*/
@@ -300,7 +300,7 @@
* @param offset The index into seq of the first element to read from the
* input stream.
* @param length The number of elements to read from the input stream.
- * @throws <code>org.omg.CORBA.MARSHAL</code>
+ * @throws org.omg.CORBA.MARSHAL
* If an inconsistency is detected, including not having registered
* a streaming policy, then the standard system exception MARSHAL is raised.
*/
@@ -312,7 +312,7 @@
* @param offset The index into seq of the first element to read from the
* input stream.
* @param length The number of elements to read from the input stream.
- * @throws <code>org.omg.CORBA.MARSHAL</code>
+ * @throws org.omg.CORBA.MARSHAL
* If an inconsistency is detected, including not having registered
* a streaming policy, then the standard system exception MARSHAL is raised.
*/
@@ -324,7 +324,7 @@
* @param offset The index into seq of the first element to read from the
* input stream.
* @param length The number of elements to read from the input stream.
- * @throws <code>org.omg.CORBA.MARSHAL</code>
+ * @throws org.omg.CORBA.MARSHAL
* If an inconsistency is detected, including not having registered
* a streaming policy, then the standard system exception MARSHAL is raised.
*/
@@ -336,7 +336,7 @@
* @param offset The index into seq of the first element to read from the
* input stream.
* @param length The number of elements to read from the input stream.
- * @throws <code>org.omg.CORBA.MARSHAL</code>
+ * @throws org.omg.CORBA.MARSHAL
* If an inconsistency is detected, including not having registered
* a streaming policy, then the standard system exception MARSHAL is raised.
*/
--- a/corba/src/java.corba/share/classes/org/omg/CORBA/LocalObject.java Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/CORBA/LocalObject.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -71,7 +71,7 @@
* to attempt determination of whether two distinct object references
* refer to the same object, since such determination could be impractically
* expensive.
- * <P>Default implementation of the org.omg.CORBA.Object method. <P>
+ * <P>Default implementation of the org.omg.CORBA.Object method.
*
* @param that the object reference with which to check for equivalence
* @return <code>true</code> if this object reference is known to be
@@ -87,7 +87,7 @@
/**
* Always returns <code>false</code>.
* This method is the default implementation of the
- * <code>org.omg.CORBA.Object</code> method.<P>
+ * <code>org.omg.CORBA.Object</code> method.
*
* @return <code>false</code>
*/
@@ -99,9 +99,10 @@
* Returns a hash value that is consistent for the
* lifetime of the object, using the given number as the maximum.
* This method is the default implementation of the
- * <code>org.omg.CORBA.Object</code> method.<P>
+ * <code>org.omg.CORBA.Object</code> method.
+ *
* @param maximum an <code>int</code> identifying maximum value of
- * the hashcode
+ * the hashcode
* @return this instance's hashcode
*/
public int _hash(int maximum) {
@@ -113,7 +114,7 @@
* the message "This is a locally constrained object." This method
* does not apply to local objects and is therefore not implemented.
* This method is the default implementation of the
- * <code>org.omg.CORBA.Object</code> method.<P>
+ * <code>org.omg.CORBA.Object</code> method.
*
* @param repository_id a <code>String</code>
* @return NO_IMPLEMENT because this is a locally constrained object
@@ -131,7 +132,8 @@
* Throws an <code>org.omg.CORBA.NO_IMPLEMENT</code> exception with
* the message "This is a locally constrained object."
* This method is the default implementation of the
- * <code>org.omg.CORBA.Object</code> method.<P>
+ * <code>org.omg.CORBA.Object</code> method.
+ *
* @return a duplicate of this <code>LocalObject</code> instance.
* @exception NO_IMPLEMENT
* @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
@@ -145,7 +147,8 @@
* Throws an <code>org.omg.CORBA.NO_IMPLEMENT</code> exception with
* the message "This is a locally constrained object."
* This method is the default implementation of the
- * <code>org.omg.CORBA.Object</code> method.<P>
+ * <code>org.omg.CORBA.Object</code> method.
+ *
* @exception NO_IMPLEMENT
* @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
* comments for unimplemented features</a>
@@ -158,7 +161,7 @@
* Throws an <code>org.omg.CORBA.NO_IMPLEMENT</code> exception with
* the message "This is a locally constrained object."
* This method is the default implementation of the
- * <code>org.omg.CORBA.Object</code> method.<P>
+ * <code>org.omg.CORBA.Object</code> method.
*
* @param operation a <code>String</code> giving the name of an operation
* to be performed by the request that is returned
@@ -175,7 +178,7 @@
* Throws an <code>org.omg.CORBA.NO_IMPLEMENT</code> exception with
* the message "This is a locally constrained object."
* This method is the default implementation of the
- * <code>org.omg.CORBA.Object</code> method.<P>
+ * <code>org.omg.CORBA.Object</code> method.
*
* @param ctx a <code>Context</code> object containing
* a list of properties
@@ -202,7 +205,7 @@
* Throws an <code>org.omg.CORBA.NO_IMPLEMENT</code> exception with
* the message "This is a locally constrained object."
* This method is the default implementation of the
- * <code>org.omg.CORBA.Object</code> method.<P>
+ * <code>org.omg.CORBA.Object</code> method.
*
* @param ctx a <code>Context</code> object containing
* a list of properties
@@ -237,7 +240,8 @@
* the message "This is a locally constrained object." This method
* does not apply to local objects and is therefore not implemented.
* This method is the default implementation of the
- * <code>org.omg.CORBA.Object</code> method.<P>
+ * <code>org.omg.CORBA.Object</code> method.
+ *
* @return NO_IMPLEMENT because this is a locally constrained object
* and this method does not apply to local objects
* @exception NO_IMPLEMENT because this is a locally constrained object
@@ -254,7 +258,8 @@
* Throws an <code>org.omg.CORBA.NO_IMPLEMENT</code> exception with
* the message "This is a locally constrained object."
* This method is the default implementation of the
- * <code>org.omg.CORBA.Object</code> method.<P>
+ * <code>org.omg.CORBA.Object</code> method.
+ *
* @exception NO_IMPLEMENT
* @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
* comments for unimplemented features</a>
@@ -275,7 +280,7 @@
* Throws an <code>org.omg.CORBA.NO_IMPLEMENT</code> exception with
* the message "This is a locally constrained object."
* This method is the default implementation of the
- * <code>org.omg.CORBA.Object</code> method.<P>
+ * <code>org.omg.CORBA.Object</code> method.
* @return the ORB instance that created the Delegate contained in this
* <code>ObjectImpl</code>
* @exception NO_IMPLEMENT
@@ -291,7 +296,8 @@
* the message "This is a locally constrained object." This method
* does not apply to local objects and is therefore not implemented.
* This method is the default implementation of the
- * <code>org.omg.CORBA.Object</code> method.<P>
+ * <code>org.omg.CORBA.Object</code> method.
+ *
* @param policy_type an <code>int</code>
* @return NO_IMPLEMENT because this is a locally constrained object
* and this method does not apply to local objects
@@ -310,7 +316,8 @@
* the message "This is a locally constrained object." This method
* does not apply to local objects and is therefore not implemented.
* This method is the default implementation of the
- * <code>org.omg.CORBA.Object</code> method.<P>
+ * <code>org.omg.CORBA.Object</code> method.
+ *
* @exception NO_IMPLEMENT
* @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
* comments for unimplemented features</a>
@@ -347,7 +354,8 @@
* the message "This is a locally constrained object."
* This method is the default implementation of the
* <code>org.omg.CORBA.Object</code> method.<P>
- * Returns <code>true</code> for this <code>LocalObject</code> instance.<P>
+ * Returns <code>true</code> for this <code>LocalObject</code> instance.
+ *
* @return <code>true</code> always
* @exception NO_IMPLEMENT
* @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
@@ -361,7 +369,8 @@
* Throws an <code>org.omg.CORBA.NO_IMPLEMENT</code> exception with
* the message "This is a locally constrained object."
* This method is the default implementation of the
- * <code>org.omg.CORBA.Object</code> method.<P>
+ * <code>org.omg.CORBA.Object</code> method.
+ *
* @param operation a <code>String</code> indicating which operation
* to preinvoke
* @param expectedType the class of the type of operation mentioned above
@@ -381,7 +390,8 @@
* Throws an <code>org.omg.CORBA.NO_IMPLEMENT</code> exception with
* the message "This is a locally constrained object."
* This method is the default implementation of the
- * <code>org.omg.CORBA.Object</code> method.<P>
+ * <code>org.omg.CORBA.Object</code> method.
+ *
* @param servant the servant object on which to post-invoke
* @exception NO_IMPLEMENT
* @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
@@ -403,8 +413,8 @@
* <code>org.omg.CORBA.Object</code> method.
* <P>Called by a stub to obtain an OutputStream for
* marshaling arguments. The stub must supply the operation name,
- * and indicate if a response is expected (i.e is this a oneway
- * call).<P>
+ * and indicate if a response is expected (i.e is this a oneway call).
+ *
* @param operation the name of the operation being requested
* @param responseExpected <code>true</code> if a response is expected,
* <code>false</code> if it is a one-way call
@@ -433,7 +443,8 @@
* marshaled reply. If an exception occurs, <code>_invoke</code> may throw an
* <code>ApplicationException</code> object which contains an
* <code>InputStream</code> from
- * which the user exception state may be unmarshaled.<P>
+ * which the user exception state may be unmarshaled.
+ *
* @param output the <code>OutputStream</code> to invoke
* @return NO_IMPLEMENT because this is a locally constrained object
* and this method does not apply to local objects
@@ -470,7 +481,8 @@
* <code>ApplicationException.getInputStream()</code>.
* A null
* value may also be passed to <code>_releaseReply</code>, in which case the
- * method is a no-op.<P>
+ * method is a no-op.
+ *
* @param input the reply stream back to the ORB or null
* @exception NO_IMPLEMENT
* @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
@@ -485,7 +497,8 @@
* the message "This is a locally constrained object." This method
* does not apply to local objects and is therefore not implemented.
* This method is the default implementation of the
- * <code>org.omg.CORBA.Object</code> method.<P>
+ * <code>org.omg.CORBA.Object</code> method.
+ *
* @return NO_IMPLEMENT because this is a locally constrained object
* and this method does not apply to local objects
* @exception NO_IMPLEMENT because this is a locally constrained object
--- a/corba/src/java.corba/share/classes/org/omg/CORBA/NVList.java Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/CORBA/NVList.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2000, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -63,7 +63,6 @@
* Note also that you can add any number of
* <code>NamedValue</code> objects to this list regardless of
* its original length.
- * <P>
* <LI><code>org.omg.CORBA.ORB.create_operation_list</code>
* <PRE>
* org.omg.CORBA.NVList nv = orb.create_operation_list(myOperationDef);
--- a/corba/src/java.corba/share/classes/org/omg/CORBA/ORB.java Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/CORBA/ORB.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -101,7 +101,7 @@
* <P>
* When an ORB instance is being created, the class name of the ORB
* implementation is located using
- * the following standard search order:<P>
+ * the following standard search order:
*
* <OL>
* <LI>check in Applet parameter or application string array, if any
@@ -1036,7 +1036,7 @@
* <P>
* Recursive types can only appear within sequences which can be empty.
* That way marshaling problems, when transmitting the struct in an Any, are avoided.
- * <P>
+ *
* @param id the logical id of the referenced type
* @return the requested TypeCode
*/
@@ -1179,7 +1179,7 @@
* value <tt>true</tt>. If no information for the requested
* services type is available, the operation returns <tt>false</tt>
* (i.e., the service is not supported by this ORB).
- * <P>
+ *
* @param service_type a <code>short</code> indicating the
* service type for which information is being requested
* @param service_info a <code>ServiceInformationHolder</code> object
@@ -1203,7 +1203,7 @@
/**
* Creates a new <code>DynAny</code> object from the given
* <code>Any</code> object.
- * <P>
+ *
* @param value the <code>Any</code> object from which to create a new
* <code>DynAny</code> object
* @return the new <code>DynAny</code> object created from the given
@@ -1221,7 +1221,7 @@
/**
* Creates a basic <code>DynAny</code> object from the given
* <code>TypeCode</code> object.
- * <P>
+ *
* @param type the <code>TypeCode</code> object from which to create a new
* <code>DynAny</code> object
* @return the new <code>DynAny</code> object created from the given
@@ -1241,7 +1241,7 @@
/**
* Creates a new <code>DynStruct</code> object from the given
* <code>TypeCode</code> object.
- * <P>
+ *
* @param type the <code>TypeCode</code> object from which to create a new
* <code>DynStruct</code> object
* @return the new <code>DynStruct</code> object created from the given
@@ -1261,7 +1261,7 @@
/**
* Creates a new <code>DynSequence</code> object from the given
* <code>TypeCode</code> object.
- * <P>
+ *
* @param type the <code>TypeCode</code> object from which to create a new
* <code>DynSequence</code> object
* @return the new <code>DynSequence</code> object created from the given
@@ -1282,7 +1282,7 @@
/**
* Creates a new <code>DynArray</code> object from the given
* <code>TypeCode</code> object.
- * <P>
+ *
* @param type the <code>TypeCode</code> object from which to create a new
* <code>DynArray</code> object
* @return the new <code>DynArray</code> object created from the given
@@ -1302,7 +1302,7 @@
/**
* Creates a new <code>DynUnion</code> object from the given
* <code>TypeCode</code> object.
- * <P>
+ *
* @param type the <code>TypeCode</code> object from which to create a new
* <code>DynUnion</code> object
* @return the new <code>DynUnion</code> object created from the given
@@ -1322,7 +1322,7 @@
/**
* Creates a new <code>DynEnum</code> object from the given
* <code>TypeCode</code> object.
- * <P>
+ *
* @param type the <code>TypeCode</code> object from which to create a new
* <code>DynEnum</code> object
* @return the new <code>DynEnum</code> object created from the given
--- a/corba/src/java.corba/share/classes/org/omg/CORBA/Object.java Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/CORBA/Object.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -53,7 +53,7 @@
* <code>org.omg.CORBA.Object</code>
* are provided in the class <code>org.omg.CORBA.portable.ObjectImpl</code>,
* which is the base class for stubs and object implementations.
- * <p>
+ *
* @see org.omg.CORBA.portable.ObjectImpl
*/
--- a/corba/src/java.corba/share/classes/org/omg/CORBA/Principal.java Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/CORBA/Principal.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,7 +31,7 @@
* the client, for access control
* and other purposes. It contains a single attribute, the name of the
* <code>Principal</code>, encoded as a sequence of bytes.
- * <P>
+ *
* @deprecated Deprecated by CORBA 2.2.
*/
@Deprecated
--- a/corba/src/java.corba/share/classes/org/omg/CORBA/ServerRequest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/CORBA/ServerRequest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -57,7 +57,7 @@
* Similarly, type information needs to be provided for the response,
* for either the expected result or for an exception, so the methods
* <code>result</code> and <code>except</code> take an <code>Any</code>
- * object as a parameter. <p>
+ * object as a parameter.
*
* @see org.omg.CORBA.DynamicImplementation
* @see org.omg.CORBA.NVList
--- a/corba/src/java.corba/share/classes/org/omg/CORBA/ShortHolder.java Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/CORBA/ShortHolder.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2001, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,8 +32,8 @@
/**
* The Holder for <tt>Short</tt>. For more information on
* Holder files, see <a href="doc-files/generatedfiles.html#holder">
- * "Generated Files: Holder Files"</a>.<P
- * A Holder class for a <code>short</code>
+ * "Generated Files: Holder Files"</a>.
+ * <P>A Holder class for a <code>short</code>
* that is used to store "out" and "inout" parameters in IDL operations.
* If an IDL operation signature has an IDL <code>short</code> as an "out"
* or "inout" parameter, the programmer must pass an instance of
--- a/corba/src/java.corba/share/classes/org/omg/CORBA/TCKind.java Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/CORBA/TCKind.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -52,7 +52,7 @@
* The variable <code>k</code> represents the <code>TCKind</code>
* instance for the IDL type <code>string</code>, which is
* <code>tk_string</code>.
- * <P>
+ *
* <LI>the method <code>value</code> for accessing the
* <code>_value</code> field of a <code>TCKind</code> constant
* <P>Example:
--- a/corba/src/java.corba/share/classes/org/omg/CORBA/TypeCode.java Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/CORBA/TypeCode.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,7 +31,7 @@
/**
* A container for information about a specific CORBA data
* type.
- *<P>
+ * <P>
* <code>TypeCode</code> objects are used:
* <UL>
* <LI>in the Dynamic Invocation Interface -- to indicate the types
@@ -59,7 +59,7 @@
* with the value
* <code>TCKind.tk_sequence</code> and also fields with the values
* <code>boolean</code> and <code>10</code> for the
- * type of sequence elements and the length of the sequence. <p>
+ * type of sequence elements and the length of the sequence.
* </UL>
*
* <code>TypeCode</code> objects can be obtained in various ways:
@@ -164,8 +164,7 @@
*
* Java IDL extends the CORBA specification to allow all operations permitted
* on a <code>struct</code> <code>TypeCode</code> to be permitted
- * on an <code>exception</code> <code>TypeCode</code> as well. <p>
- *
+ * on an <code>exception</code> <code>TypeCode</code> as well.
*/
public abstract class TypeCode implements IDLEntity {
@@ -175,23 +174,21 @@
* they are interchangeable and give identical results when
* <code>TypeCode</code> operations are applied to them.
*
- * @param tc the <code>TypeCode</code> object to compare against
- * @return <code>true</code> if the type codes are equal;
+ * @param tc the <code>TypeCode</code> object to compare against
+ * @return <code>true</code> if the type codes are equal;
* <code>false</code> otherwise
*/
-
public abstract boolean equal(TypeCode tc);
/**
- * Tests to see if the given <code>TypeCode</code> object is
- * equivalent to this <code>TypeCode</code> object.
- * <P>
- *
- *
- * @param tc the typecode to compare with this typecode
- *
- * @return <code>true</code> if the given typecode is equivalent to
- * this typecode; <code>false</code> otherwise
+ * Tests to see if the given <code>TypeCode</code> object is
+ * equivalent to this <code>TypeCode</code> object.
+ *
+ *
+ * @param tc the typecode to compare with this typecode
+ *
+ * @return <code>true</code> if the given typecode is equivalent to
+ * this typecode; <code>false</code> otherwise
*
*/
public abstract boolean equivalent(TypeCode tc);
@@ -199,9 +196,9 @@
/**
* Strips out all optional name and member name fields,
* but leaves all alias typecodes intact.
- * @return a <code>TypeCode</code> object with optional name and
- * member name fields stripped out, except for alias typecodes,
- * which are left intact
+ * @return a <code>TypeCode</code> object with optional name and
+ * member name fields stripped out, except for alias typecodes,
+ * which are left intact
* @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
* comments for unimplemented features</a>
*/
@@ -220,7 +217,6 @@
* value of the <code>kind</code> field of this
* <code>TypeCode</code> object
*/
-
public abstract TCKind kind();
/**
@@ -239,13 +235,12 @@
* also always have a RepositoryId. If there is no RepositoryId, the
* method can return an empty string.
*
- * @return the RepositoryId for this <code>TypeCode</code> object
- * or an empty string if there is no RepositoryID
+ * @return the RepositoryId for this <code>TypeCode</code> object
+ * or an empty string if there is no RepositoryID
* @throws org.omg.CORBA.TypeCodePackage.BadKind if the method
* is invoked on an inappropriate kind of<code>TypeCode</code>
* object
*/
-
public abstract String id() throws BadKind;
/**
@@ -268,7 +263,6 @@
* is invoked on an inappropriate kind of<code>TypeCode</code>
* object
*/
-
public abstract String name() throws BadKind;
/**
@@ -287,7 +281,6 @@
* is invoked on an inappropriate kind of <code>TypeCode</code>
* object
*/
-
public abstract int member_count() throws BadKind;
/**
@@ -312,7 +305,6 @@
* is invoked on an inappropriate kind of <code>TypeCode</code>
* object
*/
-
public abstract String member_name(int index)
throws BadKind, org.omg.CORBA.TypeCodePackage.Bounds;
@@ -336,7 +328,6 @@
* is invoked on an inappropriate kind of <code>TypeCode</code>
* object
*/
-
public abstract TypeCode member_type(int index)
throws BadKind, org.omg.CORBA.TypeCodePackage.Bounds;
@@ -344,13 +335,13 @@
* Retrieves the label of the union member
* identified by the given index. For the default member,
* the label is the zero octet.
- *<P>
+ * <P>
* The method <code>member_label</code> can only be invoked on union
* <code>TypeCode</code> objects.
*
- * @param index index of the union member for which the
+ * @param index index of the union member for which the
* label is being requested
- * @return an <code>Any</code> object describing the label of
+ * @return an <code>Any</code> object describing the label of
* the requested union member or the zero octet for
* the default member
* @throws org.omg.CORBA.TypeCodePackage.Bounds if the index is
@@ -360,7 +351,6 @@
* is invoked on a non-union <code>TypeCode</code>
* object
*/
-
public abstract Any member_label(int index)
throws BadKind, org.omg.CORBA.TypeCodePackage.Bounds;
@@ -376,7 +366,6 @@
* is invoked on a non-union <code>TypeCode</code>
* object
*/
-
public abstract TypeCode discriminator_type()
throws BadKind;
@@ -393,7 +382,6 @@
* is invoked on a non-union <code>TypeCode</code>
* object
*/
-
public abstract int default_index() throws BadKind;
/**
@@ -412,7 +400,6 @@
* is invoked on an inappropriate kind of <code>TypeCode</code>
* object
*/
-
public abstract int length() throws BadKind;
/**
@@ -424,7 +411,7 @@
* that multidimensional arrays are represented by nesting
* <code>TypeCode</code> objects, one per dimension.
* For boxed valuetypes, it returns the boxed type.
- *<P>
+ * <P>
* The method <code>content_type</code> can be invoked on sequence, array,
* alias, and boxed valuetype <code>TypeCode</code> objects.
*
@@ -436,37 +423,36 @@
* is invoked on an inappropriate kind of <code>TypeCode</code>
* object
*/
-
public abstract TypeCode content_type() throws BadKind;
/**
- * Returns the number of digits in the fixed type described by this
- * <code>TypeCode</code> object. For example, the typecode for
- * the number 3000.275d could be <code>fixed<7,3></code>, where
- * 7 is the precision and 3 is the scale.
- *
- * @return the total number of digits
+ * Returns the number of digits in the fixed type described by this
+ * <code>TypeCode</code> object. For example, the typecode for
+ * the number 3000.275d could be <code>fixed<7,3></code>, where
+ * 7 is the precision and 3 is the scale.
+ *
+ * @return the total number of digits
* @throws org.omg.CORBA.TypeCodePackage.BadKind if this method
* is invoked on an inappropriate kind of <code>TypeCode</code>
* object
- *
+ *
*/
public abstract short fixed_digits() throws BadKind ;
/**
- * Returns the scale of the fixed type described by this
- * <code>TypeCode</code> object. A positive number indicates the
- * number of digits to the right of the decimal point.
- * For example, the number 3000d could have the
- * typecode <code>fixed<4,0></code>, where the first number is
- * the precision and the second number is the scale.
- * A negative number is also possible and adds zeroes to the
- * left of the decimal point. In this case, <code>fixed<1,-3></code>,
- * could be the typecode for the number 3000d.
- *
- * @return the scale of the fixed type that this
- * <code>TypeCode</code> object describes
+ * Returns the scale of the fixed type described by this
+ * <code>TypeCode</code> object. A positive number indicates the
+ * number of digits to the right of the decimal point.
+ * For example, the number 3000d could have the
+ * typecode <code>fixed<4,0></code>, where the first number is
+ * the precision and the second number is the scale.
+ * A negative number is also possible and adds zeroes to the
+ * left of the decimal point. In this case, <code>fixed<1,-3></code>,
+ * could be the typecode for the number 3000d.
+ *
+ * @return the scale of the fixed type that this
+ * <code>TypeCode</code> object describes
* @throws org.omg.CORBA.TypeCodePackage.BadKind if this method
* is invoked on an inappropriate kind of <code>TypeCode</code>
* object
@@ -492,7 +478,6 @@
* @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
* comments for unimplemented features</a>
*/
-
abstract public short member_visibility(int index)
throws BadKind, org.omg.CORBA.TypeCodePackage.Bounds ;
@@ -512,7 +497,6 @@
* @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
* comments for unimplemented features</a>
*/
-
abstract public short type_modifier() throws BadKind ;
/**
@@ -528,6 +512,5 @@
* @see <a href="package-summary.html#unimpl"><code>CORBA</code> package
* comments for unimplemented features</a>
*/
-
abstract public TypeCode concrete_base_type() throws BadKind ;
}
--- a/corba/src/java.corba/share/classes/org/omg/CORBA/doc-files/compliance.html Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/CORBA/doc-files/compliance.html Tue Apr 14 12:10:00 2015 -0700
@@ -55,44 +55,30 @@
<li>
CORBA 2.3.1 chapter 4 with the following replacements from the Portable
-Interceptors specification:</li>
-
- <ul>
- <li>
- section 4.2.3.5 <TT>destroy</TT></li>
-
- <li>
- section 4.5.2 <TT>CodeFactory</TT> and <TT>PICurrent</TT> are required</li>
-
- <li>
- Section 4.5.3.4 as updated for <TT>register_initial_reference</TT></li>
- </ul>
+Interceptors specification:
+ <ul>
+ <li>section 4.2.3.5 <TT>destroy</TT></li>
+ <li>section 4.5.2 <TT>CodeFactory</TT> and <TT>PICurrent</TT> are required</li>
+ <li>Section 4.5.3.4 as updated for <TT>register_initial_reference</TT></li>
+ </ul>
+</li>
<li>
CORBA 2.3.1 chapter 5 with the following update from the Portable Interceptors
-specification:</li>
-
- <ul>
- <li>
- 5.5.2 <TT>StringSeq</TT> and <TT>WStringSeq</TT> are required. This adds the
-following
- classes
- to <TT>org.omg.CORBA</TT>:</li>
-
- <ul>
- <li>
- <TT>StringSeqHolder</TT></li>
-
- <li>
- <TT>StringSeqHelper</TT></li>
-
- <li>
- <TT>WStringSeqHolder</TT></li>
-
- <li>
- <TT>WStringSeqHelper</TT></li>
- </ul>
-</ul>
+specification:
+ <ul>
+ <li>
+ 5.5.2 <TT>StringSeq</TT> and <TT>WStringSeq</TT> are required.
+ This adds the following classes to <TT>org.omg.CORBA</TT>:
+ <ul>
+ <li><TT>StringSeqHolder</TT></li>
+ <li><TT>StringSeqHelper</TT></li>
+ <li><TT>WStringSeqHolder</TT></li>
+ <li><TT>WStringSeqHelper</TT></li>
+ </ul>
+ </li>
+ </ul>
+</li>
<li>
CORBA 2.3.1 sections 10.6.1 and 10.6.2 are supported for repository IDs.</li>
@@ -101,18 +87,13 @@
CORBA 2.3.1 section 10.7 for <TT>TypeCode</TT> APIs.</li>
<li>
-CORBA 2.3.1 chapter 11, Portable Object Adapter (POA), with the following updates from the Portable Interceptors specification:</li>
-
-<ul>
-<li>
-Section 11.3.7 POAs must preserve all policies</li>
-
-<li>
-Section 11.3.8.2 again states that POAs must preserve all policies</li>
-
-<li>
-Section 11.3.8.26 <tt>POA::id</tt> is required.</li>
-</ul>
+CORBA 2.3.1 chapter 11, Portable Object Adapter (POA), with the following updates from the Portable Interceptors specification:
+ <ul>
+ <li>Section 11.3.7 POAs must preserve all policies</li>
+ <li>Section 11.3.8.2 again states that POAs must preserve all policies</li>
+ <li>Section 11.3.8.26 <tt>POA::id</tt> is required.</li>
+ </ul>
+</li>
<li>
CORBA 2.3.1 chapters 13 and 15 define GIOP 1.0, 1.1, and 1.2. The Java SE 6
@@ -124,8 +105,7 @@
<li>
Portable Interceptors section 13.8 (the new <TT>Coder</TT>/<TT>Decoder</TT> interfaces)
-and
-all of chapter 21 (the interceptor specification).</li>
+and all of chapter 21 (the interceptor specification).</li>
<li>Section 1.21.8 of the Revised IDL to Java Language Mapping Specification (ptc/00-11-03)
has been changed from the version in the IDL to Java Language Mapping Specification (ptc/00-01-08).</li>
@@ -135,40 +115,24 @@
Tools</h2>
<ul>
-<li>
-The IDL to Java compiler (<TT>idlj</TT>) complies with:</li>
-
-<ul>
-<li>
-CORBA 2.3.1 chapter 3 (IDL definition)</li>
-
-<li>
-CORBA 2.3.1 chapters 5 and 6 (semantics of Value types)</li>
-
-<li>
-CORBA 2.3.1 section 10.6.5 (pragmas)</li>
-
-<li>
-The IDL to Java mapping specification</li>
+<li>The IDL to Java compiler (<TT>idlj</TT>) complies with:
+ <ul>
+ <li>CORBA 2.3.1 chapter 3 (IDL definition)</li>
+ <li>CORBA 2.3.1 chapters 5 and 6 (semantics of Value types)</li>
+ <li>CORBA 2.3.1 section 10.6.5 (pragmas)</li>
+ <li>The IDL to Java mapping specification</li>
+ <li>The Revised IDL to Java language mapping specification section 1.12.1 "local interfaces"</li>
+ </ul>
+</li>
-<li>
-The Revised IDL to Java language mapping specification section 1.12.1 "local interfaces"</li>
-</ul>
-
-<li>
-The Java to IDL compiler (the IIOP backend for <tt>rmic</tt>) complies with:</li>
-
-<ul>
-<li>
-CORBA 2.3.1 chapters 5 and 6 (value types)</li>
-
-<li>
-The Java to IDL language mapping. Note that this implicitly references
-section 1.21 of the IDL to Java language mapping</li>
-
-<li>
-IDL generated by the <tt>-idl</tt> flag complies with CORBA 2.3.1 chapter 3.</li>
-</ul>
+<li>The Java to IDL compiler (the IIOP backend for <tt>rmic</tt>) complies with:
+ <ul>
+ <li>CORBA 2.3.1 chapters 5 and 6 (value types)</li>
+ <li>The Java to IDL language mapping. Note that this implicitly references
+ section 1.21 of the IDL to Java language mapping</li>
+ <li>IDL generated by the <tt>-idl</tt> flag complies with CORBA 2.3.1 chapter 3.</li>
+ </ul>
+</li>
</ul>
</body>
--- a/corba/src/java.corba/share/classes/org/omg/CORBA/doc-files/generatedfiles.html Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/CORBA/doc-files/generatedfiles.html Tue Apr 14 12:10:00 2015 -0700
@@ -8,65 +8,101 @@
<H1>IDL-to-Java Generated Files</H1>
-<P>The files that are generated by the IDL-to-Java compiler, in accordance with the <em><a href="http://www.omg.org/cgi-bin/doc?ptc/00-01-08">IDL-to-Java Language Mapping Specification</a></em>, which is implemented in Java<sup><font size="-2">TM</font></sup> SE 6 according the <a href="compliance.html">compliance</a> document.
-
-
-<P>In general IDL names and identifiers are mapped to Java names and identifiers with no change. Because of the nature of the Java language, a single IDL construct may be mapped to several (differently named) Java constructs. The additional names are constructed by appending a descriptive suffix. For example, the IDL interface <tt>foo</tt> is mapped to the Java interfaces <tt>foo</tt> and <tt>fooOperations</tt>, and additional Java classes <tt>fooHelper</tt>, <tt>fooHolder</tt>, <tt>fooPOA</tt>, and optionally <tt>fooPOATie</tt>.
-
+<P>The files that are generated by the IDL-to-Java compiler, in accordance with
+the <em><a href="http://www.omg.org/cgi-bin/doc?ptc/00-01-08">IDL-to-Java Language Mapping Specification</a></em>,
+which is implemented in Java<sup><font size="-2">TM</font></sup> SE 6
+according the <a href="compliance.html">compliance</a> document.
-<P>The mapping in effect reserves the use of several names for its own purposes. These are:
-<P>
-<UL>
-<LI>The Java class <tt><a href="#helper"><type>Helper</tt></a>, where <tt><type></tt> is the name of an IDL defined type.
-<LI>The Java class <tt><a href="#holder"><type>Holder</tt></a>, where <tt><type></tt> is the name of an IDL defined type (with certain exceptions such as <tt>typedef</tt> aliases).
-<LI>The Java classes <tt><basicJavaType>Holder</tt>, where <tt><basicJavaType></tt> is one of the Java primitive datatypes that is used by one of the IDL basic datatypes.
-<LI>The Java classes <tt><a href="#operations"><interface>Operations</tt></a>, <tt><interface>POA</tt>, and <tt><interface>POATie</tt>, where <tt><interface></tt> is the name of an IDL interface type.
-<LI>The nested scope Java package name <tt><interface>Package</tt>, where <tt><interface></tt> is the name of an IDL interface.
-
-
-<a name="helper">
-<H2>Helper Files</H2></a>
-<P>
-Helper files supply several static methods needed to manipulate the type. These include <tt>Any</tt> insert and extract operations for the type, getting the repository id, getting the typecode, and reading and writing the type from and to a stream.
-
-<P>The helper class for a mapped IDL interface or abstract interface also include narrow operation(s). The static narrow method allows an <tt>org.omg.CORBA.Object</tt> to be narrowed to the object reference of a more specific type. The IDL exception <tt>CORBA::BAD_PARAM</tt> is thrown if the narrow fails because the object reference does not support the requested type. A different system exception is raised to indicate other kinds of errors. Trying to narrow a null will always succeed with a return value of null.
+<P>In general IDL names and identifiers are mapped to Java names
+and identifiers with no change. Because of the nature of the Java language,
+a single IDL construct may be mapped to several (differently named) Java constructs.
+The additional names are constructed by appending a descriptive suffix.
+For example, the IDL interface <tt>foo</tt> is mapped to the Java
+interfaces <tt>foo</tt> and <tt>fooOperations</tt>, and additional
+Java classes <tt>fooHelper</tt>, <tt>fooHolder</tt>, <tt>fooPOA</tt>,
+and optionally <tt>fooPOATie</tt>.
-<P>
-
-
-<a name="holder">
-<H2>Holder Files</H2></a>
-<P>
-Support for out and inout parameter passing modes requires the use of additional holder classes. These classes are available for all of the basic IDL datatypes in the <tt>org.omg.CORBA</tt> package and are generated for all named user defined IDL types except those defined by typedefs. (Note that in this context user defined includes types that are defined in OMG specifications such as those for the Interface Repository, and other OMG services.)
-
-
-<P>Each holder class has a constructor from an instance, a default constructor, and has a public instance member, <tt>value</tt> which is the typed value. The default constructor sets the value field to the default value for the type as defined by the Java language: false for boolean, 0 for numeric and char types, null for strings, null for object references.
-
-<P>To support portable stubs and skeletons, holder classes also implement the <tt>org.omg.CORBA.portable.Streamable</tt> interface.
+<P>The mapping in effect reserves the use of several names for its own purposes. These are:
+<UL>
+<LI>The Java class <a href="#helper"><tt><type>Helper</tt></a>, where <tt><type></tt> is the name of an IDL defined type.
+<LI>The Java class <a href="#holder"><tt><type>Holder</tt></a>, where <tt><type></tt>
+is the name of an IDL defined type (with certain exceptions such as <tt>typedef</tt> aliases).
+<LI>The Java classes <tt><basicJavaType>Holder</tt>, where <tt><basicJavaType></tt>
+is one of the Java primitive datatypes that is used by one of the IDL basic datatypes.
+<LI>The Java classes <a href="#operations"><tt><interface>Operations</tt></a>, <tt><interface>POA</tt>,
+and <tt><interface>POATie</tt>, where <tt><interface></tt> is the name of an IDL interface type.
+<LI>The nested scope Java package name <tt><interface>Package</tt>, where <tt><interface></tt>
+is the name of an IDL interface.
+</UL>
-<a name="operations">
-<H2>Operations Files</H2></a>
-<P>
-A non abstract IDL interface is mapped to two public Java interfaces: a <em>signature</em> interface and an <em>operations</em> interface. The signature interface, which extends <tt>IDLEntity</tt>, has the same name as the IDL interface name and is used as the signature type in method declarations when interfaces of the specified type are used in other interfaces. The operations interface has the same name as the IDL interface with the suffix <tt>Operations</tt> appended to the end and is used in the server-side mapping and as a mechanism for providing optimized calls for collocated client and servers.
+<H2><a name="helper">Helper Files</a></H2>
+
+<P>Helper files supply several static methods needed to manipulate the type.
+These include <tt>Any</tt> insert and extract operations for the type,
+getting the repository id, getting the typecode, and reading
+and writing the type from and to a stream.
+
+<P>The helper class for a mapped IDL interface or abstract interface also
+include narrow operation(s). The static narrow method allows an <tt>org.omg.CORBA.Object</tt>
+to be narrowed to the object reference of a more specific type.
+The IDL exception <tt>CORBA::BAD_PARAM</tt> is thrown if the narrow fails because
+the object reference does not support the requested type. A different system exception
+is raised to indicate other kinds of errors. Trying to narrow a null will always succeed with a return value of null.
-<P>The Java operations interface contains the mapped operation signatures. The Java signature interface extends the operations interface, the (mapped) base <tt>org.omg.CORBA.Object</tt>, as well as <tt>org.omg.portable.IDLEntity</tt>. Methods can be invoked on the signature interface. Interface inheritance expressed in IDL is reflected in both the Java signature interface and operations interface hierarchies.
+<H2><a name="holder">Holder Files</a></H2>
+
+<P>Support for out and inout parameter passing modes requires the use of additional holder classes.
+These classes are available for all of the basic IDL datatypes in the <tt>org.omg.CORBA</tt> package
+and are generated for all named user defined IDL types except those defined by typedefs.
+(Note that in this context user defined includes types that are defined in OMG specifications
+such as those for the Interface Repository, and other OMG services.)
+<P>Each holder class has a constructor from an instance, a default constructor, and has
+a public instance member, <tt>value</tt> which is the typed value. The default constructor
+sets the value field to the default value for the type as defined by the Java language:
+false for boolean, 0 for numeric and char types, null for strings, null for object references.
+<P>To support portable stubs and skeletons, holder classes also implement
+the <tt>org.omg.CORBA.portable.Streamable</tt> interface.
-<a name="stub">
-<H2>Stubs</H2></a>
-<P>For the mapping of a non-object-oriented language, there will be a programming interface to the stubs for each interface type. Generally, the stubs will present access to the OMG IDL-defined operations on an object in a way that is easy for programmers to predict once they are familiar with OMG IDL and the language mapping for the particular programming language. The stubs make calls on the rest of the ORB using interfaces that are private to, and presumably optimized for, the particular ORB Core. If more than one ORB is available, there may be different stubs corresponding to the different ORBs. In this case, it is necessary for the ORB and language mapping to cooperate to associate the correct stubs with the particular object reference.
+<H2><a name="operations">Operations Files</a></H2>
+
+<P>A non abstract IDL interface is mapped to two public Java interfaces:
+a <em>signature</em> interface and an <em>operations</em> interface.
+The signature interface, which extends <tt>IDLEntity</tt>, has the same
+name as the IDL interface name and is used as the signature type in method declarations
+when interfaces of the specified type are used in other interfaces.
+The operations interface has the same name as the IDL interface with the suffix <tt>Operations</tt>
+appended to the end and is used in the server-side mapping and as a mechanism
+for providing optimized calls for collocated client and servers.
+
+<P>The Java operations interface contains the mapped operation signatures.
+The Java signature interface extends the operations interface,
+the (mapped) base <tt>org.omg.CORBA.Object</tt>, as well as <tt>org.omg.portable.IDLEntity</tt>.
+Methods can be invoked on the signature interface. Interface inheritance
+expressed in IDL is reflected in both the Java signature interface and operations interface hierarchies.
+
+
+<H2><a name="stub">Stubs</a></H2>
+
+<P>For the mapping of a non-object-oriented language, there will be
+a programming interface to the stubs for each interface type. Generally, the stubs
+will present access to the OMG IDL-defined operations on an object in a way that is easy
+for programmers to predict once they are familiar with OMG IDL and the language mapping
+for the particular programming language. The stubs make calls on the rest of the ORB
+using interfaces that are private to, and presumably optimized for, the particular ORB Core.
+If more than one ORB is available, there may be different stubs corresponding to the different ORBs.
+In this case, it is necessary for the ORB and language mapping to cooperate to associate
+the correct stubs with the particular object reference.
<P>Object-oriented programming languages, such as Java, C++, and Smalltalk, do not require stub interfaces.
-<P><P><BR><BR>
-
-
+<BR><BR>
</body>
</html>
--- a/corba/src/java.corba/share/classes/org/omg/CORBA/package.html Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/CORBA/package.html Tue Apr 14 12:10:00 2015 -0700
@@ -6,7 +6,7 @@
<TITLE>package</TITLE>
<!--
/*
-* Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -73,7 +73,6 @@
<TT>ORB</TT> Methods</H3>
<P>Before an application can enter the CORBA environment, it must first:
-<P>
<UL>
<LI>Be initialized into the ORB and possibly the object adapter (POA) environments.
<LI>Get references to ORB object (for use in future ORB operations)
@@ -81,7 +80,6 @@
</UL>
<P>The following operations are provided to initialize applications and obtain
the appropriate object references:
- <P>
<UL>
<LI>Operations providing access to the ORB, which are discussed in this
section.
@@ -107,13 +105,13 @@
that provide access to the ORB:
<UL>
<LI>
-<TT><bold>init</bold>()</TT>
+<TT><b>init</b>()</TT>
<LI>
-<TT><bold>init</bold>(String [] args, Properties props)</TT>
+<TT><b>init</b>(String [] args, Properties props)</TT>
<LI>
-<TT><bold>init</bold>(Applet app, Properties props)</TT>
+<TT><b>init</b>(Applet app, Properties props)</TT>
</UL>
<P>Using the <tt>init()</tt> method without parameters initiates
@@ -142,11 +140,11 @@
resolve initial object references. These are:
<UL>
<LI>
-<TT><bold>resolve_initial_references</bold>(String name)</TT>
+<TT><b>resolve_initial_references</b>(String name)</TT>
<LI>
-<TT><bold>list_initial_services</bold>()</TT>
+<TT><b>list_initial_services</b>()</TT>
<LI>
-<TT><bold>register_initial_reference</bold>(String id,
+<TT><b>register_initial_reference</b>(String id,
org.omg.CORBA.Object obj)</TT>
</UL>
@@ -278,7 +276,6 @@
<P>Each holder class has:
-<P>
<UL>
<LI>a constructor from an instance
<LI>a default constructor
@@ -291,7 +288,6 @@
<P>The default constructor sets the value field to the default value for the
type as defined by the Java language:
-<P>
<UL>
<LI><tt>false</tt> for boolean
<LI><tt>0</tt> for numeric and char types
@@ -391,7 +387,6 @@
<h2>Helper Classes </h2>
<P>Helper files supply several static methods needed to manipulate the type.
These include:
- <P>
<UL>
<LI><tt>Any</tt> insert and extract operations for the type
<LI>getting the repository id
@@ -455,14 +450,13 @@
<P>The <A HREF="{@docRoot}/../technotes/guides/idl/jidlExample.html"><em>Hello World</em></A>
tutorial uses a <tt>narrow</tt> method that looks
like this:
-<P>
<PRE>
// create and initialize the ORB
- ORB orb = ORB.init(args, null);
+ ORB orb = ORB.init(args, null);
// get the root naming context
org.omg.CORBA.Object objRef =
- orb.resolve_initial_references("NameService");
+ orb.resolve_initial_references("NameService");
// Use NamingContextExt instead of NamingContext. This is
// part of latest Inter-Operable naming Service.
NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
@@ -554,7 +548,6 @@
}
</PRE>
-<P>
<h3>Value Type Helper Classes</h3>
A helper class for a value type includes different renderings of
@@ -844,7 +837,7 @@
interfaces have been included for the purpose of creating typecodes (see
create_value_tc, create_struct_tc, create_union_tc and create_exception_tc
methods in interface org.omg.CORBA.ORB):
-<BR>&nbs
+<BR>
<UL>
<LI>
IRObject
@@ -893,20 +886,19 @@
<P>Some of the API included in <TT>org.omg</TT> subpackages throw
<tt>NO_IMPLEMENT</tt> exceptions for various reasons. Among these reasons
are:
-<P>
- <UL>
- <LI>In some cases, for example <tt>LocalObject</tt>, the complete
- implementation according to the specification indicates that
- these API should throw <tt>NO_IMPLEMENT</tt>.
- <P>
- <LI>In most cases, for example methods in <tt>ORB.java</tt>,
- methods that throw
- <tt>NO_IMPLEMENT</tt> are actually implemented in subclasses
- elsewhere in the ORB code.
- <P>
- <LI>In some cases, for example <tt>_get_interface_def()</tt>
- and <tt>_get_interface</tt>, API are really not yet implemented.
- </UL>
+ <UL>
+ <LI>In some cases, for example <tt>LocalObject</tt>, the complete
+ implementation according to the specification indicates that
+ these API should throw <tt>NO_IMPLEMENT</tt>.
+
+ <LI>In most cases, for example methods in <tt>ORB.java</tt>,
+ methods that throw
+ <tt>NO_IMPLEMENT</tt> are actually implemented in subclasses
+ elsewhere in the ORB code.
+
+ <LI>In some cases, for example <tt>_get_interface_def()</tt>
+ and <tt>_get_interface</tt>, API are really not yet implemented.
+ </UL>
--- a/corba/src/java.corba/share/classes/org/omg/CORBA/portable/InvokeHandler.java Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/CORBA/portable/InvokeHandler.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -56,7 +56,7 @@
* <p>5. Marshal reply into OutputStream returned by
* ResponseHandler.
* <p>6. Return OutputStream to ORB.
- * <p>
+ *
* @param method The method name.
* @param input The <code>InputStream</code> containing the marshalled arguments.
* @param handler The <code>ResponseHandler</code> which the servant uses
--- a/corba/src/java.corba/share/classes/org/omg/CORBA/portable/package.html Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/CORBA/portable/package.html Tue Apr 14 12:10:00 2015 -0700
@@ -2,7 +2,7 @@
<html>
<head>
<!--
-Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
+Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
@@ -46,57 +46,51 @@
can override them to provide real implementations. The ORB included in
Sun's release of the Java[tm] Platform, Standard Edition 6, includes
implementations for the following methods.
-<p>
+
<h2>List of Unimplemented Features in Package
<code>org.omg.CORBA.portable</code></h2>
-<p>
+
<h3>Unimplemented Interfaces in package <code>org.omg.CORBA.portable</code></h3>
<ul>
-<code>
- <li>InvokeHandler
- <li>ResponseHandler
-</code>
+ <li><code>InvokeHandler</code>
+ <li><code>ResponseHandler</code>
</ul>
-<p>
+
<h3>Unimplemented Methods in package <code>org.omg.CORBA.portable</code></h3>
<ul>
-<code>
-<li>InputStream
+<li><code>InputStream</code>
<ul>
- <li>public int read()
- <li>public.math.BigDecimal read_fixed()
- <li>public org.omg.CORBA.Context read_Context()
- <li>public org.omg.CORBA.Object read_Object(java.lang.Class clz)
- <li>public org.omg.CORBA.ORB orb()
- </ul>
-<li>OutputStream
- <ul>
- <li>public org.omg.CORBA.ORB orb()
- <li>public void write_Context(org.omg.CORBA.Context ctx,
- org.omg.CORBA.ContextList contexts)
- <li>public void write_fixed(java.math.BigDecimal value)
- <li>public void write(int b)
+ <li><code>public int read()</code>
+ <li><code>public.math.BigDecimal read_fixed()</code>
+ <li><code>public org.omg.CORBA.Context read_Context()</code>
+ <li><code>public org.omg.CORBA.Object read_Object(java.lang.Class clz)</code>
+ <li><code>public org.omg.CORBA.ORB orb()</code>
</ul>
-<li>Delegate
+<li><code>OutputStream</code>
<ul>
- <li>public void releaseReply(org.omg.CORBA.Object self, InputStream input)
- <li>public InputStream invoke(org.omg.CORBA.Object self, OutputStream output)
- <li>public OutputStream request(org.omg.CORBA.Object self, String operation,
- boolean responseExpected)
- <li>public org.omg.CORBA.Object set_policy_override(org.omg.CORBA.Object self,
+ <li><code>public org.omg.CORBA.ORB orb()</code>
+ <li><code>public void write_Context(org.omg.CORBA.Context ctx,
+ org.omg.CORBA.ContextList contexts)</code>
+ <li><code>public void write_fixed(java.math.BigDecimal value)</code>
+ <li><code>public void write(int b)</code>
+ </ul>
+<li><code>Delegate</code>
+ <ul>
+ <li><code>public void releaseReply(org.omg.CORBA.Object self, InputStream input)</code>
+ <li><code>public InputStream invoke(org.omgl.CORBA.Object self, OutputStream output)</code>
+ <li><code>public OutputStream request(org.omg.CORBA.Object self, String operation,
+ boolean responseExpected)</code>
+ <li><code>public org.omg.CORBA.Object set_policy_override(org.omg.CORBA.Object self,
org.omg.CORBA.Policy[] policies,
- org.omg.CORBA.SetOverrideType set_add)
- <li>public org.omg.CORBA.DomainManager[] get_domain_managers(
- org.omg.CORBA.Object
- self)
- <li>public org.omg.CORBA.Policy get_policy(org.omg.CORBA.Object self,
- int policy_type)
+ org.omg.CORBA.SetOverrideType set_add)</code>
+ <li><code>public org.omg.CORBA.DomainManager[] get_domain_managers(
+ org.omg.CORBA.Objectself)</code>
+ <li><code>public org.omg.CORBA.Policy get_policy(org.omg.CORBA.Object self,
+ int policy_type)</code>
</ul>
-</code>
</ul>
@since JDK1.2
@serial exclude
</body>
</html>
-
--- a/corba/src/java.corba/share/classes/org/omg/CORBA_2_3/package.html Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/CORBA_2_3/package.html Tue Apr 14 12:10:00 2015 -0700
@@ -6,7 +6,7 @@
<title>package</title>
<!--
/*
-* Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -43,23 +43,21 @@
<P>For a precise list of supported sections of official specifications with which
the Java[tm] Platform, Standard Edition 6, ORB complies, see <A
-HREF="../CORBA/doc-files/compliance.html">Official Specifications for CORBA
+HREF="../CORBA/doc-files/compliance.html">Official Specifications for CORBA
support in Java[tm] SE 6</A>.
<P>
<a name="unimpl"></a>
The following methods in the abstract class
<code>org.omg.CORBA_2_3.ORB</code> are unimplemented:
<UL>
- <code>
- <LI>public org.omg.CORBA.portable.ValueFactory
- <b>register_value_factory(String id, org.omg.CORBA.portable.ValueFactory
-factory)</b>
- <LI>public void <b>unregister_value_factory(String id)</b>
- <LI>public org.omg.CORBA.portable.ValueFactory
- <b>lookup_value_factory(String id)</b>
- <LI>public org.omg.CORBA.Object <b>get_value_def(String repid)</b>
- <LI>public void <b>set_delegate(java.lang.Object wrapper)</b>
- </code>
+ <LI><code>public org.omg.CORBA.portable.ValueFactory
+ <b>register_value_factory(String id, org.omg.CORBA.portable.ValueFactory
+ factory)</b></code>
+ <LI><code>public void <b>unregister_value_factory(String id)</b></code>
+ <LI><code>public org.omg.CORBA.portable.ValueFactory
+ <b>lookup_value_factory(String id)</b></code>
+ <LI><code>public org.omg.CORBA.Object <b>get_value_def(String repid)</b></code>
+ <LI><code>public void <b>set_delegate(java.lang.Object wrapper)</b></code>
</UL>
@since JDK 1.3
<br>
--- a/corba/src/java.corba/share/classes/org/omg/CORBA_2_3/portable/InputStream.java Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/CORBA_2_3/portable/InputStream.java Tue Apr 14 12:10:00 2015 -0700
@@ -77,7 +77,7 @@
*
* throw SecurityException if SecurityManager is installed and
* enableSubclassImplementation SerializablePermission
- * is not granted or jdk.corba.allowOutputStreamSubclass system
+ * is not granted or jdk.corba.allowInputStreamSubclass system
* property is either not set or is set to 'false'
*/
public InputStream() {
--- a/corba/src/java.corba/share/classes/org/omg/CORBA_2_3/portable/package.html Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/CORBA_2_3/portable/package.html Tue Apr 14 12:10:00 2015 -0700
@@ -3,7 +3,7 @@
<head>
<!--
/*
-* Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,6 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-
-->
</head>
@@ -34,7 +33,7 @@
Provides methods for the input and output of value types, and contains
other updates to the <code>org/omg/CORBA/portable</code> package.
-<p>
+
@since 1.3
@serial exclude
</body>
--- a/corba/src/java.corba/share/classes/org/omg/CosNaming/NamingContextExtPackage/package.html Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/CosNaming/NamingContextExtPackage/package.html Tue Apr 14 12:10:00 2015 -0700
@@ -3,7 +3,7 @@
<head>
<!--
/*
-* Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,21 +32,20 @@
<body bgcolor="white">
<P>This package contains the following classes, which are used in
<tt>org.omg.CosNaming.NamingContextExt</tt>:
-<P>
<UL>
-<LI><tt>AddressHelper</tt>
+ <LI><tt>AddressHelper</tt>
<LI><tt>StringNameHelper</tt>
<LI><tt>URLStringHelper</tt>
<LI><tt>InvalidAddress</tt>
-
+</UL>
<H3>Package Specification</H3>
-
+
<P>For a precise list of supported sections of official specifications with which
the Java[tm] Platform, Standard Edition 6 ORB complies, see <A
HREF="../../CORBA/doc-files/compliance.html">Official Specifications for CORBA
support in Java[tm] SE 6</A>.
-<p>
+
@since 1.4
<br>
@serial exclude
--- a/corba/src/java.corba/share/classes/org/omg/CosNaming/NamingContextPackage/package.html Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/CosNaming/NamingContextPackage/package.html Tue Apr 14 12:10:00 2015 -0700
@@ -3,7 +3,7 @@
<head>
<!--
/*
-* Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,6 @@
<body bgcolor="white">
<P>This package contains Exception classes for the <tt>org.omg.CosNaming</tt>
package. The list of exception classes are:
- <P>
<UL>
<LI><tt>AlreadyBound</tt>
<LI><tt>CannotProceed</tt>
@@ -40,6 +39,7 @@
<LI><tt>NotEmpty</tt>
<LI><tt>NotFound</tt>
<LI><tt>NotFoundReason</tt>
+ </UL>
<H3>Package Specification</H3>
@@ -48,7 +48,7 @@
the Java[tm] Platform, Standard Edition 6 ORB complies, see <A
HREF="../../CORBA/doc-files/compliance.html">Official Specifications for CORBA
support in Java SE 6</A>.
-<p>
+
@since 1.4
<br>
@serial exclude
--- a/corba/src/java.corba/share/classes/org/omg/CosNaming/nameservice.idl Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/CosNaming/nameservice.idl Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -64,12 +64,12 @@
Istring id;
Istring kind;
};
-
+
/**
* A name is a sequence of name components.
*/
typedef sequence <NameComponent> Name;
-
+
/**
* Specifies whether the given binding is for a object (that is not a
* naming context) or for a naming context.
@@ -79,7 +79,7 @@
nobject, // name is bound to an object
ncontext // name is bound to a naming context
};
-
+
/**
* A name-to-object association is called a Binding.
*/
@@ -89,12 +89,12 @@
BindingType binding_type; // whether name is bound to an object
// or a naming context
};
-
+
/**
* List of Bindings.
*/
- typedef sequence <Binding> BindingList;
-
+ typedef sequence <Binding> BindingList;
+
/**
* The BindingIterator interface allows a client to iterate through
* the bindings using the next_one or next_n operations.
@@ -112,24 +112,24 @@
* @param b the returned binding
*/
boolean next_one(out Binding b);
-
+
/**
* This operation returns at most the requested number of bindings.
*
- * @param how_many the maximum number of bindings tro return <p>
+ * @param how_many the maximum number of bindings to return
*
* @param bl the returned bindings
*/
boolean next_n(in unsigned long how_many,
- out BindingList bl);
-
+ out BindingList bl);
+
// Destroy binding iterator
/**
* This operation destroys the iterator.
*/
void destroy();
};
-
+
/**
* A naming context is an object that contains a set of name bindings in
* which each name is unique. Different names can be bound to an object
@@ -151,7 +151,7 @@
not_context,
not_object
};
-
+
/**
* Indicates the name does not identify a binding.
*/
@@ -160,7 +160,7 @@
NotFoundReason why;
Name rest_of_name;
};
-
+
/**
* Indicates that the implementation has given up for some reason.
* The client, however, may be able to continue the operation at the
@@ -171,130 +171,130 @@
NamingContext cxt;
Name rest_of_name;
};
-
+
/**
* Indicates the name is invalid.
*/
exception InvalidName
- {};
-
+ {};
+
/**
* Indicates an object is already bound to the specified name. Only
* one object can be bound to a particular name in a context.
*/
exception AlreadyBound
{};
-
+
/**
* Indicates that the Naming Context contains bindings.
*/
exception NotEmpty
{};
-
+
/**
* Creates a binding of a name and an object in the naming context.
* Naming contexts that are bound using bind do not participate in name
* resolution when compound names are passed to be resolved.
*
- * @param n Name of the object <p>
+ * @param n Name of the object.
*
- * @param obj The Object to bind with the given name<p>
+ * @param obj The Object to bind with the given name.
*
* @exception org.omg.CosNaming.NamingContextPackage.NotFound Indicates
- * the name does not identify a binding.<p>
+ * the name does not identify a binding.
*
* @exception org.omg.CosNaming.NamingContextPackage.CannotProceed
* Indicates that the implementation has given up for some reason.
* The client, however, may be able to continue the operation
- * at the returned naming context.<p>
+ * at the returned naming context.
*
* @exception org.omg.CosNaming.NamingContextPackage.InvalidName
- * Indicates that the name is invalid. <p>
+ * Indicates that the name is invalid.
*
* @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound
- * Indicates an object is already bound to the specified name.<p>
+ * Indicates an object is already bound to the specified name.
*/
void bind(in Name n,
- in Object obj)
+ in Object obj)
raises(NotFound,
- CannotProceed,
- InvalidName,
- AlreadyBound);
-
+ CannotProceed,
+ InvalidName,
+ AlreadyBound);
+
/**
* Names an object that is a naming context. Naming contexts that
* are bound using bind_context() participate in name resolution
* when compound names are passed to be resolved.
*
- * @param n Name of the object <p>
+ * @param n Name of the object.
*
- * @param nc NamingContect object to bind with the given name <p>
+ * @param nc NamingContect object to bind with the given name.
*
- * @exception org.omg.CosNaming.NamingContextPackage.NotFound Indicates the name does not identify a binding.<p>
+ * @exception org.omg.CosNaming.NamingContextPackage.NotFound Indicates the name does not identify a binding.
*
* @exception org.omg.CosNaming.NamingContextPackage.CannotProceed Indicates that the implementation has
* given up for some reason. The client, however, may be able to
- * continue the operation at the returned naming context.<p>
+ * continue the operation at the returned naming context.
*
- * @exception org.omg.CosNaming.NamingContextPackage.InvalidName Indicates that the name is invalid. <p>
+ * @exception org.omg.CosNaming.NamingContextPackage.InvalidName Indicates that the name is invalid.
*
* @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound Indicates an object is already
- * bound to the specified name.<p>
+ * bound to the specified name.
*/
void bind_context(in Name n,
- in NamingContext nc)
+ in NamingContext nc)
raises(NotFound,
- CannotProceed,
- InvalidName,
- AlreadyBound);
-
+ CannotProceed,
+ InvalidName,
+ AlreadyBound);
+
/**
* Creates a binding of a name and an object in the naming context
* even if the name is already bound in the context. Naming contexts
* that are bound using rebind do not participate in name resolution
* when compound names are passed to be resolved.
*
- * @param n Name of the object <p>
+ * @param n Name of the object.
*
- * @param obj The Object to rebind with the given name <p>
+ * @param obj The Object to rebind with the given name.
*
- * @exception org.omg.CosNaming.NamingContextPackage.NotFound Indicates the name does not identify a binding.<p>
+ * @exception org.omg.CosNaming.NamingContextPackage.NotFound Indicates the name does not identify a binding.
*
* @exception org.omg.CosNaming.NamingContextPackage.CannotProceed Indicates that the implementation has
* given up for some reason. The client, however, may be able to
- * continue the operation at the returned naming context.<p>
+ * continue the operation at the returned naming context.
*
- * @exception org.omg.CosNaming.NamingContextPackage.InvalidName Indicates that the name is invalid. <p>
+ * @exception org.omg.CosNaming.NamingContextPackage.InvalidName Indicates that the name is invalid.
*/
void rebind(in Name n,
- in Object obj)
+ in Object obj)
raises(NotFound,
- CannotProceed,
- InvalidName);
-
+ CannotProceed,
+ InvalidName);
+
/**
* Creates a binding of a name and a naming context in the naming
* context even if the name is already bound in the context. Naming
* contexts that are bound using rebind_context() participate in name
* resolution when compound names are passed to be resolved.
*
- * @param n Name of the object <p>
+ * @param n Name of the object.
*
- * @param nc NamingContect object to rebind with the given name <p>
+ * @param nc NamingContect object to rebind with the given name.
*
- * @exception org.omg.CosNaming.NamingContextPackage.NotFound Indicates the name does not identify a binding.<p>
+ * @exception org.omg.CosNaming.NamingContextPackage.NotFound Indicates the name does not identify a binding.
*
* @exception org.omg.CosNaming.NamingContextPackage.CannotProceed Indicates that the implementation has
* given up for some reason. The client, however, may be able to
- * continue the operation at the returned naming context.<p>
+ * continue the operation at the returned naming context.
*
- * @exception org.omg.CosNaming.NamingContextPackage.InvalidName Indicates that the name is invalid. <p>
+ * @exception org.omg.CosNaming.NamingContextPackage.InvalidName Indicates that the name is invalid.
*/
void rebind_context(in Name n,
- in NamingContext nc)
+ in NamingContext nc)
raises(NotFound,
- CannotProceed,
- InvalidName);
+ CannotProceed,
+ InvalidName);
/**
* The resolve operation is the process of retrieving an object
@@ -304,39 +304,39 @@
* to the appropriate type. That is, clients typically cast the returned
* object from Object to a more specialized interface.
*
- * @param n Name of the object <p>
+ * @param n Name of the object.
*
- * @exception org.omg.CosNaming.NamingContextPackage.NotFound Indicates the name does not identify a binding.<p>
+ * @exception org.omg.CosNaming.NamingContextPackage.NotFound Indicates the name does not identify a binding.
*
* @exception org.omg.CosNaming.NamingContextPackage.CannotProceed Indicates that the implementation has
* given up for some reason. The client, however, may be able to
- * continue the operation at the returned naming context.<p>
+ * continue the operation at the returned naming context.
*
- * @exception org.omg.CosNaming.NamingContextPackage.InvalidName Indicates that the name is invalid. <p>
+ * @exception org.omg.CosNaming.NamingContextPackage.InvalidName Indicates that the name is invalid.
*/
Object resolve(in Name n)
raises(NotFound,
- CannotProceed,
- InvalidName);
-
+ CannotProceed,
+ InvalidName);
+
/**
* The unbind operation removes a name binding from a context.
*
- * @param n Name of the object <p>
+ * @param n Name of the object.
*
- * @exception org.omg.CosNaming.NamingContextPackage.NotFound Indicates the name does not identify a binding.<p>
+ * @exception org.omg.CosNaming.NamingContextPackage.NotFound Indicates the name does not identify a binding.
*
* @exception org.omg.CosNaming.NamingContextPackage.CannotProceed Indicates that the implementation has
* given up for some reason. The client, however, may be able to
- * continue the operation at the returned naming context.<p>
+ * continue the operation at the returned naming context.
*
- * @exception org.omg.CosNaming.NamingContextPackage.InvalidName Indicates that the name is invalid. <p>
+ * @exception org.omg.CosNaming.NamingContextPackage.InvalidName Indicates that the name is invalid.
*/
void unbind(in Name n)
raises(NotFound,
- CannotProceed,
- InvalidName);
-
+ CannotProceed,
+ InvalidName);
+
/**
* The list operation allows a client to iterate through a set of
* bindings in a naming context. <p>
@@ -351,15 +351,15 @@
* bindings, the binding iterator is a nil object reference.
* </ul>
*
- * @param how_many the maximum number of bindings to return <p>
+ * @param how_many the maximum number of bindings to return.
*
- * @param bl the returned list of bindings <p>
+ * @param bl the returned list of bindings.
*
- * @param bi the returned binding iterator <p>
+ * @param bi the returned binding iterator.
*/
void list(in unsigned long how_many,
- out BindingList bl,
- out BindingIterator bi);
+ out BindingList bl,
+ out BindingIterator bi);
/**
* This operation returns a naming context implemented by the same
@@ -367,7 +367,7 @@
* The new context is not bound to any name.
*/
NamingContext new_context();
-
+
/**
* This operation creates a new context and binds it to the name
* supplied as an argument. The newly-created context is implemented
@@ -375,25 +375,25 @@
* is, the naming server that implements the context denoted by the
* name argument excluding the last component).
*
- * @param n Name of the object <p>
+ * @param n Name of the object.
*
- * @exception org.omg.CosNaming.NamingContextPackage.NotFound Indicates the name does not identify a binding.<p>
+ * @exception org.omg.CosNaming.NamingContextPackage.NotFound Indicates the name does not identify a binding.
*
* @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound Indicates an object is already
- * bound to the specified name.<p>
+ * bound to the specified name.
*
* @exception org.omg.CosNaming.NamingContextPackage.CannotProceed Indicates that the implementation has
* given up for some reason. The client, however, may be able to
- * continue the operation at the returned naming context.<p>
+ * continue the operation at the returned naming context.
*
- * @exception org.omg.CosNaming.NamingContextPackage.InvalidName Indicates that the name is invalid. <p>
+ * @exception org.omg.CosNaming.NamingContextPackage.InvalidName Indicates that the name is invalid.
*/
NamingContext bind_new_context(in Name n)
raises(NotFound,
- AlreadyBound,
- CannotProceed,
- InvalidName);
-
+ AlreadyBound,
+ CannotProceed,
+ InvalidName);
+
/**
* The destroy operation deletes a naming context. If the naming
* context contains bindings, the NotEmpty exception is raised.
@@ -402,7 +402,7 @@
*/
void destroy()
raises(NotEmpty);
-
+
};
@@ -413,7 +413,7 @@
* part of Interoperable Naming Service.
* Different names can be bound to an object in the same or different
* contexts at the same time. Using <tt>NamingContextExt</tt>, you can use
- * URL-based names to bind and resolve. <p>
+ * URL-based names to bind and resolve.
*
* See <a href="http://www.omg.org/technology/documents/formal/naming_service.htm">
* CORBA COS
@@ -425,86 +425,84 @@
* StringName is the Stringified Name, Array of Name Components
* represented as a String.
*/
- typedef string StringName;
+ typedef string StringName;
/**
* Address is the Host and Port information represented as a String.
*/
- typedef string Address;
-
+ typedef string Address;
+
/**
* URLString is the URL address (corbaloc: or corbaname:) represented as
* a String.
*/
- typedef string URLString;
+ typedef string URLString;
/**
* This operation creates a stringified name from the array of Name
* components.
*
- * @param n Name of the object <p>
+ * @param n Name of the object.
*
* @exception org.omg.CosNaming.NamingContextExtPackage.InvalidName
- * Indicates the name does not identify a binding.<p>
+ * Indicates the name does not identify a binding.
*
*/
- StringName to_string( in Name n ) raises (InvalidName);
+ StringName to_string( in Name n ) raises (InvalidName);
/**
* This operation converts a Stringified Name into an equivalent array
- * of Name Components.
+ * of Name Components.
*
- * @param sn Stringified Name of the object <p>
+ * @param sn Stringified Name of the object.
*
* @exception org.omg.CosNaming.NamingContextExtPackage.InvalidName
- * Indicates the name does not identify a binding.<p>
+ * Indicates the name does not identify a binding.
*
*/
- Name to_name( in StringName sn ) raises (InvalidName);
+ Name to_name( in StringName sn ) raises (InvalidName);
/**
* Indicates the invalid Stringified name for the object, The
* reason could be invalid syntax.
*/
- exception InvalidAddress
- { };
+ exception InvalidAddress
+ { };
/**
* This operation creates a URL based "iiopname://" format name
* from the Stringified Name of the object.
*
- * @param addr internet based address of the host machine where Name Service is running <p>
- * @param sn Stringified Name of the object <p>
+ * @param addr internet based address of the host machine where Name Service is running.
+ * @param sn Stringified Name of the object.
*
* @exception org.omg.CosNaming.NamingContextExtPackage.InvalidName
- * Indicates the name does not identify a binding.<p>
+ * Indicates the name does not identify a binding.
* @exception org.omg.CosNaming.NamingContextPackage.InvalidAddress
- * Indicates the internet based address of the host machine is
- * incorrect <p>
- *
- */
- URLString to_url( in Address addr, in StringName sn )
- raises( InvalidAddress, InvalidName );
+ * Indicates the internet based address of the host machine is incorrect
+ */
+ URLString to_url( in Address addr, in StringName sn )
+ raises( InvalidAddress, InvalidName );
/**
* This operation resolves the Stringified name into the object
* reference.
*
- * @param sn Stringified Name of the object <p>
+ * @param sn Stringified Name of the object.
*
* @exception org.omg.CosNaming.NamingContextPackage.NotFound
- * Indicates there is no object reference for the given name. <p>
+ * Indicates there is no object reference for the given name.
* @exception org.omg.CosNaming.NamingContextPackage.CannotProceed
- * Indicates that the given compound name is incorrect <p>
+ * Indicates that the given compound name is incorrect.
* @exception org.omg.CosNaming.NamingContextExtPackage.InvalidName
- * Indicates the name does not identify a binding.<p>
+ * Indicates the name does not identify a binding.
*
*/
- Object resolve_str( in StringName sn)
- raises( NotFound, CannotProceed,
- InvalidName);
+ Object resolve_str( in StringName sn)
+ raises( NotFound, CannotProceed,
+ InvalidName);
};
--- a/corba/src/java.corba/share/classes/org/omg/CosNaming/package.html Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/CosNaming/package.html Tue Apr 14 12:10:00 2015 -0700
@@ -3,7 +3,7 @@
<head>
<!--
/*
-* Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,20 +32,20 @@
Provides a naming service for Java IDL. The Object Request Broker Daemon
(ORBD) also includes both a transient and persistent naming service.
-
+
<P>
The package and all its classes and interfaces
were generated by running the tool <code>idlj</code> on the file
<code>nameservice.idl</code>, which is a module written in OMG IDL.
-
+
<H3>Package Specification</H3>
-
+
<P>For a precise list of supported sections of official specifications with which
the Java[tm] Platform, Standard Edition 6, ORB complies, see <A
HREF="../CORBA/doc-files/compliance.html">Official Specifications for CORBA
support in Java[tm] SE 6</A>.
- <P>
+
<H2>Interfaces</H2>
The package <tt>org.omg.CosNaming</tt> contains two public interfaces
and several auxiliary classes.
@@ -62,7 +62,7 @@
interface supplies the main functionality for the naming service, and
<code>BindingIterator</code> provides a means of iterating through a list
of name/object reference bindings.
- <P>
+
<H2>Auxiliary Classes</H2>
In order to map an OMG IDL interface to the Java programming language,
the idlj compiler creates Java classes that can be thought of
@@ -70,13 +70,13 @@
Comments for the generated auxiliary classes
used by the interfaces <code>NamingContext</code> and
<code>BindingIterator</code> are included here.
- <P>
+
<H3>Classes Used by <code>NamingContext</code> and
<code>BindingIterator</code></H3>
The following are classes used by
the naming service. (Helper and holder classes, which are
generated for each of the classes listed here, are discussed below.)
-
+
<UL>
<LI><code>public final class <B>NameComponent</B></code> --
a building block for names. (Names are bound to object references
@@ -89,8 +89,7 @@
A <code><B>NameComponent</B></code> object consists of two fields:
<OL>
<LI><code><B>id</B></code> -- a <code>String</code> used as an identifier
- <LI><code><B>kind</B></code> -- a <code>String</code> that can be used for
-any
+ <LI><code><B>kind</B></code> -- a <code>String</code> that can be used for any
descriptive purpose. Its importance is that it
can be used to describe an object without affecting syntax.
The C programming language, for example, uses the the syntactic convention
@@ -102,16 +101,15 @@
<code>"c_source"</code>, <code>"object_code"</code>,
<code>"executable"</code>,
<code>"postscript"</code>, and <code>""</code>. It is not unusual
- for the <code>kind</code> field to be the empty string.
+ for the <code>kind</code> field to be the empty string.
</OL>
<P>
In a name, each <code>NameComponent</code> object except the last denotes
a <code>NamingContext</code> object; the last <code>NameComponent</code>
object denotes the bound object reference.
This is similar to a path name, in which the last name is the
- file name, and all names before it are directory names.<p>
- <P>
-
+ file name, and all names before it are directory names.
+
<LI><code>public final class <B>Binding</B></code> --
an object that associates a name with an object reference or a
naming context.
@@ -125,45 +123,44 @@
</OL>
<P>
The interface <code>NamingContext</code> has methods for
- binding/unbinding names with object references or naming contexts,
- for listing bindings,
+ binding/unbinding names with object references or naming contexts,
+ for listing bindings,
and for resolving bindings (given a name, the method
<code>resolve</code> returns the object reference bound to it).
-
- <P>
- <LI><code>public final class <B>BindingType</B></code> --
+
+ <LI><code>public final class <B>BindingType</B></code> --
an object that specifies whether the given <code>Binding</code>
object is a binding between a name and an object reference (that is,
not a naming context) or between a name and a naming context.
<P>
The class<code>BindingType</code> consists of two methods and
- four constants. Two of these constants are
- <code>BindingType</code> objects, and two are <code>int</code>s.
- <P>
- The <code>BindingType</code> objects
+ four constants. Two of these constants are
+ <code>BindingType</code> objects, and two are <code>int</code>s.
+ <P>
+ The <code>BindingType</code> objects
can be passed to the constructor for the class
<code>Binding</code> or used as parameters or return values. These
- <code>BindingType</code> objects are:
+ <code>BindingType</code> objects are:
<UL>
<LI><code>public static final BindingType <B>nobject</B></code> --
- to indicate that the binding is with an object reference
+ to indicate that the binding is with an object reference
<LI><code>public static final BindingType <B>ncontext</B></code> --
- to indicate that the binding is with a naming context
+ to indicate that the binding is with a naming context
</UL>
<P>
- The <code>int</code> constants can be supplied to the method
- <code>from_int</code> to create <code>BindingType</code> objects,
- or they can be return values for the method <code>value</code>.
- These constants are:
- <UL>
+ The <code>int</code> constants can be supplied to the method
+ <code>from_int</code> to create <code>BindingType</code> objects,
+ or they can be return values for the method <code>value</code>.
+ These constants are:
+ <UL>
<LI><code>public static final int <B>_nobject</B></code>
<LI><code>public static final int <B>_ncontext</B></code>
- </UL>
+ </UL>
If the method <code>from_int</code> is supplied with anything other
- than <code>_nobject</code>
+ than <code>_nobject</code>
or <code>_ncontext</code>, it will throw
- the exception <code>org.omg.CORBA.BAD_PARAM</code>.
- <P>Usage is as follows:
+ the exception <code>org.omg.CORBA.BAD_PARAM</code>.
+ <P>Usage is as follows:
<PRE>
BindingType btObject = from_int(_nobject);
BindingType btContext = from_int(_ncontext);
@@ -182,9 +179,9 @@
int bt = BindingType.value();
</PRE>
</UL>
-
+
<H3>Holder Classes</H3>
-
+
OMG IDL uses OUT and INOUT parameters for returning values from operations.
The mapping to the Java programming language, which does not have OUT
and INOUT parameters, creates a special class for each type, called
@@ -308,7 +305,6 @@
This associates <code>NameService</code> with the Root Naming
Context of the <code>CosNaming</code> implementation that you
want to use.
- <P>
<LI>Start the standalone Bootstrap server using the following command:
<pre>
<code>
@@ -340,13 +336,13 @@
<code>CosNaming</code> API, please see:
<ul>
<li><a href="../../../../technotes/guides/idl/tnameserv.html">
- Naming Service</a>
+ Naming Service</a>
</ul>
<p>
For an overview of Java IDL, please see:
<ul>
<li><a href="../../../../technotes/guides/idl/index.html">
- Java IDL home page</a>
+ Java IDL home page</a>
</ul>
@since JDK1.3
--- a/corba/src/java.corba/share/classes/org/omg/Dynamic/package.html Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/Dynamic/package.html Tue Apr 14 12:10:00 2015 -0700
@@ -3,7 +3,7 @@
<head>
<!--
/*
-* Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -45,7 +45,7 @@
the Java[tm] Platform, Standard Edition 6 ORB complies, see <A
HREF="../CORBA/doc-files/compliance.html">Official Specifications for CORBA
support in Java[tm] SE 6</A>.
-<p>
+
@since 1.4
<br>
@serial exclude
--- a/corba/src/java.corba/share/classes/org/omg/DynamicAny/DynAnyFactoryPackage/package.html Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/DynamicAny/DynAnyFactoryPackage/package.html Tue Apr 14 12:10:00 2015 -0700
@@ -3,7 +3,7 @@
<head>
<!--
/*
-* Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -48,7 +48,7 @@
the Java[tm] Platform, Standard Edition 6 ORB complies, see <A
HREF="../../CORBA/doc-files/compliance.html">Official Specifications for CORBA
support in Java SE 6</A>.
-<p>
+
@since 1.4
<br>
@serial exclude
--- a/corba/src/java.corba/share/classes/org/omg/DynamicAny/DynAnyPackage/package.html Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/DynamicAny/DynAnyPackage/package.html Tue Apr 14 12:10:00 2015 -0700
@@ -3,7 +3,7 @@
<head>
<!--
- Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
@@ -46,7 +46,7 @@
the Java[tm] Platform, Standard Edition 6 ORB complies, see <A
HREF="../../CORBA/doc-files/compliance.html">Official Specifications for CORBA
support in Java[tm] SE 6</A>.
-<p>
+
@since 1.4
<br>
@serial exclude
--- a/corba/src/java.corba/share/classes/org/omg/DynamicAny/package.html Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/DynamicAny/package.html Tue Apr 14 12:10:00 2015 -0700
@@ -3,7 +3,7 @@
<head>
<!--
- Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
@@ -197,22 +197,14 @@
interface may raise the standard NO_IMPLEMENT exception.
An attempt to use a <code>DynAny</code> object with the DII may raise the NO_IMPLEMENT
exception.
-
-
-
-
-
-
-<P>
-
<H3>Package Specification</H3>
-
+
<P>For a precise list of supported sections of official specifications with which
the Java[tm] Platform, Standard Edition 6 ORB complies, see <A
HREF="../CORBA/doc-files/compliance.html">Official Specifications for CORBA
support in Java[tm] SE 6</A>.
-<p>
+
@since 1.4
<br>
@serial exclude
--- a/corba/src/java.corba/share/classes/org/omg/IOP/CodecFactoryPackage/package.html Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/IOP/CodecFactoryPackage/package.html Tue Apr 14 12:10:00 2015 -0700
@@ -3,7 +3,7 @@
<head>
<!--
-Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved.
+Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
@@ -42,7 +42,7 @@
the Java[tm] Platform, Standard Edition 6 ORB complies, see <A
HREF="../../CORBA/doc-files/compliance.html">Official Specifications for CORBA
support in Java SE 6</A>.
-<p>
+
@since 1.4
<br>
@serial exclude
--- a/corba/src/java.corba/share/classes/org/omg/IOP/CodecPackage/package.html Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/IOP/CodecPackage/package.html Tue Apr 14 12:10:00 2015 -0700
@@ -3,7 +3,7 @@
<head>
<!--
-Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved.
+Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
@@ -45,7 +45,7 @@
the Java[tm] Platform, Standard Edition 6 ORB complies, see <A
HREF="../../CORBA/doc-files/compliance.html">Official Specifications for CORBA
support in Java[tm] SE 6</A>.
-<p>
+
@since 1.4
<br>
@serial exclude
--- a/corba/src/java.corba/share/classes/org/omg/IOP/package.html Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/IOP/package.html Tue Apr 14 12:10:00 2015 -0700
@@ -3,7 +3,7 @@
<head>
<!--
-Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved.
+Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
@@ -52,7 +52,7 @@
the Java[tm] Platform, Standard Edition 6 ORB complies, see <A
HREF="../CORBA/doc-files/compliance.html">Official Specifications for CORBA
support in Java[tm] SE 6</A>.
-<p>
+
@since 1.4
<br>
@serial exclude
--- a/corba/src/java.corba/share/classes/org/omg/Messaging/package.html Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/Messaging/package.html Tue Apr 14 12:10:00 2015 -0700
@@ -3,7 +3,7 @@
<head>
<!--
-Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved.
+Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
@@ -47,7 +47,7 @@
the Java[tm] Platform, Standard Edition 6 ORB complies, see <A
HREF="../CORBA/doc-files/compliance.html">Official Specifications for CORBA
support in Java[tm] SE 6</A>.
-<p>
+
@since 1.4
<br>
@serial exclude
--- a/corba/src/java.corba/share/classes/org/omg/PortableInterceptor/IOP.idl Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/PortableInterceptor/IOP.idl Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -258,14 +258,14 @@
* <p>
* The <code>TAG_ALTERNATE_IIOP_ADDRESS</code> component has an
* associated value of type:
- * <code>
- * <pre>
+ * <pre>
+ * <code>
* struct {
* string HostID,
* short Port
- * };
- * </pre>
- * </code>
+ * };
+ * </code>
+ * </pre>
* encoded as a CDR encapsulation.
* <p>
* Zero or more instances of the <code>TAG_ALTERNATE_IIOP_ADDRESS</code>
@@ -601,7 +601,7 @@
/**
* Create a <code>Codec</code> of the given encoding.
- * <p>
+ *
* @param enc The encoding for which to create a <code>Codec</code>.
* @return A <code>Codec</code> obtained with the given encoding.
* @exception UnknownEncoding thrown if this factory cannot create a
--- a/corba/src/java.corba/share/classes/org/omg/PortableInterceptor/Interceptors.idl Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/PortableInterceptor/Interceptors.idl Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -479,7 +479,7 @@
* On the client:
* <ul>
* <li>Within the <code>receive_reply</code> interception point, this
- * will only return <code>SUCCESSFUL</code></li>.
+ * will only return <code>SUCCESSFUL</code>.</li>
* <li>Within the <code>receive_exception</code> interception point,
* this will be either <code>SYSTEM_EXCEPTION</code> or
* <code>USER_EXCEPTION</code>.</li>
@@ -545,7 +545,7 @@
/**
* Returns a copy of the service context with the given ID that
* is associated with the request.
- * <p>
+ *
* @param id The <code>IOP.ServiceId</code> of the service context
* which is to be returned.
* @return The <code>IOP.ServiceContext</code> obtained with the
@@ -579,7 +579,6 @@
* validity of each attribute or operation. If it is not valid, attempting
* to access it will result in a <code>BAD_INV_ORDER</code> being thrown
* with a standard minor code of 14.
- * <p>
*
* <table border=1 summary="Shows the validity of each attribute or operation">
* <thead>
@@ -934,7 +933,6 @@
* of each attribute or operation. If it is not valid, attempting to access
* it will result in a <code>BAD_INV_ORDER</code> being thrown with a
* standard minor code of 14.
- * <p>
*
*
* <table border=1 summary="Shows the validity of each attribute or operation">
@@ -1028,7 +1026,7 @@
* <td>yes</td> <td>yes</td> <td>yes</td> <td>yes</td> <td>yes</td></tr>
*
* <tr><td><b>arguments</b></td>
- * <td>no </td> <td>yes<sub>1</sub</td>
+ * <td>no </td> <td>yes<sub>1</sub></td>
* <td>yes</td> <td>no<sub>2</sub></td>
* <td>no<sub>2</sub>
* </td></tr>
@@ -1133,7 +1131,7 @@
* servant, which may no longer be available to the ORB. For example,
* if the object's adapter is a POA that uses a
* <code>ServantLocator</code>, then the ORB invokes the interception
- * point after it calls <code>ServantLocator.postinvoke()</code></li>.
+ * point after it calls <code>ServantLocator.postinvoke()</code>.</li>
* </ol>
*
* @see ServerRequestInterceptor
@@ -1889,7 +1887,7 @@
* @param type An int specifying the type of policy being created.
* @param value An any containing data with which to construct the
* <code>CORBA.Policy</code>.
- * @return A <code>CORBA.Policy<code> object of the specified type and
+ * @return A <code>CORBA.Policy</code> object of the specified type and
* value.
*/
CORBA::Policy create_policy
@@ -2124,7 +2122,7 @@
* <p>
* A client-side logging service written by company X, for example, may
* have the following ORBInitializer implementation:
- * <code><pre>
+ * <pre><code>
* package com.x.logging;
*
* import org.omg.PortableInterceptor.Interceptor;
@@ -2144,7 +2142,7 @@
* // This service does not need two init points.
* }
* }
- * </pre></code>
+ * </code></pre>
* To run a program called <code>MyApp</code> using this logging
* service, the user could type:
* <blockquote><code>
--- a/corba/src/java.corba/share/classes/org/omg/PortableInterceptor/ORBInitInfoPackage/package.html Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/PortableInterceptor/ORBInitInfoPackage/package.html Tue Apr 14 12:10:00 2015 -0700
@@ -3,7 +3,7 @@
<head>
<!--
-Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved.
+Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
@@ -44,7 +44,7 @@
the Java[tm] Platform, Standard Edition 6 ORB complies, see <A
HREF="../../CORBA/doc-files/compliance.html">Official Specifications for CORBA
support in Java SE 6</A>.
-<p>
+
@since 1.4
<br>
@serial exclude
--- a/corba/src/java.corba/share/classes/org/omg/PortableInterceptor/package.html Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/PortableInterceptor/package.html Tue Apr 14 12:10:00 2015 -0700
@@ -3,7 +3,7 @@
<head>
<!--
-Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
+Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
@@ -56,41 +56,39 @@
<h2>Known limitations / unimplemented methods in package
<code>org.omg.PortableInterceptor</code></h2>
-<code>
<ul>
<li>
- <b>RequestInfo</b>
+ <code><b>RequestInfo</b></code>
<ul>
- <li><b>sync_scope()</b>: Always returns SYNC_WITH_TRANSPORT</li>
- <li><b>arguments()</b>: Only supported for DII/DSI calls</li>
- <li><b>exceptions()</b>: Only supported for DII calls on client side.
+ <li><code><b>sync_scope()</b></code>: Always returns SYNC_WITH_TRANSPORT</li>
+ <li><code><b>arguments()</b></code>: Only supported for DII/DSI calls</li>
+ <li><code><b>exceptions()</b></code>: Only supported for DII calls on client side.
Not supported on server-side.</li>
- <li><b>contexts()</b>: Only supported for DII calls on client side.
+ <li><code><b>contexts()</b></code>: Only supported for DII calls on client side.
Not supported on server-side since our ORB does not send contexts.
</li>
- <li><b>operation_context()</b>: Only supported for DII calls
+ <li><code><b>operation_context()</b></code>: Only supported for DII calls
on client side. Not supported on server-side since ORB
does not send contexts.</li>
- <li><b>result()</b>: Only supported for DII/DSI calls</li>
+ <li><code><b>result()</b></code>: Only supported for DII/DSI calls</li>
</ul>
</li>
<li>
- <b>ClientRequestInfo</b>
+ <code><b>ClientRequestInfo</b></code>
<ul>
- <li><b>received_exception_id()</b>: Always returns null in the
+ <li><code><b>received_exception_id()</b></code>: Always returns null in the
DII case</li>
- <li><b>get_request_policy(int type)</b>: Not implemented.</li>
+ <li><code><b>get_request_policy(int type)</b></code>: Not implemented.</li>
</ul>
</li>
<li>
- <b>ServerRequestInfo</b>
+ <code><b>ServerRequestInfo</b></code>
<ul>
- <li><b>sending_exception()</b>: Does not support user exceptions on
+ <li><code><b>sending_exception()</b></code>: Does not support user exceptions on
the server side in non-DSI case.</li>
</ul>
</li>
</ul>
-</code>
<h2>Package Specification</h2>
<P>For a precise list of supported sections of official OMG specifications with which
--- a/corba/src/java.corba/share/classes/org/omg/PortableServer/CurrentPackage/package.html Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/PortableServer/CurrentPackage/package.html Tue Apr 14 12:10:00 2015 -0700
@@ -3,7 +3,7 @@
<head>
<!--
- Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
@@ -53,7 +53,7 @@
the Java[tm] Platform, Standard Edition 6 ORB complies, see <A
HREF="../../CORBA/doc-files/compliance.html">Official Specifications for CORBA
support in Java[tm] SE 6</A>.
-<p>
+
@since 1.4
<br>
@serial exclude
--- a/corba/src/java.corba/share/classes/org/omg/PortableServer/POAManagerPackage/package.html Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/PortableServer/POAManagerPackage/package.html Tue Apr 14 12:10:00 2015 -0700
@@ -3,7 +3,7 @@
<head>
<!--
- Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
@@ -43,7 +43,7 @@
the Java[tm] Platform, Standard Edition 6 ORB complies, see <A
HREF="../../CORBA/doc-files/compliance.html">Official Specifications for CORBA
support in Java[tm] SE 6</A>.
-<p>
+
@since 1.4
<br>
@serial exclude
--- a/corba/src/java.corba/share/classes/org/omg/PortableServer/POAPackage/package.html Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/PortableServer/POAPackage/package.html Tue Apr 14 12:10:00 2015 -0700
@@ -3,7 +3,7 @@
<head>
<!--
- Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,6 @@
between different ORB products.
<P>The Portable Object Adaptor (POA) is designed to meet the following goals:
-<P>
<UL>
<LI>Allow programmers to construct object implementations that are portable between different ORB products.
<LI>Provide support for objects with persistent identities.
@@ -66,7 +65,7 @@
the Java[tm] Platform, Standard Edition 6, ORB complies, see <A
HREF="../../CORBA/doc-files/compliance.html">Official Specifications for CORBA
support in Java[tm] SE 6</A>.
-<p>
+
@since 1.4
<br>
@serial exclude
--- a/corba/src/java.corba/share/classes/org/omg/PortableServer/ServantLocatorPackage/package.html Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/PortableServer/ServantLocatorPackage/package.html Tue Apr 14 12:10:00 2015 -0700
@@ -3,7 +3,7 @@
<head>
<!--
- Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
@@ -43,13 +43,6 @@
the Java[tm] Platform, Standard Edition 6 complies, see <A
HREF="../../CORBA/doc-files/compliance.html">Official Specifications for CORBA
support in Java[tm] SE 6</A>.
-<p>
-
-
-
-
-
-
@since 1.4
<br>
--- a/corba/src/java.corba/share/classes/org/omg/PortableServer/package.html Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/PortableServer/package.html Tue Apr 14 12:10:00 2015 -0700
@@ -3,7 +3,7 @@
<head>
<!--
- Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
@@ -52,12 +52,10 @@
the Java[tm] Platform, Standard Edition 6 complies, see <A
HREF="../CORBA/doc-files/compliance.html">Official Specifications for CORBA
support in Java[tm] SE 6</A>.
-<p>
<H2>POA-related Interfaces</H2>
<P>The <TT>PortableServer</TT> module defines the following POA-related interfaces:
-<P>
<UL>
<LI><TT>POA</TT>
<LI><TT>POAManager</TT>
@@ -79,12 +77,18 @@
<H3>Operations classes</H3>
-<P>Each of the interfaces listed above has an associated <code>Operations</code> interface. The <code>Operations</code> interface is generated by the <code>idlj</code> compiler and contains the method signatures for methods defined in its associated interface. The <code>Operations</code> interface can be accessed by both the client and the server, while its associated interface can only be called by the client.
+<P>Each of the interfaces listed above has an associated <code>Operations</code> interface.
+The <code>Operations</code> interface is generated by the <code>idlj</code> compiler and
+contains the method signatures for methods defined in its associated interface.
+The <code>Operations</code> interface can be accessed by both the client and the server,
+while its associated interface can only be called by the client.
<H3>Value Classes</H3>
-Classes ending in the suffix <code>PolicyValue</code> provide the values used for the <code>create_POA</code> call, which sets the policy for the POA. See the <a href="#sampleserver">sample code</a> below for a demonstration. <code>PolicyValue</code> files include the following:
-<P>
+Classes ending in the suffix <code>PolicyValue</code> provide the values used
+for the <code>create_POA</code> call, which sets the policy for the POA. See
+the <a href="#sampleserver">sample code</a> below for a demonstration.
+<code>PolicyValue</code> files include the following:
<UL>
<LI><code>IdAssignmentPolicyValue</code>
<LI><code>IdUniquenessPolicyValue</code>
@@ -98,8 +102,11 @@
<H3>Helper Classes</H3>
<P>Helper classes, which are generated for all user-defined types in an OMG IDL
-interface, supply static methods needed to manipulate those types. There is only one method in a helper class that an application programmer uses: the <code>narrow</code> method. Only Java interfaces mapped from IDL interfaces will have a helper class that includes a <code>narrow</code> method, so in the <code>PortableServer</code> package, only the following classes have a <code>narrow</code> method:
-<P>
+interface, supply static methods needed to manipulate those types.
+There is only one method in a helper class that an application programmer uses:
+the <code>narrow</code> method. Only Java interfaces mapped from IDL interfaces
+will have a helper class that includes a <code>narrow</code> method, so in
+the <code>PortableServer</code> package, only the following classes have a <code>narrow</code> method:
<UL>
<LI><code>ForwardRequestHelper</code>
<LI><code>ServantActivatorHelper</code>
@@ -113,22 +120,31 @@
<H3>Exceptions</H3>
<P>The <code>ForwardRequest</code> exception indicates to the ORB
-that it is responsible for delivering the current request and subsequent <code>ForwardRequest</code> requests to the object denoted in the
- <code>forward_reference</code> member of the exception.
+that it is responsible for delivering the current request and
+subsequent <code>ForwardRequest</code> requests to the object denoted in the
+<code>forward_reference</code> member of the exception.
<H3>Interfaces Implemented by the Application Programmer</H3>
-<P>Most of what <code>PortableServer</code> does is transparent to the user. The result is that programmers will use only a few of the interfaces mentioned above. The remaining interfaces will be provided by the ORB implementation. The interfaces of interest to application programmers are the following:
-<P>
+<P>Most of what <code>PortableServer</code> does is transparent to the user.
+The result is that programmers will use only a few of the interfaces mentioned above.
+The remaining interfaces will be provided by the ORB implementation.
+The interfaces of interest to application programmers are the following:
<ul>
- <LI><code>AdapterActivator</code>
- <P>Adapter activators are associated with POAs. An adapter activator supplies a POA with the ability to create child POAs on demand, as a side-effect of receiving a request that names the child POA (or one of its children), or when <code>find_POA</code> is called with an activate parameter value of <code>TRUE</code>. An application server that creates all its needed POAs at the beginning of execution does not need to use or provide an adapter activator; it is necessary only for the case in which POAs need to be created during request processing.
- <P>
- <LI><code>ServantLocator</code>
- <P>When the POA has the <code>NON_RETAIN</code> policy, it uses servant managers that are <code>ServantLocator</code>s.
- <P>
- <LI><code>ServantActivator</code>
- <P>When the POA has the <code>RETAIN</code> policy, it uses servant managers that are <code>ServantActivator</code>s.
+ <LI><code>AdapterActivator</code>
+ <P>Adapter activators are associated with POAs.
+ An adapter activator supplies a POA with the ability to create child POAs on demand,
+ as a side-effect of receiving a request that names the child POA (or one of its children),
+ or when <code>find_POA</code> is called with an activate parameter value of <code>TRUE</code>.
+ An application server that creates all its needed POAs at the beginning of execution
+ does not need to use or provide an adapter activator; it is necessary
+ only for the case in which POAs need to be created during request processing.
+ <LI><code>ServantLocator</code>
+ <P>When the POA has the <code>NON_RETAIN</code> policy,
+ it uses servant managers that are <code>ServantLocator</code>s.
+ <LI><code>ServantActivator</code>
+ <P>When the POA has the <code>RETAIN</code> policy,
+ it uses servant managers that are <code>ServantActivator</code>s.
</ul>
@@ -141,13 +157,11 @@
<H2>Related Documentation</H2>
<P>For an overview of Java IDL, please see:
-<P>
-<LI><A HREF="../../../../technotes/guides/idl/index.html">Java IDL home page</A>.
+<A HREF="../../../../technotes/guides/idl/index.html">Java IDL home page</A>.
<H2>Example Code</H2>
<a name="sampleserver"></a>
<H3>Example Server Code</H3>
-<P>
<PRE>
import javax.naming.InitialContext;
import javax.naming.Context;
@@ -209,9 +223,6 @@
-<P>
-
-
@since 1.4
<br>
@serial exclude
--- a/corba/src/java.corba/share/classes/org/omg/SendingContext/package.html Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/SendingContext/package.html Tue Apr 14 12:10:00 2015 -0700
@@ -3,7 +3,7 @@
<head>
<!--
- Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
@@ -68,7 +68,7 @@
the Java[tm] Platform, Standard Edition 6 ORB complies, see <A
HREF="../CORBA/doc-files/compliance.html">Official Specifications for CORBA
support in Java[tm] SE 6</A>.
-<p>
+
@since 1.3
<br>
@serial exclude
--- a/corba/src/java.corba/share/classes/org/omg/stub/java/rmi/package.html Mon Apr 13 17:03:11 2015 -0700
+++ b/corba/src/java.corba/share/classes/org/omg/stub/java/rmi/package.html Tue Apr 14 12:10:00 2015 -0700
@@ -3,7 +3,7 @@
<title>org.omg.stub.java.rmi package</title>
<!--
- Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,7 @@
<body bgcolor="white">
Contains RMI-IIOP Stubs for the Remote types that occur in the
<tt>java.rmi</tt> package.
-<p>
+
@since 1.3
<br>
@serial exclude
--- a/hotspot/.hgtags Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/.hgtags Tue Apr 14 12:10:00 2015 -0700
@@ -460,3 +460,5 @@
be49ab55e5c498c5077bbf58c2737100d1992339 jdk9-b55
fd2d5ec7e7b16c7bf4043a7fe7cfd8af96b819e2 jdk9-b56
56a85ffe743d3f9d70ba25d6ce82ddd2ad1bf33c jdk9-b57
+ee878f3d6732856f7725c590312bfbe2ffa52cc7 jdk9-b58
+96bcaec07cb165782bae1b9a1f28450b37a10e3a jdk9-b59
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/GenCollectedHeap.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/GenCollectedHeap.java Tue Apr 14 12:10:00 2015 -0700
@@ -37,7 +37,9 @@
private static CIntegerField nGensField;
private static AddressField youngGenField;
private static AddressField oldGenField;
- private static AddressField genSpecsField;
+
+ private static AddressField youngGenSpecField;
+ private static AddressField oldGenSpecField;
private static GenerationFactory genFactory;
@@ -55,9 +57,12 @@
nGensField = type.getCIntegerField("_n_gens");
youngGenField = type.getAddressField("_young_gen");
oldGenField = type.getAddressField("_old_gen");
- genSpecsField = type.getAddressField("_gen_specs");
genFactory = new GenerationFactory();
+
+ Type collectorPolicyType = db.lookupType("GenCollectorPolicy");
+ youngGenSpecField = collectorPolicyType.getAddressField("_young_gen_spec");
+ oldGenSpecField = collectorPolicyType.getAddressField("_old_gen_spec");
}
public GenCollectedHeap(Address addr) {
@@ -115,21 +120,23 @@
/** Package-private access to GenerationSpecs */
GenerationSpec spec(int level) {
if (Assert.ASSERTS_ENABLED) {
- Assert.that((level >= 0) && (level < nGens()), "Index " + level +
- " out of range (should be between 0 and " + nGens() + ")");
+ Assert.that((level == 0) || (level == 1), "Index " + level +
+ " out of range (should be 0 or 1)");
}
- if ((level < 0) || (level >= nGens())) {
+ if ((level != 0) && (level != 1)) {
return null;
}
- Address ptrList = genSpecsField.getValue(addr);
- if (ptrList == null) {
- return null;
+ if (level == 0) {
+ return (GenerationSpec)
+ VMObjectFactory.newObject(GenerationSpec.class,
+ youngGenSpecField.getAddress());
+ } else {
+ return (GenerationSpec)
+ VMObjectFactory.newObject(GenerationSpec.class,
+ oldGenSpecField.getAddress());
}
- return (GenerationSpec)
- VMObjectFactory.newObject(GenerationSpec.class,
- ptrList.getAddressAt(level * VM.getVM().getAddressSize()));
}
public CollectedHeapName kind() {
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java Tue Apr 14 12:10:00 2015 -0700
@@ -123,6 +123,7 @@
private static Type intxType;
private static Type uintxType;
+ private static Type sizetType;
private static CIntegerType boolType;
private Boolean sharingEnabled;
private Boolean compressedOopsEnabled;
@@ -175,7 +176,7 @@
public long getIntx() {
if (Assert.ASSERTS_ENABLED) {
- Assert.that(isIntx(), "not a intx flag!");
+ Assert.that(isIntx(), "not an intx flag!");
}
return addr.getCIntegerAt(0, intxType.getSize(), false);
}
@@ -191,6 +192,17 @@
return addr.getCIntegerAt(0, uintxType.getSize(), true);
}
+ public boolean isSizet() {
+ return type.equals("size_t");
+ }
+
+ public long getSizet() {
+ if (Assert.ASSERTS_ENABLED) {
+ Assert.that(isSizet(), "not a size_t flag!");
+ }
+ return addr.getCIntegerAt(0, sizetType.getSize(), true);
+ }
+
public String getValue() {
if (isBool()) {
return new Boolean(getBool()).toString();
@@ -198,6 +210,8 @@
return new Long(getIntx()).toString();
} else if (isUIntx()) {
return new Long(getUIntx()).toString();
+ } else if (isSizet()) {
+ return new Long(getSizet()).toString();
} else {
return null;
}
@@ -323,6 +337,7 @@
intxType = db.lookupType("intx");
uintxType = db.lookupType("uintx");
+ sizetType = db.lookupType("size_t");
boolType = (CIntegerType) db.lookupType("bool");
minObjAlignmentInBytes = getObjectAlignmentInBytes();
--- a/hotspot/make/linux/makefiles/gcc.make Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/make/linux/makefiles/gcc.make Tue Apr 14 12:10:00 2015 -0700
@@ -207,7 +207,7 @@
WARNINGS_ARE_ERRORS += -Wno-return-type -Wno-empty-body
endif
-WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value -Wformat=2 -Wreturn-type
+WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value -Wformat=2 -Wreturn-type -Woverloaded-virtual
ifeq ($(USE_CLANG),)
# Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
--- a/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, Red Hat Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -673,7 +673,6 @@
void gen_write_ref_array_pre_barrier(Register addr, Register count, bool dest_uninitialized) {
BarrierSet* bs = Universe::heap()->barrier_set();
switch (bs->kind()) {
- case BarrierSet::G1SATBCT:
case BarrierSet::G1SATBCTLogging:
// With G1, don't generate the call if we statically know that the target in uninitialized
if (!dest_uninitialized) {
@@ -719,7 +718,6 @@
assert_different_registers(start, end, scratch);
BarrierSet* bs = Universe::heap()->barrier_set();
switch (bs->kind()) {
- case BarrierSet::G1SATBCT:
case BarrierSet::G1SATBCTLogging:
{
--- a/hotspot/src/cpu/aarch64/vm/templateTable_aarch64.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/cpu/aarch64/vm/templateTable_aarch64.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, Red Hat Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -150,7 +150,6 @@
assert(val == noreg || val == r0, "parameter is just for looks");
switch (barrier) {
#if INCLUDE_ALL_GCS
- case BarrierSet::G1SATBCT:
case BarrierSet::G1SATBCTLogging:
{
// flatten object address if needed
--- a/hotspot/src/cpu/ppc/vm/c2_globals_ppc.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/cpu/ppc/vm/c2_globals_ppc.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright 2012, 2014 SAP AG. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -49,7 +49,7 @@
define_pd_global(intx, MinJumpTableSize, 10);
define_pd_global(intx, INTPRESSURE, 25);
define_pd_global(intx, InteriorEntryAlignment, 16);
-define_pd_global(intx, NewSizeThreadIncrease, ScaleForWordSize(4*K));
+define_pd_global(size_t, NewSizeThreadIncrease, ScaleForWordSize(4*K));
define_pd_global(intx, RegisterCostAreaRatio, 16000);
define_pd_global(bool, UseTLAB, true);
define_pd_global(bool, ResizeTLAB, true);
@@ -85,14 +85,14 @@
define_pd_global(intx, CodeCacheExpansionSize, 64*K);
// Ergonomics related flags
-define_pd_global(uint64_t,MaxRAM, 4ULL*G);
+define_pd_global(uint64_t, MaxRAM, 4ULL*G);
define_pd_global(uintx, CodeCacheMinBlockLength, 4);
define_pd_global(uintx, CodeCacheMinimumUseSpace, 400*K);
define_pd_global(bool, TrapBasedRangeChecks, true);
// Heap related flags
-define_pd_global(uintx,MetaspaceSize, ScaleForWordSize(16*M));
+define_pd_global(size_t, MetaspaceSize, ScaleForWordSize(16*M));
// Ergonomics related flags
define_pd_global(bool, NeverActAsServerClassMachine, false);
--- a/hotspot/src/cpu/ppc/vm/globals_ppc.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/cpu/ppc/vm/globals_ppc.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright 2012, 2013 SAP AG. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -56,7 +56,7 @@
define_pd_global(bool, UseMembar, false);
// GC Ergo Flags
-define_pd_global(uintx, CMSYoungGenPerWorker, 16*M); // Default max size of CMS young gen, per GC worker thread.
+define_pd_global(size_t, CMSYoungGenPerWorker, 16*M); // Default max size of CMS young gen, per GC worker thread.
define_pd_global(uintx, TypeProfileLevel, 0);
--- a/hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -608,7 +608,6 @@
void gen_write_ref_array_pre_barrier(Register from, Register to, Register count, bool dest_uninitialized, Register Rtmp1) {
BarrierSet* const bs = Universe::heap()->barrier_set();
switch (bs->kind()) {
- case BarrierSet::G1SATBCT:
case BarrierSet::G1SATBCTLogging:
// With G1, don't generate the call if we statically know that the target in uninitialized
if (!dest_uninitialized) {
@@ -665,7 +664,6 @@
BarrierSet* const bs = Universe::heap()->barrier_set();
switch (bs->kind()) {
- case BarrierSet::G1SATBCT:
case BarrierSet::G1SATBCTLogging:
{
if (branchToEnd) {
--- a/hotspot/src/cpu/ppc/vm/templateTable_ppc_64.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/cpu/ppc/vm/templateTable_ppc_64.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -66,7 +66,6 @@
switch (barrier) {
#if INCLUDE_ALL_GCS
- case BarrierSet::G1SATBCT:
case BarrierSet::G1SATBCTLogging:
{
// Load and record the previous value.
--- a/hotspot/src/cpu/sparc/vm/c1_globals_sparc.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/cpu/sparc/vm/c1_globals_sparc.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -53,10 +53,10 @@
define_pd_global(intx, CodeCacheExpansionSize, 32*K );
define_pd_global(uintx, CodeCacheMinBlockLength, 1);
define_pd_global(uintx, CodeCacheMinimumUseSpace, 400*K);
-define_pd_global(uintx, MetaspaceSize, 12*M );
+define_pd_global(size_t, MetaspaceSize, 12*M );
define_pd_global(bool, NeverActAsServerClassMachine, true );
-define_pd_global(intx, NewSizeThreadIncrease, 16*K );
-define_pd_global(uint64_t,MaxRAM, 1ULL*G);
+define_pd_global(size_t, NewSizeThreadIncrease, 16*K );
+define_pd_global(uint64_t, MaxRAM, 1ULL*G);
define_pd_global(intx, InitialCodeCacheSize, 160*K);
#endif // !TIERED
--- a/hotspot/src/cpu/sparc/vm/c2_globals_sparc.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/cpu/sparc/vm/c2_globals_sparc.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -51,7 +51,7 @@
define_pd_global(intx, FreqInlineSize, 175);
define_pd_global(intx, INTPRESSURE, 48); // large register set
define_pd_global(intx, InteriorEntryAlignment, 16); // = CodeEntryAlignment
-define_pd_global(intx, NewSizeThreadIncrease, ScaleForWordSize(4*K));
+define_pd_global(size_t, NewSizeThreadIncrease, ScaleForWordSize(4*K));
define_pd_global(intx, RegisterCostAreaRatio, 12000);
define_pd_global(bool, UseTLAB, true);
define_pd_global(bool, ResizeTLAB, true);
@@ -90,7 +90,7 @@
define_pd_global(intx, NonNMethodCodeHeapSize, 5*M );
define_pd_global(intx, CodeCacheExpansionSize, 32*K);
// Ergonomics related flags
-define_pd_global(uint64_t,MaxRAM, 4ULL*G);
+define_pd_global(uint64_t, MaxRAM, 4ULL*G);
#endif
define_pd_global(uintx, CodeCacheMinBlockLength, 4);
define_pd_global(uintx, CodeCacheMinimumUseSpace, 400*K);
@@ -98,7 +98,7 @@
define_pd_global(bool, TrapBasedRangeChecks, false); // Not needed on sparc.
// Heap related flags
-define_pd_global(uintx,MetaspaceSize, ScaleForWordSize(16*M));
+define_pd_global(size_t, MetaspaceSize, ScaleForWordSize(16*M));
// Ergonomics related flags
define_pd_global(bool, NeverActAsServerClassMachine, false);
--- a/hotspot/src/cpu/sparc/vm/globals_sparc.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/cpu/sparc/vm/globals_sparc.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -75,7 +75,7 @@
define_pd_global(bool, UseMembar, false);
// GC Ergo Flags
-define_pd_global(uintx, CMSYoungGenPerWorker, 16*M); // default max size of CMS young gen, per GC worker thread
+define_pd_global(size_t, CMSYoungGenPerWorker, 16*M); // default max size of CMS young gen, per GC worker thread
define_pd_global(uintx, TypeProfileLevel, 0);
--- a/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -957,7 +957,6 @@
void gen_write_ref_array_pre_barrier(Register addr, Register count, bool dest_uninitialized) {
BarrierSet* bs = Universe::heap()->barrier_set();
switch (bs->kind()) {
- case BarrierSet::G1SATBCT:
case BarrierSet::G1SATBCTLogging:
// With G1, don't generate the call if we statically know that the target in uninitialized
if (!dest_uninitialized) {
@@ -1005,7 +1004,6 @@
BarrierSet* bs = Universe::heap()->barrier_set();
switch (bs->kind()) {
- case BarrierSet::G1SATBCT:
case BarrierSet::G1SATBCTLogging:
{
// Get some new fresh output registers.
--- a/hotspot/src/cpu/sparc/vm/templateTable_sparc.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/cpu/sparc/vm/templateTable_sparc.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -56,7 +56,6 @@
assert(index == noreg || offset == 0, "only one offset");
switch (barrier) {
#if INCLUDE_ALL_GCS
- case BarrierSet::G1SATBCT:
case BarrierSet::G1SATBCTLogging:
{
// Load and record the previous value.
--- a/hotspot/src/cpu/x86/vm/c1_globals_x86.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/cpu/x86/vm/c1_globals_x86.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,39 +32,39 @@
// (see c1_globals.hpp)
#ifndef TIERED
-define_pd_global(bool, BackgroundCompilation, true );
-define_pd_global(bool, UseTLAB, true );
-define_pd_global(bool, ResizeTLAB, true );
-define_pd_global(bool, InlineIntrinsics, true );
-define_pd_global(bool, PreferInterpreterNativeStubs, false);
-define_pd_global(bool, ProfileTraps, false);
-define_pd_global(bool, UseOnStackReplacement, true );
-define_pd_global(bool, TieredCompilation, false);
-define_pd_global(intx, CompileThreshold, 1500 );
+define_pd_global(bool, BackgroundCompilation, true );
+define_pd_global(bool, UseTLAB, true );
+define_pd_global(bool, ResizeTLAB, true );
+define_pd_global(bool, InlineIntrinsics, true );
+define_pd_global(bool, PreferInterpreterNativeStubs, false);
+define_pd_global(bool, ProfileTraps, false);
+define_pd_global(bool, UseOnStackReplacement, true );
+define_pd_global(bool, TieredCompilation, false);
+define_pd_global(intx, CompileThreshold, 1500 );
-define_pd_global(intx, OnStackReplacePercentage, 933 );
-define_pd_global(intx, FreqInlineSize, 325 );
-define_pd_global(intx, NewSizeThreadIncrease, 4*K );
-define_pd_global(intx, InitialCodeCacheSize, 160*K);
-define_pd_global(intx, ReservedCodeCacheSize, 32*M );
-define_pd_global(intx, NonProfiledCodeHeapSize, 13*M );
-define_pd_global(intx, ProfiledCodeHeapSize, 14*M );
-define_pd_global(intx, NonNMethodCodeHeapSize, 5*M );
-define_pd_global(bool, ProfileInterpreter, false);
-define_pd_global(intx, CodeCacheExpansionSize, 32*K );
-define_pd_global(uintx, CodeCacheMinBlockLength, 1);
-define_pd_global(uintx, CodeCacheMinimumUseSpace, 400*K);
-define_pd_global(uintx, MetaspaceSize, 12*M );
-define_pd_global(bool, NeverActAsServerClassMachine, true );
-define_pd_global(uint64_t,MaxRAM, 1ULL*G);
-define_pd_global(bool, CICompileOSR, true );
+define_pd_global(intx, OnStackReplacePercentage, 933 );
+define_pd_global(intx, FreqInlineSize, 325 );
+define_pd_global(size_t, NewSizeThreadIncrease, 4*K );
+define_pd_global(intx, InitialCodeCacheSize, 160*K);
+define_pd_global(intx, ReservedCodeCacheSize, 32*M );
+define_pd_global(intx, NonProfiledCodeHeapSize, 13*M );
+define_pd_global(intx, ProfiledCodeHeapSize, 14*M );
+define_pd_global(intx, NonNMethodCodeHeapSize, 5*M );
+define_pd_global(bool, ProfileInterpreter, false);
+define_pd_global(intx, CodeCacheExpansionSize, 32*K );
+define_pd_global(uintx, CodeCacheMinBlockLength, 1 );
+define_pd_global(uintx, CodeCacheMinimumUseSpace, 400*K);
+define_pd_global(size_t, MetaspaceSize, 12*M );
+define_pd_global(bool, NeverActAsServerClassMachine, true );
+define_pd_global(uint64_t, MaxRAM, 1ULL*G);
+define_pd_global(bool, CICompileOSR, true );
#endif // !TIERED
-define_pd_global(bool, UseTypeProfile, false);
-define_pd_global(bool, RoundFPResults, true );
+define_pd_global(bool, UseTypeProfile, false);
+define_pd_global(bool, RoundFPResults, true );
-define_pd_global(bool, LIRFillDelaySlots, false);
-define_pd_global(bool, OptimizeSinglePrecision, true );
-define_pd_global(bool, CSEArrayLength, false);
-define_pd_global(bool, TwoOperandLIRForm, true );
+define_pd_global(bool, LIRFillDelaySlots, false);
+define_pd_global(bool, OptimizeSinglePrecision, true );
+define_pd_global(bool, CSEArrayLength, false);
+define_pd_global(bool, TwoOperandLIRForm, true );
#endif // CPU_X86_VM_C1_GLOBALS_X86_HPP
--- a/hotspot/src/cpu/x86/vm/c2_globals_x86.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/cpu/x86/vm/c2_globals_x86.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -54,25 +54,25 @@
#ifdef AMD64
define_pd_global(intx, INTPRESSURE, 13);
define_pd_global(intx, InteriorEntryAlignment, 16);
-define_pd_global(intx, NewSizeThreadIncrease, ScaleForWordSize(4*K));
+define_pd_global(size_t, NewSizeThreadIncrease, ScaleForWordSize(4*K));
define_pd_global(intx, LoopUnrollLimit, 60);
// InitialCodeCacheSize derived from specjbb2000 run.
define_pd_global(intx, InitialCodeCacheSize, 2496*K); // Integral multiple of CodeCacheExpansionSize
define_pd_global(intx, CodeCacheExpansionSize, 64*K);
// Ergonomics related flags
-define_pd_global(uint64_t,MaxRAM, 128ULL*G);
+define_pd_global(uint64_t, MaxRAM, 128ULL*G);
#else
define_pd_global(intx, INTPRESSURE, 6);
define_pd_global(intx, InteriorEntryAlignment, 4);
-define_pd_global(intx, NewSizeThreadIncrease, 4*K);
+define_pd_global(size_t, NewSizeThreadIncrease, 4*K);
define_pd_global(intx, LoopUnrollLimit, 50); // Design center runs on 1.3.1
// InitialCodeCacheSize derived from specjbb2000 run.
define_pd_global(intx, InitialCodeCacheSize, 2304*K); // Integral multiple of CodeCacheExpansionSize
define_pd_global(intx, CodeCacheExpansionSize, 32*K);
// Ergonomics related flags
-define_pd_global(uint64_t,MaxRAM, 4ULL*G);
+define_pd_global(uint64_t, MaxRAM, 4ULL*G);
#endif // AMD64
define_pd_global(intx, RegisterCostAreaRatio, 16000);
@@ -93,7 +93,7 @@
define_pd_global(bool, TrapBasedRangeChecks, false); // Not needed on x86.
// Heap related flags
-define_pd_global(uintx,MetaspaceSize, ScaleForWordSize(16*M));
+define_pd_global(size_t, MetaspaceSize, ScaleForWordSize(16*M));
// Ergonomics related flags
define_pd_global(bool, NeverActAsServerClassMachine, false);
--- a/hotspot/src/cpu/x86/vm/globals_x86.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/cpu/x86/vm/globals_x86.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -78,7 +78,7 @@
#endif
// GC Ergo Flags
-define_pd_global(uintx, CMSYoungGenPerWorker, 64*M); // default max size of CMS young gen, per GC worker thread
+define_pd_global(size_t, CMSYoungGenPerWorker, 64*M); // default max size of CMS young gen, per GC worker thread
define_pd_global(uintx, TypeProfileLevel, 111);
--- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -706,7 +706,6 @@
assert_different_registers(start, count);
BarrierSet* bs = Universe::heap()->barrier_set();
switch (bs->kind()) {
- case BarrierSet::G1SATBCT:
case BarrierSet::G1SATBCTLogging:
// With G1, don't generate the call if we statically know that the target in uninitialized
if (!uninitialized_target) {
@@ -739,7 +738,6 @@
BarrierSet* bs = Universe::heap()->barrier_set();
assert_different_registers(start, count);
switch (bs->kind()) {
- case BarrierSet::G1SATBCT:
case BarrierSet::G1SATBCTLogging:
{
__ pusha(); // push registers
--- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -1207,7 +1207,6 @@
void gen_write_ref_array_pre_barrier(Register addr, Register count, bool dest_uninitialized) {
BarrierSet* bs = Universe::heap()->barrier_set();
switch (bs->kind()) {
- case BarrierSet::G1SATBCT:
case BarrierSet::G1SATBCTLogging:
// With G1, don't generate the call if we statically know that the target in uninitialized
if (!dest_uninitialized) {
@@ -1252,7 +1251,6 @@
assert_different_registers(start, count, scratch);
BarrierSet* bs = Universe::heap()->barrier_set();
switch (bs->kind()) {
- case BarrierSet::G1SATBCT:
case BarrierSet::G1SATBCTLogging:
{
__ pusha(); // push registers (overkill)
--- a/hotspot/src/cpu/x86/vm/templateTable_x86.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/cpu/x86/vm/templateTable_x86.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -156,7 +156,6 @@
assert(val == noreg || val == rax, "parameter is just for looks");
switch (barrier) {
#if INCLUDE_ALL_GCS
- case BarrierSet::G1SATBCT:
case BarrierSet::G1SATBCTLogging:
{
// flatten object address if needed
--- a/hotspot/src/cpu/zero/vm/globals_zero.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/cpu/zero/vm/globals_zero.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright 2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -57,7 +57,7 @@
define_pd_global(bool, UseMembar, true);
// GC Ergo Flags
-define_pd_global(uintx, CMSYoungGenPerWorker, 16*M); // default max size of CMS young gen, per GC worker thread
+define_pd_global(size_t, CMSYoungGenPerWorker, 16*M); // default max size of CMS young gen, per GC worker thread
define_pd_global(uintx, TypeProfileLevel, 0);
--- a/hotspot/src/cpu/zero/vm/shark_globals_zero.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/cpu/zero/vm/shark_globals_zero.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright 2008, 2009, 2010 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -50,7 +50,7 @@
define_pd_global(intx, OnStackReplacePercentage, 933 );
define_pd_global(intx, FreqInlineSize, 325 );
define_pd_global(uintx, NewRatio, 12 );
-define_pd_global(intx, NewSizeThreadIncrease, 4*K );
+define_pd_global(size_t, NewSizeThreadIncrease, 4*K );
define_pd_global(intx, InitialCodeCacheSize, 160*K);
define_pd_global(intx, ReservedCodeCacheSize, 32*M );
define_pd_global(intx, NonProfiledCodeHeapSize, 13*M );
@@ -61,7 +61,7 @@
define_pd_global(uintx, CodeCacheMinBlockLength, 1 );
define_pd_global(uintx, CodeCacheMinimumUseSpace, 200*K);
-define_pd_global(uintx, MetaspaceSize, 12*M );
+define_pd_global(size_t, MetaspaceSize, 12*M );
define_pd_global(bool, NeverActAsServerClassMachine, true );
define_pd_global(uint64_t, MaxRAM, 1ULL*G);
define_pd_global(bool, CICompileOSR, true );
--- a/hotspot/src/os_cpu/aix_ppc/vm/globals_aix_ppc.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/os_cpu/aix_ppc/vm/globals_aix_ppc.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -40,13 +40,13 @@
define_pd_global(intx, CompilerThreadStackSize, 4096);
// Allow extra space in DEBUG builds for asserts.
-define_pd_global(uintx,JVMInvokeMethodSlack, 8192);
+define_pd_global(size_t, JVMInvokeMethodSlack, 8192);
define_pd_global(intx, StackYellowPages, 6);
define_pd_global(intx, StackRedPages, 1);
define_pd_global(intx, StackShadowPages, 6 DEBUG_ONLY(+2));
// Only used on 64 bit platforms
-define_pd_global(uintx,HeapBaseMinAddress, 2*G);
+define_pd_global(size_t, HeapBaseMinAddress, 2*G);
#endif // OS_CPU_AIX_OJDKPPC_VM_GLOBALS_AIX_PPC_HPP
--- a/hotspot/src/os_cpu/bsd_x86/vm/globals_bsd_x86.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/os_cpu/bsd_x86/vm/globals_bsd_x86.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -43,9 +43,9 @@
define_pd_global(intx, CompilerThreadStackSize, 0);
-define_pd_global(uintx, JVMInvokeMethodSlack, 8192);
+define_pd_global(size_t, JVMInvokeMethodSlack, 8192);
// Used on 64 bit platforms for UseCompressedOops base address
-define_pd_global(uintx, HeapBaseMinAddress, 2*G);
+define_pd_global(size_t, HeapBaseMinAddress, 2*G);
#endif // OS_CPU_BSD_X86_VM_GLOBALS_BSD_X86_HPP
--- a/hotspot/src/os_cpu/bsd_zero/vm/globals_bsd_zero.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/os_cpu/bsd_zero/vm/globals_bsd_zero.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright 2007, 2008, 2010 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -39,9 +39,9 @@
define_pd_global(intx, VMThreadStackSize, 512);
#endif // _LP64
define_pd_global(intx, CompilerThreadStackSize, 0);
-define_pd_global(uintx, JVMInvokeMethodSlack, 8192);
+define_pd_global(size_t, JVMInvokeMethodSlack, 8192);
// Used on 64 bit platforms for UseCompressedOops base address
-define_pd_global(uintx, HeapBaseMinAddress, 2*G);
+define_pd_global(size_t, HeapBaseMinAddress, 2*G);
#endif // OS_CPU_BSD_ZERO_VM_GLOBALS_BSD_ZERO_HPP
--- a/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -116,6 +116,14 @@
#endif
}
+void os::Linux::ucontext_set_pc(ucontext_t * uc, address pc) {
+#ifdef BUILTIN_SIM
+ uc->uc_mcontext.gregs[REG_PC] = (intptr_t)pc;
+#else
+ uc->uc_mcontext.pc = (intptr_t)pc;
+#endif
+}
+
intptr_t* os::Linux::ucontext_get_sp(ucontext_t * uc) {
#ifdef BUILTIN_SIM
return (intptr_t*)uc->uc_mcontext.gregs[REG_SP];
@@ -311,7 +319,7 @@
}
#else
if (StubRoutines::is_safefetch_fault(pc)) {
- uc->uc_mcontext.pc = intptr_t(StubRoutines::continuation_for_safefetch_fault(pc));
+ os::Linux::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
return 1;
}
#endif
@@ -432,11 +440,7 @@
// save all thread context in case we need to restore it
if (thread != NULL) thread->set_saved_exception_pc(pc);
-#ifdef BUILTIN_SIM
- uc->uc_mcontext.gregs[REG_PC] = (greg_t)stub;
-#else
- uc->uc_mcontext.pc = (__u64)stub;
-#endif
+ os::Linux::ucontext_set_pc(uc, stub);
return true;
}
--- a/hotspot/src/os_cpu/linux_ppc/vm/globals_linux_ppc.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/os_cpu/linux_ppc/vm/globals_linux_ppc.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -40,13 +40,13 @@
define_pd_global(intx, CompilerThreadStackSize, 4096);
// Allow extra space in DEBUG builds for asserts.
-define_pd_global(uintx,JVMInvokeMethodSlack, 8192);
+define_pd_global(size_t, JVMInvokeMethodSlack, 8192);
define_pd_global(intx, StackYellowPages, 6);
define_pd_global(intx, StackRedPages, 1);
define_pd_global(intx, StackShadowPages, 6 DEBUG_ONLY(+2));
// Only used on 64 bit platforms
-define_pd_global(uintx,HeapBaseMinAddress, 2*G);
+define_pd_global(size_t, HeapBaseMinAddress, 2*G);
#endif // OS_CPU_LINUX_PPC_VM_GLOBALS_LINUX_PPC_HPP
--- a/hotspot/src/os_cpu/linux_sparc/vm/globals_linux_sparc.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/os_cpu/linux_sparc/vm/globals_linux_sparc.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,10 +30,10 @@
// runtime system. (see globals.hpp)
//
-define_pd_global(uintx, JVMInvokeMethodSlack, 12288);
+define_pd_global(size_t, JVMInvokeMethodSlack, 12288);
define_pd_global(intx, CompilerThreadStackSize, 0);
// Used on 64 bit platforms for UseCompressedOops base address
-define_pd_global(uintx, HeapBaseMinAddress, CONST64(4)*G);
+define_pd_global(size_t, HeapBaseMinAddress, CONST64(4)*G);
#endif // OS_CPU_LINUX_SPARC_VM_GLOBALS_LINUX_SPARC_HPP
--- a/hotspot/src/os_cpu/linux_x86/vm/globals_linux_x86.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/os_cpu/linux_x86/vm/globals_linux_x86.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -42,9 +42,9 @@
define_pd_global(intx, CompilerThreadStackSize, 0);
-define_pd_global(uintx,JVMInvokeMethodSlack, 8192);
+define_pd_global(size_t, JVMInvokeMethodSlack, 8192);
// Used on 64 bit platforms for UseCompressedOops base address
-define_pd_global(uintx,HeapBaseMinAddress, 2*G);
+define_pd_global(size_t, HeapBaseMinAddress, 2*G);
#endif // OS_CPU_LINUX_X86_VM_GLOBALS_LINUX_X86_HPP
--- a/hotspot/src/os_cpu/linux_zero/vm/globals_linux_zero.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/os_cpu/linux_zero/vm/globals_linux_zero.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright 2007, 2008, 2010 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -39,9 +39,9 @@
define_pd_global(intx, VMThreadStackSize, 512);
#endif // _LP64
define_pd_global(intx, CompilerThreadStackSize, 0);
-define_pd_global(uintx, JVMInvokeMethodSlack, 8192);
+define_pd_global(size_t, JVMInvokeMethodSlack, 8192);
// Used on 64 bit platforms for UseCompressedOops base address
-define_pd_global(uintx, HeapBaseMinAddress, 2*G);
+define_pd_global(size_t, HeapBaseMinAddress, 2*G);
#endif // OS_CPU_LINUX_ZERO_VM_GLOBALS_LINUX_ZERO_HPP
--- a/hotspot/src/os_cpu/solaris_sparc/vm/globals_solaris_sparc.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/os_cpu/solaris_sparc/vm/globals_solaris_sparc.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,16 +30,16 @@
// (see globals.hpp)
//
-define_pd_global(uintx, JVMInvokeMethodSlack, 12288);
+define_pd_global(size_t, JVMInvokeMethodSlack, 12288);
define_pd_global(intx, CompilerThreadStackSize, 0);
// Used on 64 bit platforms for UseCompressedOops base address
#ifdef _LP64
// use 6G as default base address because by default the OS maps the application
// to 4G on Solaris-Sparc. This leaves at least 2G for the native heap.
-define_pd_global(uintx, HeapBaseMinAddress, CONST64(6)*G);
+define_pd_global(size_t, HeapBaseMinAddress, CONST64(6)*G);
#else
-define_pd_global(uintx, HeapBaseMinAddress, 2*G);
+define_pd_global(size_t, HeapBaseMinAddress, 2*G);
#endif
--- a/hotspot/src/os_cpu/solaris_x86/vm/globals_solaris_x86.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/os_cpu/solaris_x86/vm/globals_solaris_x86.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,18 +32,18 @@
#ifdef AMD64
define_pd_global(intx, ThreadStackSize, 1024); // 0 => use system default
define_pd_global(intx, VMThreadStackSize, 1024);
-define_pd_global(uintx,JVMInvokeMethodSlack, 8*K);
+define_pd_global(size_t, JVMInvokeMethodSlack, 8*K);
#else
// ThreadStackSize 320 allows a couple of test cases to run while
// keeping the number of threads that can be created high.
define_pd_global(intx, ThreadStackSize, 320);
define_pd_global(intx, VMThreadStackSize, 512);
-define_pd_global(uintx,JVMInvokeMethodSlack, 10*K);
+define_pd_global(size_t, JVMInvokeMethodSlack, 10*K);
#endif // AMD64
define_pd_global(intx, CompilerThreadStackSize, 0);
// Used on 64 bit platforms for UseCompressedOops base address
-define_pd_global(uintx,HeapBaseMinAddress, 2*G);
+define_pd_global(size_t, HeapBaseMinAddress, 2*G);
#endif // OS_CPU_SOLARIS_X86_VM_GLOBALS_SOLARIS_X86_HPP
--- a/hotspot/src/os_cpu/windows_x86/vm/globals_windows_x86.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/os_cpu/windows_x86/vm/globals_windows_x86.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -43,9 +43,9 @@
define_pd_global(intx, CompilerThreadStackSize, 0);
#endif
-define_pd_global(uintx, JVMInvokeMethodSlack, 8192);
+define_pd_global(size_t, JVMInvokeMethodSlack, 8192);
// Used on 64 bit platforms for UseCompressedOops base address
-define_pd_global(uintx, HeapBaseMinAddress, 2*G);
+define_pd_global(size_t, HeapBaseMinAddress, 2*G);
#endif // OS_CPU_WINDOWS_X86_VM_GLOBALS_WINDOWS_X86_HPP
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -1421,7 +1421,6 @@
// Do the pre-write barrier, if any.
switch (_bs->kind()) {
#if INCLUDE_ALL_GCS
- case BarrierSet::G1SATBCT:
case BarrierSet::G1SATBCTLogging:
G1SATBCardTableModRef_pre_barrier(addr_opr, pre_val, do_load, patch, info);
break;
@@ -1442,7 +1441,6 @@
void LIRGenerator::post_barrier(LIR_OprDesc* addr, LIR_OprDesc* new_val) {
switch (_bs->kind()) {
#if INCLUDE_ALL_GCS
- case BarrierSet::G1SATBCT:
case BarrierSet::G1SATBCTLogging:
G1SATBCardTableModRef_post_barrier(addr, new_val);
break;
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -52,9 +52,10 @@
}
void ConcurrentMarkSweepPolicy::initialize_generations() {
- _generations = NEW_C_HEAP_ARRAY(GenerationSpecPtr, number_of_generations(), mtGC);
- _generations[0] = new GenerationSpec(Generation::ParNew, _initial_young_size, _max_young_size);
- _generations[1] = new GenerationSpec(Generation::ConcurrentMarkSweep, _initial_old_size, _max_old_size);
+ _young_gen_spec = new GenerationSpec(Generation::ParNew, _initial_young_size,
+ _max_young_size, _gen_alignment);
+ _old_gen_spec = new GenerationSpec(Generation::ConcurrentMarkSweep,
+ _initial_old_size, _max_old_size, _gen_alignment);
}
void ConcurrentMarkSweepPolicy::initialize_size_policy(size_t init_eden_size,
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -186,7 +186,7 @@
cp->space->set_compaction_top(compact_top);
cp->space = cp->space->next_compaction_space();
if (cp->space == NULL) {
- cp->gen = GenCollectedHeap::heap()->prev_gen(cp->gen);
+ cp->gen = GenCollectedHeap::heap()->young_gen();
assert(cp->gen != NULL, "compaction must succeed");
cp->space = cp->gen->first_compaction_space();
assert(cp->space != NULL, "generation must have a first compaction space");
@@ -900,7 +900,6 @@
}
}
-
// Callers of this iterator beware: The closure application should
// be robust in the face of uninitialized objects and should (always)
// return a correct size so that the next addr + size below gives us a
@@ -2663,8 +2662,8 @@
// Need to smooth wrt historical average
if (ResizeOldPLAB) {
_blocks_to_claim[i].sample(
- MAX2((size_t)CMSOldPLABMin,
- MIN2((size_t)CMSOldPLABMax,
+ MAX2(CMSOldPLABMin,
+ MIN2(CMSOldPLABMax,
_global_num_blocks[i]/(_global_num_workers[i]*CMSOldPLABNumRefills))));
}
// Reset counters for next round
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,9 @@
// space, in this case a CompactibleFreeListSpace.
// Forward declarations
+class CMSCollector;
class CompactibleFreeListSpace;
+class ConcurrentMarkSweepGeneration;
class BlkClosure;
class BlkClosureCareful;
class FreeChunk;
@@ -396,6 +398,10 @@
// Resizing support
void set_end(HeapWord* value); // override
+ // Never mangle CompactibleFreeListSpace
+ void mangle_unused_area() {}
+ void mangle_unused_area_complete() {}
+
// Mutual exclusion support
Mutex* freelistLock() const { return &_freelistLock; }
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -65,8 +65,6 @@
#include "services/memoryService.hpp"
#include "services/runtimeService.hpp"
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
// statics
CMSCollector* ConcurrentMarkSweepGeneration::_collector = NULL;
bool CMSCollector::_full_gc_requested = false;
@@ -369,7 +367,7 @@
double CMSStats::time_until_cms_gen_full() const {
size_t cms_free = _cms_gen->cmsSpace()->free();
GenCollectedHeap* gch = GenCollectedHeap::heap();
- size_t expected_promotion = MIN2(gch->get_gen(0)->capacity(),
+ size_t expected_promotion = MIN2(gch->young_gen()->capacity(),
(size_t) _cms_gen->gc_stats()->avg_promoted()->padded_average());
if (cms_free > expected_promotion) {
// Start a cms collection if there isn't enough space to promote
@@ -506,7 +504,7 @@
_collector_policy(cp),
_should_unload_classes(CMSClassUnloadingEnabled),
_concurrent_cycles_since_last_unload(0),
- _roots_scanning_options(SharedHeap::SO_None),
+ _roots_scanning_options(GenCollectedHeap::SO_None),
_inter_sweep_estimate(CMS_SweepWeight, CMS_SweepPadding),
_intra_sweep_estimate(CMS_SweepWeight, CMS_SweepPadding),
_gc_tracer_cm(new (ResourceObj::C_HEAP, mtGC) CMSTracer()),
@@ -626,8 +624,8 @@
// Support for parallelizing young gen rescan
GenCollectedHeap* gch = GenCollectedHeap::heap();
- assert(gch->prev_gen(_cmsGen)->kind() == Generation::ParNew, "CMS can only be used with ParNew");
- _young_gen = (ParNewGeneration*)gch->prev_gen(_cmsGen);
+ assert(gch->young_gen()->kind() == Generation::ParNew, "CMS can only be used with ParNew");
+ _young_gen = (ParNewGeneration*)gch->young_gen();
if (gch->supports_inline_contig_alloc()) {
_top_addr = gch->top_addr();
_end_addr = gch->end_addr();
@@ -869,7 +867,7 @@
if (prev_level >= 0) {
size_t prev_size = 0;
GenCollectedHeap* gch = GenCollectedHeap::heap();
- Generation* prev_gen = gch->get_gen(prev_level);
+ Generation* prev_gen = gch->young_gen();
prev_size = prev_gen->capacity();
gclog_or_tty->print_cr(" Younger gen size "SIZE_FORMAT,
prev_size/1000);
@@ -1049,11 +1047,8 @@
// expand and retry
size_t s = _cmsSpace->expansionSpaceRequired(obj_size); // HeapWords
expand_for_gc_cause(s*HeapWordSize, MinHeapDeltaBytes, CMSExpansionCause::_satisfy_promotion);
- // Since there's currently no next generation, we don't try to promote
+ // Since this is the old generation, we don't try to promote
// into a more senior generation.
- assert(next_gen() == NULL, "assumption, based upon which no attempt "
- "is made to pass on a possibly failing "
- "promotion to next generation");
res = _cmsSpace->promote(obj, obj_size);
}
if (res != NULL) {
@@ -1596,7 +1591,7 @@
bitMapLock()->lock_without_safepoint_check();
if (TraceCMSState) {
gclog_or_tty->print_cr("CMS foreground collector has asked for control "
- INTPTR_FORMAT " with first state %d", Thread::current(), first_state);
+ INTPTR_FORMAT " with first state %d", p2i(Thread::current()), first_state);
gclog_or_tty->print_cr(" gets control with state %d", _collectorState);
}
@@ -1766,27 +1761,27 @@
// Eden
if (_eden_chunk_array != NULL) {
gclog_or_tty->print_cr("eden " PTR_FORMAT "-" PTR_FORMAT "-" PTR_FORMAT "(" SIZE_FORMAT ")",
- eden_space->bottom(), eden_space->top(),
- eden_space->end(), eden_space->capacity());
+ p2i(eden_space->bottom()), p2i(eden_space->top()),
+ p2i(eden_space->end()), eden_space->capacity());
gclog_or_tty->print_cr("_eden_chunk_index=" SIZE_FORMAT ", "
"_eden_chunk_capacity=" SIZE_FORMAT,
_eden_chunk_index, _eden_chunk_capacity);
for (size_t i = 0; i < _eden_chunk_index; i++) {
gclog_or_tty->print_cr("_eden_chunk_array[" SIZE_FORMAT "]=" PTR_FORMAT,
- i, _eden_chunk_array[i]);
+ i, p2i(_eden_chunk_array[i]));
}
}
// Survivor
if (_survivor_chunk_array != NULL) {
gclog_or_tty->print_cr("survivor " PTR_FORMAT "-" PTR_FORMAT "-" PTR_FORMAT "(" SIZE_FORMAT ")",
- from_space->bottom(), from_space->top(),
- from_space->end(), from_space->capacity());
+ p2i(from_space->bottom()), p2i(from_space->top()),
+ p2i(from_space->end()), from_space->capacity());
gclog_or_tty->print_cr("_survivor_chunk_index=" SIZE_FORMAT ", "
"_survivor_chunk_capacity=" SIZE_FORMAT,
_survivor_chunk_index, _survivor_chunk_capacity);
for (size_t i = 0; i < _survivor_chunk_index; i++) {
gclog_or_tty->print_cr("_survivor_chunk_array[" SIZE_FORMAT "]=" PTR_FORMAT,
- i, _survivor_chunk_array[i]);
+ i, p2i(_survivor_chunk_array[i]));
}
}
}
@@ -1893,7 +1888,7 @@
while (_collectorState != Idling) {
if (TraceCMSState) {
gclog_or_tty->print_cr("Thread " INTPTR_FORMAT " in CMS state %d",
- Thread::current(), _collectorState);
+ p2i(Thread::current()), _collectorState);
}
// The foreground collector
// holds the Heap_lock throughout its collection.
@@ -1927,7 +1922,7 @@
if (TraceCMSState) {
gclog_or_tty->print_cr("CMS Thread " INTPTR_FORMAT
" exiting collection CMS state %d",
- Thread::current(), _collectorState);
+ p2i(Thread::current()), _collectorState);
}
return;
} else {
@@ -2034,7 +2029,7 @@
}
if (TraceCMSState) {
gclog_or_tty->print_cr(" Thread " INTPTR_FORMAT " done - next CMS state %d",
- Thread::current(), _collectorState);
+ p2i(Thread::current()), _collectorState);
}
assert(_foregroundGCShouldWait, "block post-condition");
}
@@ -2057,7 +2052,7 @@
if (TraceCMSState) {
gclog_or_tty->print_cr("CMS Thread " INTPTR_FORMAT
" exiting collection CMS state %d",
- Thread::current(), _collectorState);
+ p2i(Thread::current()), _collectorState);
}
if (PrintGC && Verbose) {
_cmsGen->print_heap_change(prev_used);
@@ -2115,7 +2110,7 @@
CGC_lock->notify();
if (TraceCMSState) {
gclog_or_tty->print_cr("CMS Thread " INTPTR_FORMAT " waiting at CMS state %d",
- Thread::current(), _collectorState);
+ p2i(Thread::current()), _collectorState);
}
while (_foregroundGCIsActive) {
CGC_lock->wait(Mutex::_no_safepoint_check_flag);
@@ -2127,7 +2122,7 @@
}
if (TraceCMSState) {
gclog_or_tty->print_cr("CMS Thread " INTPTR_FORMAT " continuing at CMS state %d",
- Thread::current(), _collectorState);
+ p2i(Thread::current()), _collectorState);
}
return res;
}
@@ -2359,13 +2354,13 @@
// Clear the marking bit map array before starting, but, just
// for kicks, first report if the given address is already marked
- gclog_or_tty->print_cr("Start: Address " PTR_FORMAT " is%s marked", addr,
+ gclog_or_tty->print_cr("Start: Address " PTR_FORMAT " is%s marked", p2i(addr),
_markBitMap.isMarked(addr) ? "" : " not");
if (verify_after_remark()) {
MutexLockerEx x(verification_mark_bm()->lock(), Mutex::_no_safepoint_check_flag);
bool result = verification_mark_bm()->isMarked(addr);
- gclog_or_tty->print_cr("TransitiveMark: Address " PTR_FORMAT " %s marked", addr,
+ gclog_or_tty->print_cr("TransitiveMark: Address " PTR_FORMAT " %s marked", p2i(addr),
result ? "IS" : "is NOT");
return result;
} else {
@@ -2380,13 +2375,13 @@
CMSCollector* collector = ConcurrentMarkSweepGeneration::_collector;
if (collector != NULL) {
CMSBitMap* bitmap = &collector->_markBitMap;
- st->print_cr("Marking Bits: (CMSBitMap*) " PTR_FORMAT, bitmap);
+ st->print_cr("Marking Bits: (CMSBitMap*) " PTR_FORMAT, p2i(bitmap));
bitmap->print_on_error(st, " Bits: ");
st->cr();
CMSBitMap* mut_bitmap = &collector->_modUnionTable;
- st->print_cr("Mod Union Table: (CMSBitMap*) " PTR_FORMAT, mut_bitmap);
+ st->print_cr("Mod Union Table: (CMSBitMap*) " PTR_FORMAT, p2i(mut_bitmap));
mut_bitmap->print_on_error(st, " Bits: ");
}
}
@@ -2409,7 +2404,7 @@
HeapWord* addr = _marks->offsetToHeapWord(offset);
if (!_marks->isMarked(addr)) {
oop(addr)->print_on(gclog_or_tty);
- gclog_or_tty->print_cr(" ("INTPTR_FORMAT" should have been marked)", addr);
+ gclog_or_tty->print_cr(" ("INTPTR_FORMAT" should have been marked)", p2i(addr));
_failed = true;
}
return true;
@@ -2477,7 +2472,7 @@
// presumably, a mutation to A failed to be picked up by preclean/remark?
verify_after_remark_work_2();
} else {
- warning("Unrecognized value %d for CMSRemarkVerifyVariant",
+ warning("Unrecognized value " UINTX_FORMAT " for CMSRemarkVerifyVariant",
CMSRemarkVerifyVariant);
}
if (!silent) gclog_or_tty->print(" done] ");
@@ -2499,7 +2494,7 @@
gch->gen_process_roots(_cmsGen->level(),
true, // younger gens are roots
true, // activate StrongRootsScope
- SharedHeap::ScanningOption(roots_scanning_options()),
+ GenCollectedHeap::ScanningOption(roots_scanning_options()),
should_unload_classes(),
¬Older,
NULL,
@@ -2567,7 +2562,7 @@
gch->gen_process_roots(_cmsGen->level(),
true, // younger gens are roots
true, // activate StrongRootsScope
- SharedHeap::ScanningOption(roots_scanning_options()),
+ GenCollectedHeap::ScanningOption(roots_scanning_options()),
should_unload_classes(),
¬Older,
NULL,
@@ -2751,7 +2746,7 @@
void CMSCollector::setup_cms_unloading_and_verification_state() {
const bool should_verify = VerifyBeforeGC || VerifyAfterGC || VerifyDuringGC
|| VerifyBeforeExit;
- const int rso = SharedHeap::SO_AllCodeCache;
+ const int rso = GenCollectedHeap::SO_AllCodeCache;
// We set the proper root for this CMS cycle here.
if (should_unload_classes()) { // Should unload classes this cycle
@@ -3000,7 +2995,6 @@
report_heap_summary(GCWhen::BeforeGC);
ReferenceProcessor* rp = ref_processor();
- SpecializationStats::clear();
assert(_restart_addr == NULL, "Control point invariant");
{
// acquire locks for subsequent manipulations
@@ -3011,7 +3005,6 @@
rp->enable_discovery();
_collectorState = Marking;
}
- SpecializationStats::print();
}
void CMSCollector::checkpointRootsInitialWork() {
@@ -3092,7 +3085,7 @@
gch->gen_process_roots(_cmsGen->level(),
true, // younger gens are roots
true, // activate StrongRootsScope
- SharedHeap::ScanningOption(roots_scanning_options()),
+ GenCollectedHeap::ScanningOption(roots_scanning_options()),
should_unload_classes(),
¬Older,
NULL,
@@ -4329,7 +4322,6 @@
verify_work_stacks_empty();
verify_overflow_empty();
- SpecializationStats::clear();
if (PrintGCDetails) {
gclog_or_tty->print("[YG occupancy: "SIZE_FORMAT" K ("SIZE_FORMAT" K)]",
_young_gen->used() / K,
@@ -4360,7 +4352,6 @@
}
verify_work_stacks_empty();
verify_overflow_empty();
- SpecializationStats::print();
}
void CMSCollector::checkpointRootsFinalWork() {
@@ -4528,13 +4519,13 @@
gch->gen_process_roots(_collector->_cmsGen->level(),
false, // yg was scanned above
false, // this is parallel code
- SharedHeap::ScanningOption(_collector->CMSCollector::roots_scanning_options()),
+ GenCollectedHeap::ScanningOption(_collector->CMSCollector::roots_scanning_options()),
_collector->should_unload_classes(),
&par_mri_cl,
NULL,
&cld_closure);
assert(_collector->should_unload_classes()
- || (_collector->CMSCollector::roots_scanning_options() & SharedHeap::SO_AllCodeCache),
+ || (_collector->CMSCollector::roots_scanning_options() & GenCollectedHeap::SO_AllCodeCache),
"if we didn't scan the code cache, we have to be ready to drop nmethods with expired weak oops");
_timer.stop();
if (PrintCMSStatistics != 0) {
@@ -4664,14 +4655,14 @@
gch->gen_process_roots(_collector->_cmsGen->level(),
false, // yg was scanned above
false, // this is parallel code
- SharedHeap::ScanningOption(_collector->CMSCollector::roots_scanning_options()),
+ GenCollectedHeap::ScanningOption(_collector->CMSCollector::roots_scanning_options()),
_collector->should_unload_classes(),
&par_mrias_cl,
NULL,
NULL); // The dirty klasses will be handled below
assert(_collector->should_unload_classes()
- || (_collector->CMSCollector::roots_scanning_options() & SharedHeap::SO_AllCodeCache),
+ || (_collector->CMSCollector::roots_scanning_options() & GenCollectedHeap::SO_AllCodeCache),
"if we didn't scan the code cache, we have to be ready to drop nmethods with expired weak oops");
_timer.stop();
if (PrintCMSStatistics != 0) {
@@ -5063,7 +5054,7 @@
for (size_t i = 0; i < total - 1; i++) {
if (PrintCMSStatistics > 0) {
gclog_or_tty->print(" (chunk" SIZE_FORMAT ":" INTPTR_FORMAT ") ",
- i, _survivor_chunk_array[i]);
+ i, p2i(_survivor_chunk_array[i]));
}
assert(_survivor_chunk_array[i] < _survivor_chunk_array[i+1],
"Not sorted");
@@ -5255,14 +5246,14 @@
gch->gen_process_roots(_cmsGen->level(),
true, // younger gens as roots
false, // use the local StrongRootsScope
- SharedHeap::ScanningOption(roots_scanning_options()),
+ GenCollectedHeap::ScanningOption(roots_scanning_options()),
should_unload_classes(),
&mrias_cl,
NULL,
NULL); // The dirty klasses will be handled below
assert(should_unload_classes()
- || (roots_scanning_options() & SharedHeap::SO_AllCodeCache),
+ || (roots_scanning_options() & GenCollectedHeap::SO_AllCodeCache),
"if we didn't scan the code cache, we have to be ready to drop nmethods with expired weak oops");
}
@@ -5707,8 +5698,8 @@
gclog_or_tty->print_cr(
"CMS: Large Block: " PTR_FORMAT ";"
" Proximity: " PTR_FORMAT " -> " PTR_FORMAT,
- largestAddr,
- _cmsSpace->nearLargestChunk(), minAddr + nearLargestOffset);
+ p2i(largestAddr),
+ p2i(_cmsSpace->nearLargestChunk()), p2i(minAddr + nearLargestOffset));
}
_cmsSpace->set_nearLargestChunk(minAddr + nearLargestOffset);
}
@@ -6191,7 +6182,7 @@
_verification_bm->mark(addr);
if (!_cms_bm->isMarked(addr)) {
oop(addr)->print();
- gclog_or_tty->print_cr(" (" INTPTR_FORMAT " should have been marked)", addr);
+ gclog_or_tty->print_cr(" (" INTPTR_FORMAT " should have been marked)", p2i(addr));
fatal("... aborting");
}
}
@@ -6986,7 +6977,7 @@
if (!_cms_bm->isMarked(addr)) {
oop(addr)->print();
gclog_or_tty->print_cr(" (" INTPTR_FORMAT " should have been marked)",
- addr);
+ p2i(addr));
fatal("... aborting");
}
@@ -7382,16 +7373,16 @@
"sweep _limit out of bounds");
if (CMSTraceSweeper) {
gclog_or_tty->print_cr("\n====================\nStarting new sweep with limit " PTR_FORMAT,
- _limit);
+ p2i(_limit));
}
}
void SweepClosure::print_on(outputStream* st) const {
tty->print_cr("_sp = [" PTR_FORMAT "," PTR_FORMAT ")",
- _sp->bottom(), _sp->end());
- tty->print_cr("_limit = " PTR_FORMAT, _limit);
- tty->print_cr("_freeFinger = " PTR_FORMAT, _freeFinger);
- NOT_PRODUCT(tty->print_cr("_last_fc = " PTR_FORMAT, _last_fc);)
+ p2i(_sp->bottom()), p2i(_sp->end()));
+ tty->print_cr("_limit = " PTR_FORMAT, p2i(_limit));
+ tty->print_cr("_freeFinger = " PTR_FORMAT, p2i(_freeFinger));
+ NOT_PRODUCT(tty->print_cr("_last_fc = " PTR_FORMAT, p2i(_last_fc));)
tty->print_cr("_inFreeRange = %d, _freeRangeInFreeLists = %d, _lastFreeRangeCoalesced = %d",
_inFreeRange, _freeRangeInFreeLists, _lastFreeRangeCoalesced);
}
@@ -7435,7 +7426,7 @@
}
if (CMSTraceSweeper) {
gclog_or_tty->print_cr("end of sweep with _limit = " PTR_FORMAT "\n================",
- _limit);
+ p2i(_limit));
}
}
#endif // PRODUCT
@@ -7444,7 +7435,7 @@
bool freeRangeInFreeLists) {
if (CMSTraceSweeper) {
gclog_or_tty->print("---- Start free range at " PTR_FORMAT " with free block (%d)\n",
- freeFinger, freeRangeInFreeLists);
+ p2i(freeFinger), freeRangeInFreeLists);
}
assert(!inFreeRange(), "Trampling existing free range");
set_inFreeRange(true);
@@ -7508,14 +7499,14 @@
// coalesced chunk to the appropriate free list.
if (inFreeRange()) {
assert(freeFinger() >= _sp->bottom() && freeFinger() < _limit,
- err_msg("freeFinger() " PTR_FORMAT" is out-of-bounds", freeFinger()));
+ err_msg("freeFinger() " PTR_FORMAT" is out-of-bounds", p2i(freeFinger())));
flush_cur_free_chunk(freeFinger(),
pointer_delta(addr, freeFinger()));
if (CMSTraceSweeper) {
gclog_or_tty->print("Sweep: last chunk: ");
gclog_or_tty->print("put_free_blk " PTR_FORMAT " ("SIZE_FORMAT") "
"[coalesced:%d]\n",
- freeFinger(), pointer_delta(addr, freeFinger()),
+ p2i(freeFinger()), pointer_delta(addr, freeFinger()),
lastFreeRangeCoalesced() ? 1 : 0);
}
}
@@ -7659,7 +7650,7 @@
// the midst of a free range, we are coalescing
print_free_block_coalesced(fc);
if (CMSTraceSweeper) {
- gclog_or_tty->print(" -- pick up free block " PTR_FORMAT " (" SIZE_FORMAT ")\n", fc, size);
+ gclog_or_tty->print(" -- pick up free block " PTR_FORMAT " (" SIZE_FORMAT ")\n", p2i(fc), size);
}
// remove it from the free lists
_sp->removeFreeChunkFromFreeLists(fc);
@@ -7721,7 +7712,7 @@
// this will be swept up when we hit the end of the
// free range
if (CMSTraceSweeper) {
- gclog_or_tty->print(" -- pick up garbage " PTR_FORMAT " (" SIZE_FORMAT ")\n", fc, size);
+ gclog_or_tty->print(" -- pick up garbage " PTR_FORMAT " (" SIZE_FORMAT ")\n", p2i(fc), size);
}
// If the chunk is being coalesced and the current free range is
// in the free lists, remove the current free range so that it
@@ -7814,7 +7805,7 @@
}
if (CMSTraceSweeper) {
- gclog_or_tty->print_cr(" -- pick up another chunk at " PTR_FORMAT " (" SIZE_FORMAT ")", fc, chunkSize);
+ gclog_or_tty->print_cr(" -- pick up another chunk at " PTR_FORMAT " (" SIZE_FORMAT ")", p2i(fc), chunkSize);
}
HeapWord* const fc_addr = (HeapWord*) fc;
@@ -7913,14 +7904,14 @@
err_msg("eob = " PTR_FORMAT " eob-1 = " PTR_FORMAT " _limit = " PTR_FORMAT
" out of bounds wrt _sp = [" PTR_FORMAT "," PTR_FORMAT ")"
" when examining fc = " PTR_FORMAT "(" SIZE_FORMAT ")",
- eob, eob-1, _limit, _sp->bottom(), _sp->end(), fc, chunk_size));
+ p2i(eob), p2i(eob-1), p2i(_limit), p2i(_sp->bottom()), p2i(_sp->end()), p2i(fc), chunk_size));
if (eob >= _limit) {
assert(eob == _limit || fc->is_free(), "Only a free chunk should allow us to cross over the limit");
if (CMSTraceSweeper) {
gclog_or_tty->print_cr("_limit " PTR_FORMAT " reached or crossed by block "
"[" PTR_FORMAT "," PTR_FORMAT ") in space "
"[" PTR_FORMAT "," PTR_FORMAT ")",
- _limit, fc, eob, _sp->bottom(), _sp->end());
+ p2i(_limit), p2i(fc), p2i(eob), p2i(_sp->bottom()), p2i(_sp->end()));
}
// Return the storage we are tracking back into the free lists.
if (CMSTraceSweeper) {
@@ -7944,7 +7935,7 @@
}
if (CMSTraceSweeper) {
gclog_or_tty->print_cr(" -- add free block " PTR_FORMAT " (" SIZE_FORMAT ") to free lists",
- chunk, size);
+ p2i(chunk), size);
}
// A new free range is going to be starting. The current
// free range has not been added to the free lists yet or
@@ -8017,7 +8008,7 @@
void SweepClosure::print_free_block_coalesced(FreeChunk* fc) const {
if (CMSTraceSweeper) {
gclog_or_tty->print_cr("Sweep:coal_free_blk " PTR_FORMAT " (" SIZE_FORMAT ")",
- fc, fc->size());
+ p2i(fc), fc->size());
}
}
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
#ifndef SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_CONCURRENTMARKSWEEPGENERATION_HPP
#define SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_CONCURRENTMARKSWEEPGENERATION_HPP
+#include "gc_implementation/concurrentMarkSweep/cmsOopClosures.hpp"
#include "gc_implementation/shared/gcHeapSummary.hpp"
#include "gc_implementation/shared/gSpaceCounters.hpp"
#include "gc_implementation/shared/gcStats.hpp"
@@ -55,6 +56,7 @@
// means of a sliding mark-compact.
class AdaptiveSizePolicy;
+class CMSCollector;
class CMSConcMarkingTask;
class CMSGCAdaptivePolicyCounters;
class CMSTracer;
@@ -64,6 +66,7 @@
class ConcurrentMarkSweepThread;
class CompactibleFreeListSpace;
class FreeChunk;
+class ParNewGeneration;
class PromotionInfo;
class ScanMarkedObjectsAgainCarefullyClosure;
class TenuredGeneration;
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/freeChunk.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/freeChunk.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -27,8 +27,6 @@
#include "memory/freeBlockDictionary.hpp"
#include "utilities/copy.hpp"
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
#ifndef PRODUCT
#define baadbabeHeapWord badHeapWordVal
@@ -74,5 +72,5 @@
void FreeChunk::print_on(outputStream* st) {
st->print_cr("Next: " PTR_FORMAT " Prev: " PTR_FORMAT " %s",
- next(), prev(), cantCoalesce() ? "[can't coalesce]" : "");
+ p2i(next()), p2i(prev()), cantCoalesce() ? "[can't coalesce]" : "");
}
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/promotionInfo.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/promotionInfo.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -28,8 +28,6 @@
#include "oops/markOop.inline.hpp"
#include "oops/oop.inline.hpp"
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
/////////////////////////////////////////////////////////////////////////
//// PromotionInfo
/////////////////////////////////////////////////////////////////////////
@@ -360,6 +358,6 @@
void SpoolBlock::print_on(outputStream* st) const {
st->print("[" PTR_FORMAT "," PTR_FORMAT "), " SIZE_FORMAT " HeapWords -> " PTR_FORMAT,
- this, (HeapWord*)displacedHdr + bufferSize,
- bufferSize, nextSpoolBlock);
+ p2i(this), p2i((HeapWord*)displacedHdr + bufferSize),
+ bufferSize, p2i(nextSpoolBlock));
}
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -34,8 +34,6 @@
#include "runtime/os.hpp"
#include "utilities/dtrace.hpp"
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
//////////////////////////////////////////////////////////
// Methods in abstract class VM_CMS_Operation
//////////////////////////////////////////////////////////
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -696,32 +696,32 @@
}
if (FLAG_IS_DEFAULT(MarkStackSize)) {
- uintx mark_stack_size =
+ size_t mark_stack_size =
MIN2(MarkStackSizeMax,
- MAX2(MarkStackSize, (uintx) (parallel_marking_threads() * TASKQUEUE_SIZE)));
+ MAX2(MarkStackSize, (size_t) (parallel_marking_threads() * TASKQUEUE_SIZE)));
// Verify that the calculated value for MarkStackSize is in range.
// It would be nice to use the private utility routine from Arguments.
if (!(mark_stack_size >= 1 && mark_stack_size <= MarkStackSizeMax)) {
- warning("Invalid value calculated for MarkStackSize (" UINTX_FORMAT "): "
- "must be between " UINTX_FORMAT " and " UINTX_FORMAT,
- mark_stack_size, (uintx) 1, MarkStackSizeMax);
+ warning("Invalid value calculated for MarkStackSize (" SIZE_FORMAT "): "
+ "must be between 1 and " SIZE_FORMAT,
+ mark_stack_size, MarkStackSizeMax);
return;
}
- FLAG_SET_ERGO(uintx, MarkStackSize, mark_stack_size);
+ FLAG_SET_ERGO(size_t, MarkStackSize, mark_stack_size);
} else {
// Verify MarkStackSize is in range.
if (FLAG_IS_CMDLINE(MarkStackSize)) {
if (FLAG_IS_DEFAULT(MarkStackSizeMax)) {
if (!(MarkStackSize >= 1 && MarkStackSize <= MarkStackSizeMax)) {
- warning("Invalid value specified for MarkStackSize (" UINTX_FORMAT "): "
- "must be between " UINTX_FORMAT " and " UINTX_FORMAT,
- MarkStackSize, (uintx) 1, MarkStackSizeMax);
+ warning("Invalid value specified for MarkStackSize (" SIZE_FORMAT "): "
+ "must be between 1 and " SIZE_FORMAT,
+ MarkStackSize, MarkStackSizeMax);
return;
}
} else if (FLAG_IS_CMDLINE(MarkStackSizeMax)) {
if (!(MarkStackSize >= 1 && MarkStackSize <= MarkStackSizeMax)) {
- warning("Invalid value specified for MarkStackSize (" UINTX_FORMAT ")"
- " or for MarkStackSizeMax (" UINTX_FORMAT ")",
+ warning("Invalid value specified for MarkStackSize (" SIZE_FORMAT ")"
+ " or for MarkStackSizeMax (" SIZE_FORMAT ")",
MarkStackSize, MarkStackSizeMax);
return;
}
@@ -745,7 +745,7 @@
// so that the assertion in MarkingTaskQueue::task_queue doesn't fail
_active_tasks = _max_worker_id;
- size_t max_regions = (size_t) _g1h->max_regions();
+ uint max_regions = _g1h->max_regions();
for (uint i = 0; i < _max_worker_id; ++i) {
CMTaskQueue* task_queue = new CMTaskQueue();
task_queue->initialize();
@@ -2088,10 +2088,7 @@
_cleanup_times.add((end - start) * 1000.0);
if (G1Log::fine()) {
- g1h->print_size_transition(gclog_or_tty,
- start_used_bytes,
- g1h->used(),
- g1h->capacity());
+ g1h->g1_policy()->print_heap_transition(start_used_bytes);
}
// Clean up will have freed any regions completely full of garbage.
@@ -2584,7 +2581,7 @@
public:
G1RemarkThreadsClosure(G1CollectedHeap* g1h, CMTask* task) :
_cm_obj(task), _cm_cl(g1h, g1h->concurrent_mark(), task), _code_cl(&_cm_cl, !CodeBlobToOopClosure::FixRelocations),
- _thread_parity(SharedHeap::heap()->strong_roots_parity()) {}
+ _thread_parity(Threads::thread_claim_parity()) {}
void do_thread(Thread* thread) {
if (thread->is_Java_thread()) {
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -34,6 +34,7 @@
class G1CollectedHeap;
class CMBitMap;
class CMTask;
+class ConcurrentMark;
typedef GenericTaskQueue<oop, mtGC> CMTaskQueue;
typedef GenericTaskQueueSet<CMTaskQueue, mtGC> CMTaskQueueSet;
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CardCounts.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CardCounts.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -31,8 +31,6 @@
#include "services/memTracker.hpp"
#include "utilities/copy.hpp"
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
void G1CardCountsMappingChangedListener::on_commit(uint start_idx, size_t num_regions, bool zero_filled) {
if (zero_filled) {
return;
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CodeCacheRemSet.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CodeCacheRemSet.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -33,8 +33,6 @@
#include "utilities/hashtable.inline.hpp"
#include "utilities/stack.inline.hpp"
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
class CodeRootSetTable : public Hashtable<nmethod*, mtGC> {
friend class G1CodeRootSetTest;
typedef HashtableEntry<nmethod*, mtGC> Entry;
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -48,6 +48,7 @@
#include "gc_implementation/g1/g1ParScanThreadState.inline.hpp"
#include "gc_implementation/g1/g1RegionToSpaceMapper.hpp"
#include "gc_implementation/g1/g1RemSet.inline.hpp"
+#include "gc_implementation/g1/g1RootProcessor.hpp"
#include "gc_implementation/g1/g1StringDedup.hpp"
#include "gc_implementation/g1/g1YCTypes.hpp"
#include "gc_implementation/g1/heapRegion.inline.hpp"
@@ -65,7 +66,6 @@
#include "memory/iterator.hpp"
#include "memory/referenceProcessor.hpp"
#include "oops/oop.inline.hpp"
-#include "oops/oop.pcgc.inline.hpp"
#include "runtime/atomic.inline.hpp"
#include "runtime/orderAccess.inline.hpp"
#include "runtime/vmThread.hpp"
@@ -89,18 +89,6 @@
// apply to TLAB allocation, which is not part of this interface: it
// is done by clients of this interface.)
-// Notes on implementation of parallelism in different tasks.
-//
-// G1ParVerifyTask uses heap_region_par_iterate() for parallelism.
-// The number of GC workers is passed to heap_region_par_iterate().
-// It does use run_task() which sets _n_workers in the task.
-// G1ParTask executes g1_process_roots() ->
-// SharedHeap::process_roots() which calls eventually to
-// CardTableModRefBS::par_non_clean_card_iterate_work() which uses
-// SequentialSubTasksDone. SharedHeap::process_roots() also
-// directly uses SubTasksDone (_process_strong_tasks field in SharedHeap).
-//
-
// Local to this file.
class RefineCardTableEntryClosure: public CardTableEntryClosure {
@@ -414,25 +402,6 @@
return hr;
}
-#ifdef ASSERT
-// A region is added to the collection set as it is retired
-// so an address p can point to a region which will be in the
-// collection set but has not yet been retired. This method
-// therefore is only accurate during a GC pause after all
-// regions have been retired. It is used for debugging
-// to check if an nmethod has references to objects that can
-// be move during a partial collection. Though it can be
-// inaccurate, it is sufficient for G1 because the conservative
-// implementation of is_scavengable() for G1 will indicate that
-// all nmethods must be scanned during a partial collection.
-bool G1CollectedHeap::is_in_partial_collection(const void* p) {
- if (p == NULL) {
- return false;
- }
- return heap_region_containing(p)->in_collection_set();
-}
-#endif
-
// Returns true if the reference points to an object that
// can move in an incremental collection.
bool G1CollectedHeap::is_scavengable(const void* p) {
@@ -1759,7 +1728,7 @@
G1CollectedHeap::G1CollectedHeap(G1CollectorPolicy* policy_) :
- SharedHeap(policy_),
+ SharedHeap(),
_g1_policy(policy_),
_dirty_card_queue_set(false),
_into_cset_dirty_card_queue_set(false),
@@ -1767,7 +1736,6 @@
_is_alive_closure_stw(this),
_ref_processor_cm(NULL),
_ref_processor_stw(NULL),
- _process_strong_tasks(new SubTasksDone(G1H_PS_NumElements)),
_bot_shared(NULL),
_evac_failure_scan_stack(NULL),
_mark_in_progress(false),
@@ -1801,9 +1769,6 @@
_gc_tracer_cm(new (ResourceObj::C_HEAP, mtGC) G1OldTracer()) {
_g1h = this;
- if (_process_strong_tasks == NULL || !_process_strong_tasks->valid()) {
- vm_exit_during_initialization("Failed necessary allocation.");
- }
_allocator = G1Allocator::create_allocator(_g1h);
_humongous_object_threshold_in_words = HeapRegion::GrainWords / 2;
@@ -2026,10 +1991,6 @@
Shared_DirtyCardQ_lock,
&JavaThread::dirty_card_queue_set());
- // In case we're keeping closure specialization stats, initialize those
- // counts and that mechanism.
- SpecializationStats::clear();
-
// Here we allocate the dummy HeapRegion that is required by the
// G1AllocRegion class.
HeapRegion* dummy_region = _hrm.get_dummy_region();
@@ -2206,11 +2167,11 @@
hot_card_cache->drain(worker_i, g1_rem_set(), into_cset_dcq);
DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
- int n_completed_buffers = 0;
+ size_t n_completed_buffers = 0;
while (dcqs.apply_closure_to_completed_buffer(cl, worker_i, 0, true)) {
n_completed_buffers++;
}
- g1_policy()->phase_times()->record_update_rs_processed_buffers(worker_i, n_completed_buffers);
+ g1_policy()->phase_times()->record_thread_work_item(G1GCPhaseTimes::UpdateRS, worker_i, n_completed_buffers);
dcqs.clear_n_completed_buffers();
assert(!dcqs.completed_buffers_exist_dirty(), "Completed buffers exist!");
}
@@ -3111,11 +3072,12 @@
G1VerifyCodeRootOopClosure codeRootsCl(this, &rootsCl, vo);
G1VerifyCodeRootBlobClosure blobsCl(&codeRootsCl);
- process_all_roots(true, // activate StrongRootsScope
- SO_AllCodeCache, // roots scanning options
- &rootsCl,
- &cldCl,
- &blobsCl);
+ {
+ G1RootProcessor root_processor(this);
+ root_processor.process_all_roots(&rootsCl,
+ &cldCl,
+ &blobsCl);
+ }
bool failures = rootsCl.failures() || codeRootsCl.failures();
@@ -3321,7 +3283,6 @@
concurrent_mark()->print_summary_info();
}
g1_policy()->print_yg_surv_rate_info();
- SpecializationStats::print();
}
#ifndef PRODUCT
@@ -3751,9 +3712,16 @@
TraceCPUTime tcpu(G1Log::finer(), true, gclog_or_tty);
- int active_workers = workers()->active_workers();
+ uint active_workers = AdaptiveSizePolicy::calc_active_workers(workers()->total_workers(),
+ workers()->active_workers(),
+ Threads::number_of_non_daemon_threads());
+ assert(UseDynamicNumberOfGCThreads ||
+ active_workers == workers()->total_workers(),
+ "If not dynamic should be using all the workers");
+ workers()->set_active_workers(active_workers);
+
double pause_start_sec = os::elapsedTime();
- g1_policy()->phase_times()->note_gc_start(active_workers);
+ g1_policy()->phase_times()->note_gc_start(active_workers, mark_in_progress());
log_gc_header();
TraceCollectorStats tcs(g1mm()->incremental_collection_counters());
@@ -4365,60 +4333,11 @@
}
};
-class G1CodeBlobClosure : public CodeBlobClosure {
- class HeapRegionGatheringOopClosure : public OopClosure {
- G1CollectedHeap* _g1h;
- OopClosure* _work;
- nmethod* _nm;
-
- template <typename T>
- void do_oop_work(T* p) {
- _work->do_oop(p);
- T oop_or_narrowoop = oopDesc::load_heap_oop(p);
- if (!oopDesc::is_null(oop_or_narrowoop)) {
- oop o = oopDesc::decode_heap_oop_not_null(oop_or_narrowoop);
- HeapRegion* hr = _g1h->heap_region_containing_raw(o);
- assert(!_g1h->obj_in_cs(o) || hr->rem_set()->strong_code_roots_list_contains(_nm), "if o still in CS then evacuation failed and nm must already be in the remset");
- hr->add_strong_code_root(_nm);
- }
- }
-
- public:
- HeapRegionGatheringOopClosure(OopClosure* oc) : _g1h(G1CollectedHeap::heap()), _work(oc), _nm(NULL) {}
-
- void do_oop(oop* o) {
- do_oop_work(o);
- }
-
- void do_oop(narrowOop* o) {
- do_oop_work(o);
- }
-
- void set_nm(nmethod* nm) {
- _nm = nm;
- }
- };
-
- HeapRegionGatheringOopClosure _oc;
-public:
- G1CodeBlobClosure(OopClosure* oc) : _oc(oc) {}
-
- void do_code_blob(CodeBlob* cb) {
- nmethod* nm = cb->as_nmethod_or_null();
- if (nm != NULL) {
- if (!nm->test_set_oops_do_mark()) {
- _oc.set_nm(nm);
- nm->oops_do(&_oc);
- nm->fix_oop_relocations();
- }
- }
- }
-};
-
class G1ParTask : public AbstractGangTask {
protected:
G1CollectedHeap* _g1h;
RefToScanQueueSet *_queues;
+ G1RootProcessor* _root_processor;
ParallelTaskTerminator _terminator;
uint _n_workers;
@@ -4426,10 +4345,11 @@
Mutex* stats_lock() { return &_stats_lock; }
public:
- G1ParTask(G1CollectedHeap* g1h, RefToScanQueueSet *task_queues)
+ G1ParTask(G1CollectedHeap* g1h, RefToScanQueueSet *task_queues, G1RootProcessor* root_processor)
: AbstractGangTask("G1 collection"),
_g1h(g1h),
_queues(task_queues),
+ _root_processor(root_processor),
_terminator(0, _queues),
_stats_lock(Mutex::leaf, "parallel G1 stats lock", true)
{}
@@ -4443,13 +4363,7 @@
ParallelTaskTerminator* terminator() { return &_terminator; }
virtual void set_for_termination(int active_workers) {
- // This task calls set_n_termination() in par_non_clean_card_iterate_work()
- // in the young space (_par_seq_tasks) in the G1 heap
- // for SequentialSubTasksDone.
- // This task also uses SubTasksDone in SharedHeap and G1CollectedHeap
- // both of which need setting by set_n_termination().
- _g1h->SharedHeap::set_n_termination(active_workers);
- _g1h->set_n_termination(active_workers);
+ _root_processor->set_num_workers(active_workers);
terminator()->reset_for_reuse(active_workers);
_n_workers = active_workers;
}
@@ -4486,8 +4400,7 @@
void work(uint worker_id) {
if (worker_id >= _n_workers) return; // no work needed this round
- double start_time_ms = os::elapsedTime() * 1000.0;
- _g1h->g1_policy()->phase_times()->record_gc_worker_start_time(worker_id, start_time_ms);
+ _g1h->g1_policy()->phase_times()->record_time_secs(G1GCPhaseTimes::GCWorkerStart, worker_id, os::elapsedTime());
{
ResourceMark rm;
@@ -4519,24 +4432,21 @@
false, // Process all klasses.
true); // Need to claim CLDs.
- G1CodeBlobClosure scan_only_code_cl(&scan_only_root_cl);
- G1CodeBlobClosure scan_mark_code_cl(&scan_mark_root_cl);
- // IM Weak code roots are handled later.
-
OopClosure* strong_root_cl;
OopClosure* weak_root_cl;
CLDClosure* strong_cld_cl;
CLDClosure* weak_cld_cl;
- CodeBlobClosure* strong_code_cl;
+
+ bool trace_metadata = false;
if (_g1h->g1_policy()->during_initial_mark_pause()) {
// We also need to mark copied objects.
strong_root_cl = &scan_mark_root_cl;
strong_cld_cl = &scan_mark_cld_cl;
- strong_code_cl = &scan_mark_code_cl;
if (ClassUnloadingWithConcurrentMark) {
weak_root_cl = &scan_mark_weak_root_cl;
weak_cld_cl = &scan_mark_weak_cld_cl;
+ trace_metadata = true;
} else {
weak_root_cl = &scan_mark_root_cl;
weak_cld_cl = &scan_mark_cld_cl;
@@ -4546,31 +4456,32 @@
weak_root_cl = &scan_only_root_cl;
strong_cld_cl = &scan_only_cld_cl;
weak_cld_cl = &scan_only_cld_cl;
- strong_code_cl = &scan_only_code_cl;
}
-
- G1ParPushHeapRSClosure push_heap_rs_cl(_g1h, &pss);
-
pss.start_strong_roots();
- _g1h->g1_process_roots(strong_root_cl,
- weak_root_cl,
- &push_heap_rs_cl,
- strong_cld_cl,
- weak_cld_cl,
- strong_code_cl,
- worker_id);
-
+
+ _root_processor->evacuate_roots(strong_root_cl,
+ weak_root_cl,
+ strong_cld_cl,
+ weak_cld_cl,
+ trace_metadata,
+ worker_id);
+
+ G1ParPushHeapRSClosure push_heap_rs_cl(_g1h, &pss);
+ _root_processor->scan_remembered_sets(&push_heap_rs_cl,
+ weak_root_cl,
+ worker_id);
pss.end_strong_roots();
{
double start = os::elapsedTime();
G1ParEvacuateFollowersClosure evac(_g1h, &pss, _queues, &_terminator);
evac.do_void();
- double elapsed_ms = (os::elapsedTime()-start)*1000.0;
- double term_ms = pss.term_time()*1000.0;
- _g1h->g1_policy()->phase_times()->add_obj_copy_time(worker_id, elapsed_ms-term_ms);
- _g1h->g1_policy()->phase_times()->record_termination(worker_id, term_ms, pss.term_attempts());
+ double elapsed_sec = os::elapsedTime() - start;
+ double term_sec = pss.term_time();
+ _g1h->g1_policy()->phase_times()->add_time_secs(G1GCPhaseTimes::ObjCopy, worker_id, elapsed_sec - term_sec);
+ _g1h->g1_policy()->phase_times()->record_time_secs(G1GCPhaseTimes::Termination, worker_id, term_sec);
+ _g1h->g1_policy()->phase_times()->record_thread_work_item(G1GCPhaseTimes::Termination, worker_id, pss.term_attempts());
}
_g1h->g1_policy()->record_thread_age_table(pss.age_table());
_g1h->update_surviving_young_words(pss.surviving_young_words()+1);
@@ -4586,100 +4497,10 @@
// destructors are executed here and are included as part of the
// "GC Worker Time".
}
-
- double end_time_ms = os::elapsedTime() * 1000.0;
- _g1h->g1_policy()->phase_times()->record_gc_worker_end_time(worker_id, end_time_ms);
+ _g1h->g1_policy()->phase_times()->record_time_secs(G1GCPhaseTimes::GCWorkerEnd, worker_id, os::elapsedTime());
}
};
-// *** Common G1 Evacuation Stuff
-
-// This method is run in a GC worker.
-
-void
-G1CollectedHeap::
-g1_process_roots(OopClosure* scan_non_heap_roots,
- OopClosure* scan_non_heap_weak_roots,
- G1ParPushHeapRSClosure* scan_rs,
- CLDClosure* scan_strong_clds,
- CLDClosure* scan_weak_clds,
- CodeBlobClosure* scan_strong_code,
- uint worker_i) {
-
- // First scan the shared roots.
- double ext_roots_start = os::elapsedTime();
- double closure_app_time_sec = 0.0;
-
- bool during_im = _g1h->g1_policy()->during_initial_mark_pause();
- bool trace_metadata = during_im && ClassUnloadingWithConcurrentMark;
-
- BufferingOopClosure buf_scan_non_heap_roots(scan_non_heap_roots);
- BufferingOopClosure buf_scan_non_heap_weak_roots(scan_non_heap_weak_roots);
-
- process_roots(false, // no scoping; this is parallel code
- SharedHeap::SO_None,
- &buf_scan_non_heap_roots,
- &buf_scan_non_heap_weak_roots,
- scan_strong_clds,
- // Unloading Initial Marks handle the weak CLDs separately.
- (trace_metadata ? NULL : scan_weak_clds),
- scan_strong_code);
-
- // Now the CM ref_processor roots.
- if (!_process_strong_tasks->is_task_claimed(G1H_PS_refProcessor_oops_do)) {
- // We need to treat the discovered reference lists of the
- // concurrent mark ref processor as roots and keep entries
- // (which are added by the marking threads) on them live
- // until they can be processed at the end of marking.
- ref_processor_cm()->weak_oops_do(&buf_scan_non_heap_roots);
- }
-
- if (trace_metadata) {
- // Barrier to make sure all workers passed
- // the strong CLD and strong nmethods phases.
- active_strong_roots_scope()->wait_until_all_workers_done_with_threads(n_par_threads());
-
- // Now take the complement of the strong CLDs.
- ClassLoaderDataGraph::roots_cld_do(NULL, scan_weak_clds);
- }
-
- // Finish up any enqueued closure apps (attributed as object copy time).
- buf_scan_non_heap_roots.done();
- buf_scan_non_heap_weak_roots.done();
-
- double obj_copy_time_sec = buf_scan_non_heap_roots.closure_app_seconds()
- + buf_scan_non_heap_weak_roots.closure_app_seconds();
-
- g1_policy()->phase_times()->record_obj_copy_time(worker_i, obj_copy_time_sec * 1000.0);
-
- double ext_root_time_ms =
- ((os::elapsedTime() - ext_roots_start) - obj_copy_time_sec) * 1000.0;
-
- g1_policy()->phase_times()->record_ext_root_scan_time(worker_i, ext_root_time_ms);
-
- // During conc marking we have to filter the per-thread SATB buffers
- // to make sure we remove any oops into the CSet (which will show up
- // as implicitly live).
- double satb_filtering_ms = 0.0;
- if (!_process_strong_tasks->is_task_claimed(G1H_PS_filter_satb_buffers)) {
- if (mark_in_progress()) {
- double satb_filter_start = os::elapsedTime();
-
- JavaThread::satb_mark_queue_set().filter_thread_buffers();
-
- satb_filtering_ms = (os::elapsedTime() - satb_filter_start) * 1000.0;
- }
- }
- g1_policy()->phase_times()->record_satb_filtering_time(worker_i, satb_filtering_ms);
-
- // Now scan the complement of the collection set.
- G1CodeBlobClosure scavenge_cs_nmethods(scan_non_heap_weak_roots);
-
- g1_rem_set()->oops_into_collection_set_do(scan_rs, &scavenge_cs_nmethods, worker_i);
-
- _process_strong_tasks->all_tasks_completed();
-}
-
class G1StringSymbolTableUnlinkTask : public AbstractGangTask {
private:
BoolObjectClosure* _is_alive;
@@ -5054,14 +4875,13 @@
G1RedirtyLoggedCardsTask(DirtyCardQueueSet* queue) : AbstractGangTask("Redirty Cards"), _queue(queue) { }
virtual void work(uint worker_id) {
- double start_time = os::elapsedTime();
+ G1GCPhaseTimes* phase_times = G1CollectedHeap::heap()->g1_policy()->phase_times();
+ G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::RedirtyCards, worker_id);
RedirtyLoggedCardTableEntryClosure cl;
_queue->par_apply_closure_to_all_completed_buffers(&cl);
- G1GCPhaseTimes* timer = G1CollectedHeap::heap()->g1_policy()->phase_times();
- timer->record_redirty_logged_cards_time_ms(worker_id, (os::elapsedTime() - start_time) * 1000.0);
- timer->record_redirty_logged_cards_processed_cards(worker_id, cl.num_processed());
+ phase_times->record_thread_work_item(G1GCPhaseTimes::RedirtyCards, worker_id, cl.num_processed());
}
};
@@ -5597,18 +5417,12 @@
hot_card_cache->reset_hot_cache_claimed_index();
hot_card_cache->set_use_cache(false);
- uint n_workers;
- n_workers =
- AdaptiveSizePolicy::calc_active_workers(workers()->total_workers(),
- workers()->active_workers(),
- Threads::number_of_non_daemon_threads());
+ const uint n_workers = workers()->active_workers();
assert(UseDynamicNumberOfGCThreads ||
n_workers == workers()->total_workers(),
"If not dynamic should be using all the workers");
- workers()->set_active_workers(n_workers);
set_par_threads(n_workers);
- G1ParTask g1_par_task(this, _task_queues);
init_for_evac_failure(NULL);
@@ -5617,7 +5431,8 @@
double end_par_time_sec;
{
- StrongRootsScope srs(this);
+ G1RootProcessor root_processor(this);
+ G1ParTask g1_par_task(this, _task_queues, &root_processor);
// InitialMark needs claim bits to keep track of the marked-through CLDs.
if (g1_policy()->during_initial_mark_pause()) {
ClassLoaderDataGraph::clear_claimed_marks();
@@ -5633,18 +5448,20 @@
end_par_time_sec = os::elapsedTime();
// Closing the inner scope will execute the destructor
- // for the StrongRootsScope object. We record the current
+ // for the G1RootProcessor object. We record the current
// elapsed time before closing the scope so that time
- // taken for the SRS destructor is NOT included in the
+ // taken for the destructor is NOT included in the
// reported parallel time.
}
+ G1GCPhaseTimes* phase_times = g1_policy()->phase_times();
+
double par_time_ms = (end_par_time_sec - start_par_time_sec) * 1000.0;
- g1_policy()->phase_times()->record_par_time(par_time_ms);
+ phase_times->record_par_time(par_time_ms);
double code_root_fixup_time_ms =
(os::elapsedTime() - end_par_time_sec) * 1000.0;
- g1_policy()->phase_times()->record_code_root_fixup_time(code_root_fixup_time_ms);
+ phase_times->record_code_root_fixup_time(code_root_fixup_time_ms);
set_par_threads(0);
@@ -5656,9 +5473,14 @@
process_discovered_references(n_workers);
if (G1StringDedup::is_enabled()) {
+ double fixup_start = os::elapsedTime();
+
G1STWIsAliveClosure is_alive(this);
G1KeepAliveClosure keep_alive(this);
- G1StringDedup::unlink_or_oops_do(&is_alive, &keep_alive);
+ G1StringDedup::unlink_or_oops_do(&is_alive, &keep_alive, true, phase_times);
+
+ double fixup_time_ms = (os::elapsedTime() - fixup_start) * 1000.0;
+ phase_times->record_string_dedup_fixup_time(fixup_time_ms);
}
_allocator->release_gc_alloc_regions(n_workers, evacuation_info);
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -56,6 +56,7 @@
class GenerationSpec;
class OopsInHeapRegionClosure;
class G1KlassScanClosure;
+class G1ParScanThreadState;
class ObjectClosure;
class SpaceClosure;
class CompactibleSpaceClosure;
@@ -780,22 +781,6 @@
// statistics or updating free lists.
void abandon_collection_set(HeapRegion* cs_head);
- // Applies "scan_non_heap_roots" to roots outside the heap,
- // "scan_rs" to roots inside the heap (having done "set_region" to
- // indicate the region in which the root resides),
- // and does "scan_metadata" If "scan_rs" is
- // NULL, then this step is skipped. The "worker_i"
- // param is for use with parallel roots processing, and should be
- // the "i" of the calling parallel worker thread's work(i) function.
- // In the sequential case this param will be ignored.
- void g1_process_roots(OopClosure* scan_non_heap_roots,
- OopClosure* scan_non_heap_weak_roots,
- G1ParPushHeapRSClosure* scan_rs,
- CLDClosure* scan_strong_clds,
- CLDClosure* scan_weak_clds,
- CodeBlobClosure* scan_strong_code,
- uint worker_i);
-
// The concurrent marker (and the thread it runs in.)
ConcurrentMark* _cm;
ConcurrentMarkThread* _cmThread;
@@ -982,21 +967,10 @@
// of G1CollectedHeap::_gc_time_stamp.
uint* _worker_cset_start_region_time_stamp;
- enum G1H_process_roots_tasks {
- G1H_PS_filter_satb_buffers,
- G1H_PS_refProcessor_oops_do,
- // Leave this one last.
- G1H_PS_NumElements
- };
-
- SubTasksDone* _process_strong_tasks;
-
volatile bool _free_regions_coming;
public:
- SubTasksDone* process_strong_tasks() { return _process_strong_tasks; }
-
void set_refine_cte_cl_concurrency(bool concurrent);
RefToScanQueue *task_queue(int i) const;
@@ -1029,22 +1003,12 @@
// Initialize weak reference processing.
virtual void ref_processing_init();
- void set_par_threads(uint t) {
- SharedHeap::set_par_threads(t);
- // Done in SharedHeap but oddly there are
- // two _process_strong_tasks's in a G1CollectedHeap
- // so do it here too.
- _process_strong_tasks->set_n_threads(t);
- }
-
+ // Explicitly import set_par_threads into this scope
+ using SharedHeap::set_par_threads;
// Set _n_par_threads according to a policy TBD.
void set_par_threads();
- void set_n_termination(int t) {
- _process_strong_tasks->set_n_threads(t);
- }
-
- virtual CollectedHeap::Name kind() const {
+ virtual Name kind() const {
return CollectedHeap::G1CollectedHeap;
}
@@ -1118,6 +1082,10 @@
// The number of regions that are completely free.
uint num_free_regions() const { return _hrm.num_free_regions(); }
+ MemoryUsage get_auxiliary_data_memory_usage() const {
+ return _hrm.get_auxiliary_data_memory_usage();
+ }
+
// The number of regions that are not completely free.
uint num_used_regions() const { return num_regions() - num_free_regions(); }
@@ -1411,10 +1379,6 @@
inline bool is_in_young(const oop obj);
-#ifdef ASSERT
- virtual bool is_in_partial_collection(const void* p);
-#endif
-
virtual bool is_scavengable(const void* addr);
// We don't need barriers for initializing stores to objects
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -321,7 +321,7 @@
void G1CollectorPolicy::initialize_flags() {
if (G1HeapRegionSize != HeapRegion::GrainBytes) {
- FLAG_SET_ERGO(uintx, G1HeapRegionSize, HeapRegion::GrainBytes);
+ FLAG_SET_ERGO(size_t, G1HeapRegionSize, HeapRegion::GrainBytes);
}
if (SurvivorRatio < 1) {
@@ -335,7 +335,7 @@
uintx max_regions = G1CollectedHeap::heap()->max_regions();
size_t max_young_size = (size_t)_young_gen_sizer->max_young_length(max_regions) * HeapRegion::GrainBytes;
if (max_young_size != MaxNewSize) {
- FLAG_SET_ERGO(uintx, MaxNewSize, max_young_size);
+ FLAG_SET_ERGO(size_t, MaxNewSize, max_young_size);
}
}
@@ -1073,7 +1073,7 @@
if (update_stats) {
double cost_per_card_ms = 0.0;
if (_pending_cards > 0) {
- cost_per_card_ms = phase_times()->average_last_update_rs_time() / (double) _pending_cards;
+ cost_per_card_ms = phase_times()->average_time_ms(G1GCPhaseTimes::UpdateRS) / (double) _pending_cards;
_cost_per_card_ms_seq->add(cost_per_card_ms);
}
@@ -1081,7 +1081,7 @@
double cost_per_entry_ms = 0.0;
if (cards_scanned > 10) {
- cost_per_entry_ms = phase_times()->average_last_scan_rs_time() / (double) cards_scanned;
+ cost_per_entry_ms = phase_times()->average_time_ms(G1GCPhaseTimes::ScanRS) / (double) cards_scanned;
if (_last_gc_was_young) {
_cost_per_entry_ms_seq->add(cost_per_entry_ms);
} else {
@@ -1123,7 +1123,7 @@
double cost_per_byte_ms = 0.0;
if (copied_bytes > 0) {
- cost_per_byte_ms = phase_times()->average_last_obj_copy_time() / (double) copied_bytes;
+ cost_per_byte_ms = phase_times()->average_time_ms(G1GCPhaseTimes::ObjCopy) / (double) copied_bytes;
if (_in_marking_window) {
_cost_per_byte_ms_during_cm_seq->add(cost_per_byte_ms);
} else {
@@ -1132,8 +1132,8 @@
}
double all_other_time_ms = pause_time_ms -
- (phase_times()->average_last_update_rs_time() + phase_times()->average_last_scan_rs_time()
- + phase_times()->average_last_obj_copy_time() + phase_times()->average_last_termination_time());
+ (phase_times()->average_time_ms(G1GCPhaseTimes::UpdateRS) + phase_times()->average_time_ms(G1GCPhaseTimes::ScanRS) +
+ phase_times()->average_time_ms(G1GCPhaseTimes::ObjCopy) + phase_times()->average_time_ms(G1GCPhaseTimes::Termination));
double young_other_time_ms = 0.0;
if (young_cset_region_length() > 0) {
@@ -1174,8 +1174,8 @@
// Note that _mmu_tracker->max_gc_time() returns the time in seconds.
double update_rs_time_goal_ms = _mmu_tracker->max_gc_time() * MILLIUNITS * G1RSetUpdatingPauseTimePercent / 100.0;
- adjust_concurrent_refinement(phase_times()->average_last_update_rs_time(),
- phase_times()->sum_last_update_rs_processed_buffers(), update_rs_time_goal_ms);
+ adjust_concurrent_refinement(phase_times()->average_time_ms(G1GCPhaseTimes::UpdateRS),
+ phase_times()->sum_thread_work_items(G1GCPhaseTimes::UpdateRS), update_rs_time_goal_ms);
_collectionSetChooser->verify();
}
@@ -1201,11 +1201,21 @@
}
}
+void G1CollectorPolicy::print_heap_transition(size_t bytes_before) {
+ size_t bytes_after = _g1->used();
+ size_t capacity = _g1->capacity();
+
+ gclog_or_tty->print(" " SIZE_FORMAT "%s->" SIZE_FORMAT "%s(" SIZE_FORMAT "%s)",
+ byte_size_in_proper_unit(bytes_before),
+ proper_unit_for_byte_size(bytes_before),
+ byte_size_in_proper_unit(bytes_after),
+ proper_unit_for_byte_size(bytes_after),
+ byte_size_in_proper_unit(capacity),
+ proper_unit_for_byte_size(capacity));
+}
+
void G1CollectorPolicy::print_heap_transition() {
- _g1->print_size_transition(gclog_or_tty,
- _heap_used_bytes_before_gc,
- _g1->used(),
- _g1->capacity());
+ print_heap_transition(_heap_used_bytes_before_gc);
}
void G1CollectorPolicy::print_detailed_heap_transition(bool full) {
@@ -2114,19 +2124,19 @@
_other.add(pause_time_ms - phase_times->accounted_time_ms());
_root_region_scan_wait.add(phase_times->root_region_scan_wait_time_ms());
_parallel.add(phase_times->cur_collection_par_time_ms());
- _ext_root_scan.add(phase_times->average_last_ext_root_scan_time());
- _satb_filtering.add(phase_times->average_last_satb_filtering_times_ms());
- _update_rs.add(phase_times->average_last_update_rs_time());
- _scan_rs.add(phase_times->average_last_scan_rs_time());
- _obj_copy.add(phase_times->average_last_obj_copy_time());
- _termination.add(phase_times->average_last_termination_time());
+ _ext_root_scan.add(phase_times->average_time_ms(G1GCPhaseTimes::ExtRootScan));
+ _satb_filtering.add(phase_times->average_time_ms(G1GCPhaseTimes::SATBFiltering));
+ _update_rs.add(phase_times->average_time_ms(G1GCPhaseTimes::UpdateRS));
+ _scan_rs.add(phase_times->average_time_ms(G1GCPhaseTimes::ScanRS));
+ _obj_copy.add(phase_times->average_time_ms(G1GCPhaseTimes::ObjCopy));
+ _termination.add(phase_times->average_time_ms(G1GCPhaseTimes::Termination));
- double parallel_known_time = phase_times->average_last_ext_root_scan_time() +
- phase_times->average_last_satb_filtering_times_ms() +
- phase_times->average_last_update_rs_time() +
- phase_times->average_last_scan_rs_time() +
- phase_times->average_last_obj_copy_time() +
- + phase_times->average_last_termination_time();
+ double parallel_known_time = phase_times->average_time_ms(G1GCPhaseTimes::ExtRootScan) +
+ phase_times->average_time_ms(G1GCPhaseTimes::SATBFiltering) +
+ phase_times->average_time_ms(G1GCPhaseTimes::UpdateRS) +
+ phase_times->average_time_ms(G1GCPhaseTimes::ScanRS) +
+ phase_times->average_time_ms(G1GCPhaseTimes::ObjCopy) +
+ phase_times->average_time_ms(G1GCPhaseTimes::Termination);
double parallel_other_time = phase_times->cur_collection_par_time_ms() - parallel_known_time;
_parallel_other.add(parallel_other_time);
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -700,6 +700,8 @@
void record_heap_size_info_at_start(bool full);
// Print heap sizing transition (with less and more detail).
+
+ void print_heap_transition(size_t bytes_before);
void print_heap_transition();
void print_detailed_heap_transition(bool full = false);
--- a/hotspot/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -22,13 +22,13 @@
*
*/
-
#include "precompiled.hpp"
#include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
#include "gc_implementation/g1/g1GCPhaseTimes.hpp"
#include "gc_implementation/g1/g1Log.hpp"
#include "gc_implementation/g1/g1StringDedup.hpp"
-#include "runtime/atomic.inline.hpp"
+#include "memory/allocation.hpp"
+#include "runtime/os.hpp"
// Helper class for avoiding interleaved logging
class LineBuffer: public StackObj {
@@ -71,184 +71,260 @@
va_end(ap);
}
+ void print_cr() {
+ gclog_or_tty->print_cr("%s", _buffer);
+ _cur = _indent_level * INDENT_CHARS;
+ }
+
void append_and_print_cr(const char* format, ...) ATTRIBUTE_PRINTF(2, 3) {
va_list ap;
va_start(ap, format);
vappend(format, ap);
va_end(ap);
- gclog_or_tty->print_cr("%s", _buffer);
- _cur = _indent_level * INDENT_CHARS;
+ print_cr();
}
};
-PRAGMA_DIAG_PUSH
-PRAGMA_FORMAT_NONLITERAL_IGNORED
template <class T>
-void WorkerDataArray<T>::print(int level, const char* title) {
- if (_length == 1) {
- // No need for min, max, average and sum for only one worker
- LineBuffer buf(level);
- buf.append("[%s: ", title);
- buf.append(_print_format, _data[0]);
- buf.append_and_print_cr("]");
- return;
+class WorkerDataArray : public CHeapObj<mtGC> {
+ friend class G1GCParPhasePrinter;
+ T* _data;
+ uint _length;
+ const char* _title;
+ bool _print_sum;
+ int _log_level;
+ uint _indent_level;
+ bool _enabled;
+
+ WorkerDataArray<size_t>* _thread_work_items;
+
+ NOT_PRODUCT(T uninitialized();)
+
+ // We are caching the sum and average to only have to calculate them once.
+ // This is not done in an MT-safe way. It is intended to allow single
+ // threaded code to call sum() and average() multiple times in any order
+ // without having to worry about the cost.
+ bool _has_new_data;
+ T _sum;
+ T _min;
+ T _max;
+ double _average;
+
+ public:
+ WorkerDataArray(uint length, const char* title, bool print_sum, int log_level, uint indent_level) :
+ _title(title), _length(0), _print_sum(print_sum), _log_level(log_level), _indent_level(indent_level),
+ _has_new_data(true), _thread_work_items(NULL), _enabled(true) {
+ assert(length > 0, "Must have some workers to store data for");
+ _length = length;
+ _data = NEW_C_HEAP_ARRAY(T, _length, mtGC);
+ }
+
+ ~WorkerDataArray() {
+ FREE_C_HEAP_ARRAY(T, _data);
+ }
+
+ void link_thread_work_items(WorkerDataArray<size_t>* thread_work_items) {
+ _thread_work_items = thread_work_items;
+ }
+
+ WorkerDataArray<size_t>* thread_work_items() { return _thread_work_items; }
+
+ void set(uint worker_i, T value) {
+ assert(worker_i < _length, err_msg("Worker %d is greater than max: %d", worker_i, _length));
+ assert(_data[worker_i] == WorkerDataArray<T>::uninitialized(), err_msg("Overwriting data for worker %d in %s", worker_i, _title));
+ _data[worker_i] = value;
+ _has_new_data = true;
+ }
+
+ void set_thread_work_item(uint worker_i, size_t value) {
+ assert(_thread_work_items != NULL, "No sub count");
+ _thread_work_items->set(worker_i, value);
}
- T min = _data[0];
- T max = _data[0];
- T sum = 0;
+ T get(uint worker_i) {
+ assert(worker_i < _length, err_msg("Worker %d is greater than max: %d", worker_i, _length));
+ assert(_data[worker_i] != WorkerDataArray<T>::uninitialized(), err_msg("No data added for worker %d", worker_i));
+ return _data[worker_i];
+ }
+
+ void add(uint worker_i, T value) {
+ assert(worker_i < _length, err_msg("Worker %d is greater than max: %d", worker_i, _length));
+ assert(_data[worker_i] != WorkerDataArray<T>::uninitialized(), err_msg("No data to add to for worker %d", worker_i));
+ _data[worker_i] += value;
+ _has_new_data = true;
+ }
- LineBuffer buf(level);
- buf.append("[%s:", title);
- for (uint i = 0; i < _length; ++i) {
- T val = _data[i];
- min = MIN2(val, min);
- max = MAX2(val, max);
- sum += val;
- if (G1Log::finest()) {
- buf.append(" ");
- buf.append(_print_format, val);
- }
+ double average(uint active_threads){
+ calculate_totals(active_threads);
+ return _average;
+ }
+
+ T sum(uint active_threads) {
+ calculate_totals(active_threads);
+ return _sum;
+ }
+
+ T minimum(uint active_threads) {
+ calculate_totals(active_threads);
+ return _min;
}
- if (G1Log::finest()) {
- buf.append_and_print_cr("%s", "");
+ T maximum(uint active_threads) {
+ calculate_totals(active_threads);
+ return _max;
}
- double avg = (double)sum / (double)_length;
- buf.append(" Min: ");
- buf.append(_print_format, min);
- buf.append(", Avg: ");
- buf.append("%.1lf", avg); // Always print average as a double
- buf.append(", Max: ");
- buf.append(_print_format, max);
- buf.append(", Diff: ");
- buf.append(_print_format, max - min);
- if (_print_sum) {
- // for things like the start and end times the sum is not
- // that relevant
- buf.append(", Sum: ");
- buf.append(_print_format, sum);
+ void reset() PRODUCT_RETURN;
+ void verify(uint active_threads) PRODUCT_RETURN;
+
+ void set_enabled(bool enabled) { _enabled = enabled; }
+
+ int log_level() { return _log_level; }
+
+ private:
+
+ void calculate_totals(uint active_threads){
+ if (!_has_new_data) {
+ return;
+ }
+
+ _sum = (T)0;
+ _min = _data[0];
+ _max = _min;
+ assert(active_threads <= _length, "Wrong number of active threads");
+ for (uint i = 0; i < active_threads; ++i) {
+ T val = _data[i];
+ _sum += val;
+ _min = MIN2(_min, val);
+ _max = MAX2(_max, val);
+ }
+ _average = (double)_sum / (double)active_threads;
+ _has_new_data = false;
}
- buf.append_and_print_cr("]");
-}
-PRAGMA_DIAG_POP
+};
+
#ifndef PRODUCT
-template <> const int WorkerDataArray<int>::_uninitialized = -1;
-template <> const double WorkerDataArray<double>::_uninitialized = -1.0;
-template <> const size_t WorkerDataArray<size_t>::_uninitialized = (size_t)-1;
+template <>
+size_t WorkerDataArray<size_t>::uninitialized() {
+ return (size_t)-1;
+}
+
+template <>
+double WorkerDataArray<double>::uninitialized() {
+ return -1.0;
+}
template <class T>
void WorkerDataArray<T>::reset() {
for (uint i = 0; i < _length; i++) {
- _data[i] = (T)_uninitialized;
+ _data[i] = WorkerDataArray<T>::uninitialized();
+ }
+ if (_thread_work_items != NULL) {
+ _thread_work_items->reset();
}
}
template <class T>
-void WorkerDataArray<T>::verify() {
- for (uint i = 0; i < _length; i++) {
- assert(_data[i] != _uninitialized,
- err_msg("Invalid data for worker %u, data: %lf, uninitialized: %lf",
- i, (double)_data[i], (double)_uninitialized));
+void WorkerDataArray<T>::verify(uint active_threads) {
+ if (!_enabled) {
+ return;
+ }
+
+ assert(active_threads <= _length, "Wrong number of active threads");
+ for (uint i = 0; i < active_threads; i++) {
+ assert(_data[i] != WorkerDataArray<T>::uninitialized(),
+ err_msg("Invalid data for worker %u in '%s'", i, _title));
+ }
+ if (_thread_work_items != NULL) {
+ _thread_work_items->verify(active_threads);
}
}
#endif
G1GCPhaseTimes::G1GCPhaseTimes(uint max_gc_threads) :
- _max_gc_threads(max_gc_threads),
- _last_gc_worker_start_times_ms(_max_gc_threads, "%.1lf", false),
- _last_ext_root_scan_times_ms(_max_gc_threads, "%.1lf"),
- _last_satb_filtering_times_ms(_max_gc_threads, "%.1lf"),
- _last_update_rs_times_ms(_max_gc_threads, "%.1lf"),
- _last_update_rs_processed_buffers(_max_gc_threads, "%d"),
- _last_scan_rs_times_ms(_max_gc_threads, "%.1lf"),
- _last_strong_code_root_scan_times_ms(_max_gc_threads, "%.1lf"),
- _last_obj_copy_times_ms(_max_gc_threads, "%.1lf"),
- _last_termination_times_ms(_max_gc_threads, "%.1lf"),
- _last_termination_attempts(_max_gc_threads, SIZE_FORMAT),
- _last_gc_worker_end_times_ms(_max_gc_threads, "%.1lf", false),
- _last_gc_worker_times_ms(_max_gc_threads, "%.1lf"),
- _last_gc_worker_other_times_ms(_max_gc_threads, "%.1lf"),
- _last_redirty_logged_cards_time_ms(_max_gc_threads, "%.1lf"),
- _last_redirty_logged_cards_processed_cards(_max_gc_threads, SIZE_FORMAT),
- _cur_string_dedup_queue_fixup_worker_times_ms(_max_gc_threads, "%.1lf"),
- _cur_string_dedup_table_fixup_worker_times_ms(_max_gc_threads, "%.1lf")
+ _max_gc_threads(max_gc_threads)
{
assert(max_gc_threads > 0, "Must have some GC threads");
+
+ _gc_par_phases[GCWorkerStart] = new WorkerDataArray<double>(max_gc_threads, "GC Worker Start (ms)", false, G1Log::LevelFiner, 2);
+ _gc_par_phases[ExtRootScan] = new WorkerDataArray<double>(max_gc_threads, "Ext Root Scanning (ms)", true, G1Log::LevelFiner, 2);
+
+ // Root scanning phases
+ _gc_par_phases[ThreadRoots] = new WorkerDataArray<double>(max_gc_threads, "Thread Roots (ms)", true, G1Log::LevelFinest, 3);
+ _gc_par_phases[StringTableRoots] = new WorkerDataArray<double>(max_gc_threads, "StringTable Roots (ms)", true, G1Log::LevelFinest, 3);
+ _gc_par_phases[UniverseRoots] = new WorkerDataArray<double>(max_gc_threads, "Universe Roots (ms)", true, G1Log::LevelFinest, 3);
+ _gc_par_phases[JNIRoots] = new WorkerDataArray<double>(max_gc_threads, "JNI Handles Roots (ms)", true, G1Log::LevelFinest, 3);
+ _gc_par_phases[ObjectSynchronizerRoots] = new WorkerDataArray<double>(max_gc_threads, "ObjectSynchronizer Roots (ms)", true, G1Log::LevelFinest, 3);
+ _gc_par_phases[FlatProfilerRoots] = new WorkerDataArray<double>(max_gc_threads, "FlatProfiler Roots (ms)", true, G1Log::LevelFinest, 3);
+ _gc_par_phases[ManagementRoots] = new WorkerDataArray<double>(max_gc_threads, "Management Roots (ms)", true, G1Log::LevelFinest, 3);
+ _gc_par_phases[SystemDictionaryRoots] = new WorkerDataArray<double>(max_gc_threads, "SystemDictionary Roots (ms)", true, G1Log::LevelFinest, 3);
+ _gc_par_phases[CLDGRoots] = new WorkerDataArray<double>(max_gc_threads, "CLDG Roots (ms)", true, G1Log::LevelFinest, 3);
+ _gc_par_phases[JVMTIRoots] = new WorkerDataArray<double>(max_gc_threads, "JVMTI Roots (ms)", true, G1Log::LevelFinest, 3);
+ _gc_par_phases[CodeCacheRoots] = new WorkerDataArray<double>(max_gc_threads, "CodeCache Roots (ms)", true, G1Log::LevelFinest, 3);
+ _gc_par_phases[CMRefRoots] = new WorkerDataArray<double>(max_gc_threads, "CM RefProcessor Roots (ms)", true, G1Log::LevelFinest, 3);
+ _gc_par_phases[WaitForStrongCLD] = new WorkerDataArray<double>(max_gc_threads, "Wait For Strong CLD (ms)", true, G1Log::LevelFinest, 3);
+ _gc_par_phases[WeakCLDRoots] = new WorkerDataArray<double>(max_gc_threads, "Weak CLD Roots (ms)", true, G1Log::LevelFinest, 3);
+ _gc_par_phases[SATBFiltering] = new WorkerDataArray<double>(max_gc_threads, "SATB Filtering (ms)", true, G1Log::LevelFinest, 3);
+
+ _gc_par_phases[UpdateRS] = new WorkerDataArray<double>(max_gc_threads, "Update RS (ms)", true, G1Log::LevelFiner, 2);
+ _gc_par_phases[ScanRS] = new WorkerDataArray<double>(max_gc_threads, "Scan RS (ms)", true, G1Log::LevelFiner, 2);
+ _gc_par_phases[CodeRoots] = new WorkerDataArray<double>(max_gc_threads, "Code Root Scanning (ms)", true, G1Log::LevelFiner, 2);
+ _gc_par_phases[ObjCopy] = new WorkerDataArray<double>(max_gc_threads, "Object Copy (ms)", true, G1Log::LevelFiner, 2);
+ _gc_par_phases[Termination] = new WorkerDataArray<double>(max_gc_threads, "Termination (ms)", true, G1Log::LevelFiner, 2);
+ _gc_par_phases[GCWorkerTotal] = new WorkerDataArray<double>(max_gc_threads, "GC Worker Total (ms)", true, G1Log::LevelFiner, 2);
+ _gc_par_phases[GCWorkerEnd] = new WorkerDataArray<double>(max_gc_threads, "GC Worker End (ms)", false, G1Log::LevelFiner, 2);
+ _gc_par_phases[Other] = new WorkerDataArray<double>(max_gc_threads, "GC Worker Other (ms)", true, G1Log::LevelFiner, 2);
+
+ _update_rs_processed_buffers = new WorkerDataArray<size_t>(max_gc_threads, "Processed Buffers", true, G1Log::LevelFiner, 3);
+ _gc_par_phases[UpdateRS]->link_thread_work_items(_update_rs_processed_buffers);
+
+ _termination_attempts = new WorkerDataArray<size_t>(max_gc_threads, "Termination Attempts", true, G1Log::LevelFinest, 3);
+ _gc_par_phases[Termination]->link_thread_work_items(_termination_attempts);
+
+ _gc_par_phases[StringDedupQueueFixup] = new WorkerDataArray<double>(max_gc_threads, "Queue Fixup (ms)", true, G1Log::LevelFiner, 2);
+ _gc_par_phases[StringDedupTableFixup] = new WorkerDataArray<double>(max_gc_threads, "Table Fixup (ms)", true, G1Log::LevelFiner, 2);
+
+ _gc_par_phases[RedirtyCards] = new WorkerDataArray<double>(max_gc_threads, "Parallel Redirty", true, G1Log::LevelFinest, 3);
+ _redirtied_cards = new WorkerDataArray<size_t>(max_gc_threads, "Redirtied Cards", true, G1Log::LevelFinest, 3);
+ _gc_par_phases[RedirtyCards]->link_thread_work_items(_redirtied_cards);
}
-void G1GCPhaseTimes::note_gc_start(uint active_gc_threads) {
+void G1GCPhaseTimes::note_gc_start(uint active_gc_threads, bool mark_in_progress) {
assert(active_gc_threads > 0, "The number of threads must be > 0");
- assert(active_gc_threads <= _max_gc_threads, "The number of active threads must be <= the max nubmer of threads");
+ assert(active_gc_threads <= _max_gc_threads, "The number of active threads must be <= the max number of threads");
_active_gc_threads = active_gc_threads;
- _last_gc_worker_start_times_ms.reset();
- _last_ext_root_scan_times_ms.reset();
- _last_satb_filtering_times_ms.reset();
- _last_update_rs_times_ms.reset();
- _last_update_rs_processed_buffers.reset();
- _last_scan_rs_times_ms.reset();
- _last_strong_code_root_scan_times_ms.reset();
- _last_obj_copy_times_ms.reset();
- _last_termination_times_ms.reset();
- _last_termination_attempts.reset();
- _last_gc_worker_end_times_ms.reset();
- _last_gc_worker_times_ms.reset();
- _last_gc_worker_other_times_ms.reset();
+ for (int i = 0; i < GCParPhasesSentinel; i++) {
+ _gc_par_phases[i]->reset();
+ }
- _last_redirty_logged_cards_time_ms.reset();
- _last_redirty_logged_cards_processed_cards.reset();
-
+ _gc_par_phases[StringDedupQueueFixup]->set_enabled(G1StringDedup::is_enabled());
+ _gc_par_phases[StringDedupTableFixup]->set_enabled(G1StringDedup::is_enabled());
}
void G1GCPhaseTimes::note_gc_end() {
- _last_gc_worker_start_times_ms.verify();
- _last_ext_root_scan_times_ms.verify();
- _last_satb_filtering_times_ms.verify();
- _last_update_rs_times_ms.verify();
- _last_update_rs_processed_buffers.verify();
- _last_scan_rs_times_ms.verify();
- _last_strong_code_root_scan_times_ms.verify();
- _last_obj_copy_times_ms.verify();
- _last_termination_times_ms.verify();
- _last_termination_attempts.verify();
- _last_gc_worker_end_times_ms.verify();
+ for (uint i = 0; i < _active_gc_threads; i++) {
+ double worker_time = _gc_par_phases[GCWorkerEnd]->get(i) - _gc_par_phases[GCWorkerStart]->get(i);
+ record_time_secs(GCWorkerTotal, i , worker_time);
- for (uint i = 0; i < _active_gc_threads; i++) {
- double worker_time = _last_gc_worker_end_times_ms.get(i) - _last_gc_worker_start_times_ms.get(i);
- _last_gc_worker_times_ms.set(i, worker_time);
+ double worker_known_time =
+ _gc_par_phases[ExtRootScan]->get(i) +
+ _gc_par_phases[SATBFiltering]->get(i) +
+ _gc_par_phases[UpdateRS]->get(i) +
+ _gc_par_phases[ScanRS]->get(i) +
+ _gc_par_phases[CodeRoots]->get(i) +
+ _gc_par_phases[ObjCopy]->get(i) +
+ _gc_par_phases[Termination]->get(i);
- double worker_known_time = _last_ext_root_scan_times_ms.get(i) +
- _last_satb_filtering_times_ms.get(i) +
- _last_update_rs_times_ms.get(i) +
- _last_scan_rs_times_ms.get(i) +
- _last_strong_code_root_scan_times_ms.get(i) +
- _last_obj_copy_times_ms.get(i) +
- _last_termination_times_ms.get(i);
-
- double worker_other_time = worker_time - worker_known_time;
- _last_gc_worker_other_times_ms.set(i, worker_other_time);
+ record_time_secs(Other, i, worker_time - worker_known_time);
}
- _last_gc_worker_times_ms.verify();
- _last_gc_worker_other_times_ms.verify();
-
- _last_redirty_logged_cards_time_ms.verify();
- _last_redirty_logged_cards_processed_cards.verify();
-}
-
-void G1GCPhaseTimes::note_string_dedup_fixup_start() {
- _cur_string_dedup_queue_fixup_worker_times_ms.reset();
- _cur_string_dedup_table_fixup_worker_times_ms.reset();
-}
-
-void G1GCPhaseTimes::note_string_dedup_fixup_end() {
- _cur_string_dedup_queue_fixup_worker_times_ms.verify();
- _cur_string_dedup_table_fixup_worker_times_ms.verify();
+ for (int i = 0; i < GCParPhasesSentinel; i++) {
+ _gc_par_phases[i]->verify(_active_gc_threads);
+ }
}
void G1GCPhaseTimes::print_stats(int level, const char* str, double value) {
@@ -288,35 +364,174 @@
return misc_time_ms;
}
+// record the time a phase took in seconds
+void G1GCPhaseTimes::record_time_secs(GCParPhases phase, uint worker_i, double secs) {
+ _gc_par_phases[phase]->set(worker_i, secs);
+}
+
+// add a number of seconds to a phase
+void G1GCPhaseTimes::add_time_secs(GCParPhases phase, uint worker_i, double secs) {
+ _gc_par_phases[phase]->add(worker_i, secs);
+}
+
+void G1GCPhaseTimes::record_thread_work_item(GCParPhases phase, uint worker_i, size_t count) {
+ _gc_par_phases[phase]->set_thread_work_item(worker_i, count);
+}
+
+// return the average time for a phase in milliseconds
+double G1GCPhaseTimes::average_time_ms(GCParPhases phase) {
+ return _gc_par_phases[phase]->average(_active_gc_threads) * 1000.0;
+}
+
+double G1GCPhaseTimes::get_time_ms(GCParPhases phase, uint worker_i) {
+ return _gc_par_phases[phase]->get(worker_i) * 1000.0;
+}
+
+double G1GCPhaseTimes::sum_time_ms(GCParPhases phase) {
+ return _gc_par_phases[phase]->sum(_active_gc_threads) * 1000.0;
+}
+
+double G1GCPhaseTimes::min_time_ms(GCParPhases phase) {
+ return _gc_par_phases[phase]->minimum(_active_gc_threads) * 1000.0;
+}
+
+double G1GCPhaseTimes::max_time_ms(GCParPhases phase) {
+ return _gc_par_phases[phase]->maximum(_active_gc_threads) * 1000.0;
+}
+
+size_t G1GCPhaseTimes::get_thread_work_item(GCParPhases phase, uint worker_i) {
+ assert(_gc_par_phases[phase]->thread_work_items() != NULL, "No sub count");
+ return _gc_par_phases[phase]->thread_work_items()->get(worker_i);
+}
+
+size_t G1GCPhaseTimes::sum_thread_work_items(GCParPhases phase) {
+ assert(_gc_par_phases[phase]->thread_work_items() != NULL, "No sub count");
+ return _gc_par_phases[phase]->thread_work_items()->sum(_active_gc_threads);
+}
+
+double G1GCPhaseTimes::average_thread_work_items(GCParPhases phase) {
+ assert(_gc_par_phases[phase]->thread_work_items() != NULL, "No sub count");
+ return _gc_par_phases[phase]->thread_work_items()->average(_active_gc_threads);
+}
+
+size_t G1GCPhaseTimes::min_thread_work_items(GCParPhases phase) {
+ assert(_gc_par_phases[phase]->thread_work_items() != NULL, "No sub count");
+ return _gc_par_phases[phase]->thread_work_items()->minimum(_active_gc_threads);
+}
+
+size_t G1GCPhaseTimes::max_thread_work_items(GCParPhases phase) {
+ assert(_gc_par_phases[phase]->thread_work_items() != NULL, "No sub count");
+ return _gc_par_phases[phase]->thread_work_items()->maximum(_active_gc_threads);
+}
+
+class G1GCParPhasePrinter : public StackObj {
+ G1GCPhaseTimes* _phase_times;
+ public:
+ G1GCParPhasePrinter(G1GCPhaseTimes* phase_times) : _phase_times(phase_times) {}
+
+ void print(G1GCPhaseTimes::GCParPhases phase_id) {
+ WorkerDataArray<double>* phase = _phase_times->_gc_par_phases[phase_id];
+
+ if (phase->_log_level > G1Log::level() || !phase->_enabled) {
+ return;
+ }
+
+ if (phase->_length == 1) {
+ print_single_length(phase_id, phase);
+ } else {
+ print_multi_length(phase_id, phase);
+ }
+ }
+
+ private:
+
+ void print_single_length(G1GCPhaseTimes::GCParPhases phase_id, WorkerDataArray<double>* phase) {
+ // No need for min, max, average and sum for only one worker
+ LineBuffer buf(phase->_indent_level);
+ buf.append_and_print_cr("[%s: %.1lf]", phase->_title, _phase_times->get_time_ms(phase_id, 0));
+
+ if (phase->_thread_work_items != NULL) {
+ LineBuffer buf2(phase->_thread_work_items->_indent_level);
+ buf2.append_and_print_cr("[%s: "SIZE_FORMAT"]", phase->_thread_work_items->_title, _phase_times->sum_thread_work_items(phase_id));
+ }
+ }
+
+ void print_time_values(LineBuffer& buf, G1GCPhaseTimes::GCParPhases phase_id, WorkerDataArray<double>* phase) {
+ uint active_length = _phase_times->_active_gc_threads;
+ for (uint i = 0; i < active_length; ++i) {
+ buf.append(" %.1lf", _phase_times->get_time_ms(phase_id, i));
+ }
+ buf.print_cr();
+ }
+
+ void print_count_values(LineBuffer& buf, G1GCPhaseTimes::GCParPhases phase_id, WorkerDataArray<size_t>* thread_work_items) {
+ uint active_length = _phase_times->_active_gc_threads;
+ for (uint i = 0; i < active_length; ++i) {
+ buf.append(" " SIZE_FORMAT, _phase_times->get_thread_work_item(phase_id, i));
+ }
+ buf.print_cr();
+ }
+
+ void print_thread_work_items(G1GCPhaseTimes::GCParPhases phase_id, WorkerDataArray<size_t>* thread_work_items) {
+ LineBuffer buf(thread_work_items->_indent_level);
+ buf.append("[%s:", thread_work_items->_title);
+
+ if (G1Log::finest()) {
+ print_count_values(buf, phase_id, thread_work_items);
+ }
+
+ assert(thread_work_items->_print_sum, err_msg("%s does not have print sum true even though it is a count", thread_work_items->_title));
+
+ buf.append_and_print_cr(" Min: " SIZE_FORMAT ", Avg: %.1lf, Max: " SIZE_FORMAT ", Diff: " SIZE_FORMAT ", Sum: " SIZE_FORMAT "]",
+ _phase_times->min_thread_work_items(phase_id), _phase_times->average_thread_work_items(phase_id), _phase_times->max_thread_work_items(phase_id),
+ _phase_times->max_thread_work_items(phase_id) - _phase_times->min_thread_work_items(phase_id), _phase_times->sum_thread_work_items(phase_id));
+ }
+
+ void print_multi_length(G1GCPhaseTimes::GCParPhases phase_id, WorkerDataArray<double>* phase) {
+ LineBuffer buf(phase->_indent_level);
+ buf.append("[%s:", phase->_title);
+
+ if (G1Log::finest()) {
+ print_time_values(buf, phase_id, phase);
+ }
+
+ buf.append(" Min: %.1lf, Avg: %.1lf, Max: %.1lf, Diff: %.1lf",
+ _phase_times->min_time_ms(phase_id), _phase_times->average_time_ms(phase_id), _phase_times->max_time_ms(phase_id),
+ _phase_times->max_time_ms(phase_id) - _phase_times->min_time_ms(phase_id));
+
+ if (phase->_print_sum) {
+ // for things like the start and end times the sum is not
+ // that relevant
+ buf.append(", Sum: %.1lf", _phase_times->sum_time_ms(phase_id));
+ }
+
+ buf.append_and_print_cr("]");
+
+ if (phase->_thread_work_items != NULL) {
+ print_thread_work_items(phase_id, phase->_thread_work_items);
+ }
+ }
+};
+
void G1GCPhaseTimes::print(double pause_time_sec) {
+ G1GCParPhasePrinter par_phase_printer(this);
+
if (_root_region_scan_wait_time_ms > 0.0) {
print_stats(1, "Root Region Scan Waiting", _root_region_scan_wait_time_ms);
}
+
print_stats(1, "Parallel Time", _cur_collection_par_time_ms, _active_gc_threads);
- _last_gc_worker_start_times_ms.print(2, "GC Worker Start (ms)");
- _last_ext_root_scan_times_ms.print(2, "Ext Root Scanning (ms)");
- if (_last_satb_filtering_times_ms.sum() > 0.0) {
- _last_satb_filtering_times_ms.print(2, "SATB Filtering (ms)");
+ for (int i = 0; i <= GCMainParPhasesLast; i++) {
+ par_phase_printer.print((GCParPhases) i);
}
- _last_update_rs_times_ms.print(2, "Update RS (ms)");
- _last_update_rs_processed_buffers.print(3, "Processed Buffers");
- _last_scan_rs_times_ms.print(2, "Scan RS (ms)");
- _last_strong_code_root_scan_times_ms.print(2, "Code Root Scanning (ms)");
- _last_obj_copy_times_ms.print(2, "Object Copy (ms)");
- _last_termination_times_ms.print(2, "Termination (ms)");
- if (G1Log::finest()) {
- _last_termination_attempts.print(3, "Termination Attempts");
- }
- _last_gc_worker_other_times_ms.print(2, "GC Worker Other (ms)");
- _last_gc_worker_times_ms.print(2, "GC Worker Total (ms)");
- _last_gc_worker_end_times_ms.print(2, "GC Worker End (ms)");
print_stats(1, "Code Root Fixup", _cur_collection_code_root_fixup_time_ms);
print_stats(1, "Code Root Purge", _cur_strong_code_root_purge_time_ms);
if (G1StringDedup::is_enabled()) {
print_stats(1, "String Dedup Fixup", _cur_string_dedup_fixup_time_ms, _active_gc_threads);
- _cur_string_dedup_queue_fixup_worker_times_ms.print(2, "Queue Fixup (ms)");
- _cur_string_dedup_table_fixup_worker_times_ms.print(2, "Table Fixup (ms)");
+ for (int i = StringDedupPhasesFirst; i <= StringDedupPhasesLast; i++) {
+ par_phase_printer.print((GCParPhases) i);
+ }
}
print_stats(1, "Clear CT", _cur_clear_ct_time_ms);
double misc_time_ms = pause_time_sec * MILLIUNITS - accounted_time_ms();
@@ -340,10 +555,7 @@
print_stats(2, "Ref Proc", _cur_ref_proc_time_ms);
print_stats(2, "Ref Enq", _cur_ref_enq_time_ms);
print_stats(2, "Redirty Cards", _recorded_redirty_logged_cards_time_ms);
- if (G1Log::finest()) {
- _last_redirty_logged_cards_time_ms.print(3, "Parallel Redirty");
- _last_redirty_logged_cards_processed_cards.print(3, "Redirtied Cards");
- }
+ par_phase_printer.print(RedirtyCards);
if (G1EagerReclaimHumongousObjects) {
print_stats(2, "Humongous Register", _cur_fast_reclaim_humongous_register_time_ms);
if (G1Log::finest()) {
@@ -366,3 +578,17 @@
print_stats(2, "Verify After", _cur_verify_after_time_ms);
}
}
+
+G1GCParPhaseTimesTracker::G1GCParPhaseTimesTracker(G1GCPhaseTimes* phase_times, G1GCPhaseTimes::GCParPhases phase, uint worker_id) :
+ _phase_times(phase_times), _phase(phase), _worker_id(worker_id) {
+ if (_phase_times != NULL) {
+ _start_time = os::elapsedTime();
+ }
+}
+
+G1GCParPhaseTimesTracker::~G1GCParPhaseTimesTracker() {
+ if (_phase_times != NULL) {
+ _phase_times->record_time_secs(_phase, _worker_id, os::elapsedTime() - _start_time);
+ }
+}
+
--- a/hotspot/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -26,106 +26,60 @@
#define SHARE_VM_GC_IMPLEMENTATION_G1_G1GCPHASETIMESLOG_HPP
#include "memory/allocation.hpp"
-#include "gc_interface/gcCause.hpp"
-
-template <class T>
-class WorkerDataArray : public CHeapObj<mtGC> {
- T* _data;
- uint _length;
- const char* _print_format;
- bool _print_sum;
-
- NOT_PRODUCT(static const T _uninitialized;)
-
- // We are caching the sum and average to only have to calculate them once.
- // This is not done in an MT-safe way. It is intended to allow single
- // threaded code to call sum() and average() multiple times in any order
- // without having to worry about the cost.
- bool _has_new_data;
- T _sum;
- double _average;
-
- public:
- WorkerDataArray(uint length, const char* print_format, bool print_sum = true) :
- _length(length), _print_format(print_format), _print_sum(print_sum), _has_new_data(true) {
- assert(length > 0, "Must have some workers to store data for");
- _data = NEW_C_HEAP_ARRAY(T, _length, mtGC);
- }
-
- ~WorkerDataArray() {
- FREE_C_HEAP_ARRAY(T, _data);
- }
-
- void set(uint worker_i, T value) {
- assert(worker_i < _length, err_msg("Worker %d is greater than max: %d", worker_i, _length));
- assert(_data[worker_i] == (T)-1, err_msg("Overwriting data for worker %d", worker_i));
- _data[worker_i] = value;
- _has_new_data = true;
- }
- T get(uint worker_i) {
- assert(worker_i < _length, err_msg("Worker %d is greater than max: %d", worker_i, _length));
- assert(_data[worker_i] != (T)-1, err_msg("No data to add to for worker %d", worker_i));
- return _data[worker_i];
- }
-
- void add(uint worker_i, T value) {
- assert(worker_i < _length, err_msg("Worker %d is greater than max: %d", worker_i, _length));
- assert(_data[worker_i] != (T)-1, err_msg("No data to add to for worker %d", worker_i));
- _data[worker_i] += value;
- _has_new_data = true;
- }
-
- double average(){
- if (_has_new_data) {
- calculate_totals();
- }
- return _average;
- }
+class LineBuffer;
- T sum() {
- if (_has_new_data) {
- calculate_totals();
- }
- return _sum;
- }
-
- void print(int level, const char* title);
-
- void reset() PRODUCT_RETURN;
- void verify() PRODUCT_RETURN;
-
- private:
-
- void calculate_totals(){
- _sum = (T)0;
- for (uint i = 0; i < _length; ++i) {
- _sum += _data[i];
- }
- _average = (double)_sum / (double)_length;
- _has_new_data = false;
- }
-};
+template <class T> class WorkerDataArray;
class G1GCPhaseTimes : public CHeapObj<mtGC> {
+ friend class G1GCParPhasePrinter;
- private:
uint _active_gc_threads;
uint _max_gc_threads;
- WorkerDataArray<double> _last_gc_worker_start_times_ms;
- WorkerDataArray<double> _last_ext_root_scan_times_ms;
- WorkerDataArray<double> _last_satb_filtering_times_ms;
- WorkerDataArray<double> _last_update_rs_times_ms;
- WorkerDataArray<int> _last_update_rs_processed_buffers;
- WorkerDataArray<double> _last_scan_rs_times_ms;
- WorkerDataArray<double> _last_strong_code_root_scan_times_ms;
- WorkerDataArray<double> _last_obj_copy_times_ms;
- WorkerDataArray<double> _last_termination_times_ms;
- WorkerDataArray<size_t> _last_termination_attempts;
- WorkerDataArray<double> _last_gc_worker_end_times_ms;
- WorkerDataArray<double> _last_gc_worker_times_ms;
- WorkerDataArray<double> _last_gc_worker_other_times_ms;
+ public:
+ enum GCParPhases {
+ GCWorkerStart,
+ ExtRootScan,
+ ThreadRoots,
+ StringTableRoots,
+ UniverseRoots,
+ JNIRoots,
+ ObjectSynchronizerRoots,
+ FlatProfilerRoots,
+ ManagementRoots,
+ SystemDictionaryRoots,
+ CLDGRoots,
+ JVMTIRoots,
+ CodeCacheRoots,
+ CMRefRoots,
+ WaitForStrongCLD,
+ WeakCLDRoots,
+ SATBFiltering,
+ UpdateRS,
+ ScanRS,
+ CodeRoots,
+ ObjCopy,
+ Termination,
+ Other,
+ GCWorkerTotal,
+ GCWorkerEnd,
+ StringDedupQueueFixup,
+ StringDedupTableFixup,
+ RedirtyCards,
+ GCParPhasesSentinel
+ };
+
+ private:
+ // Markers for grouping the phases in the GCPhases enum above
+ static const int GCMainParPhasesLast = GCWorkerEnd;
+ static const int StringDedupPhasesFirst = StringDedupQueueFixup;
+ static const int StringDedupPhasesLast = StringDedupTableFixup;
+
+ WorkerDataArray<double>* _gc_par_phases[GCParPhasesSentinel];
+ WorkerDataArray<size_t>* _update_rs_processed_buffers;
+ WorkerDataArray<size_t>* _termination_attempts;
+ WorkerDataArray<size_t>* _redirtied_cards;
double _cur_collection_par_time_ms;
double _cur_collection_code_root_fixup_time_ms;
@@ -135,9 +89,7 @@
double _cur_evac_fail_restore_remsets;
double _cur_evac_fail_remove_self_forwards;
- double _cur_string_dedup_fixup_time_ms;
- WorkerDataArray<double> _cur_string_dedup_queue_fixup_worker_times_ms;
- WorkerDataArray<double> _cur_string_dedup_table_fixup_worker_times_ms;
+ double _cur_string_dedup_fixup_time_ms;
double _cur_clear_ct_time_ms;
double _cur_ref_proc_time_ms;
@@ -149,8 +101,6 @@
double _recorded_young_cset_choice_time_ms;
double _recorded_non_young_cset_choice_time_ms;
- WorkerDataArray<double> _last_redirty_logged_cards_time_ms;
- WorkerDataArray<size_t> _last_redirty_logged_cards_processed_cards;
double _recorded_redirty_logged_cards_time_ms;
double _recorded_young_free_cset_time_ms;
@@ -172,54 +122,34 @@
public:
G1GCPhaseTimes(uint max_gc_threads);
- void note_gc_start(uint active_gc_threads);
+ void note_gc_start(uint active_gc_threads, bool mark_in_progress);
void note_gc_end();
void print(double pause_time_sec);
- void record_gc_worker_start_time(uint worker_i, double ms) {
- _last_gc_worker_start_times_ms.set(worker_i, ms);
- }
-
- void record_ext_root_scan_time(uint worker_i, double ms) {
- _last_ext_root_scan_times_ms.set(worker_i, ms);
- }
+ // record the time a phase took in seconds
+ void record_time_secs(GCParPhases phase, uint worker_i, double secs);
- void record_satb_filtering_time(uint worker_i, double ms) {
- _last_satb_filtering_times_ms.set(worker_i, ms);
- }
+ // add a number of seconds to a phase
+ void add_time_secs(GCParPhases phase, uint worker_i, double secs);
- void record_update_rs_time(uint worker_i, double ms) {
- _last_update_rs_times_ms.set(worker_i, ms);
- }
+ void record_thread_work_item(GCParPhases phase, uint worker_i, size_t count);
- void record_update_rs_processed_buffers(uint worker_i, int processed_buffers) {
- _last_update_rs_processed_buffers.set(worker_i, processed_buffers);
- }
+ // return the average time for a phase in milliseconds
+ double average_time_ms(GCParPhases phase);
- void record_scan_rs_time(uint worker_i, double ms) {
- _last_scan_rs_times_ms.set(worker_i, ms);
- }
-
- void record_strong_code_root_scan_time(uint worker_i, double ms) {
- _last_strong_code_root_scan_times_ms.set(worker_i, ms);
- }
-
- void record_obj_copy_time(uint worker_i, double ms) {
- _last_obj_copy_times_ms.set(worker_i, ms);
- }
+ size_t sum_thread_work_items(GCParPhases phase);
- void add_obj_copy_time(uint worker_i, double ms) {
- _last_obj_copy_times_ms.add(worker_i, ms);
- }
+ private:
+ double get_time_ms(GCParPhases phase, uint worker_i);
+ double sum_time_ms(GCParPhases phase);
+ double min_time_ms(GCParPhases phase);
+ double max_time_ms(GCParPhases phase);
+ size_t get_thread_work_item(GCParPhases phase, uint worker_i);
+ double average_thread_work_items(GCParPhases phase);
+ size_t min_thread_work_items(GCParPhases phase);
+ size_t max_thread_work_items(GCParPhases phase);
- void record_termination(uint worker_i, double ms, size_t attempts) {
- _last_termination_times_ms.set(worker_i, ms);
- _last_termination_attempts.set(worker_i, attempts);
- }
-
- void record_gc_worker_end_time(uint worker_i, double ms) {
- _last_gc_worker_end_times_ms.set(worker_i, ms);
- }
+ public:
void record_clear_ct_time(double ms) {
_cur_clear_ct_time_ms = ms;
@@ -249,21 +179,10 @@
_cur_evac_fail_remove_self_forwards = ms;
}
- void note_string_dedup_fixup_start();
- void note_string_dedup_fixup_end();
-
void record_string_dedup_fixup_time(double ms) {
_cur_string_dedup_fixup_time_ms = ms;
}
- void record_string_dedup_queue_fixup_worker_time(uint worker_id, double ms) {
- _cur_string_dedup_queue_fixup_worker_times_ms.set(worker_id, ms);
- }
-
- void record_string_dedup_table_fixup_worker_time(uint worker_id, double ms) {
- _cur_string_dedup_table_fixup_worker_times_ms.set(worker_id, ms);
- }
-
void record_ref_proc_time(double ms) {
_cur_ref_proc_time_ms = ms;
}
@@ -303,14 +222,6 @@
_recorded_non_young_cset_choice_time_ms = time_ms;
}
- void record_redirty_logged_cards_time_ms(uint worker_i, double time_ms) {
- _last_redirty_logged_cards_time_ms.set(worker_i, time_ms);
- }
-
- void record_redirty_logged_cards_processed_cards(uint worker_i, size_t processed_buffers) {
- _last_redirty_logged_cards_processed_cards.set(worker_i, processed_buffers);
- }
-
void record_redirty_logged_cards_time_ms(double time_ms) {
_recorded_redirty_logged_cards_time_ms = time_ms;
}
@@ -364,38 +275,16 @@
double fast_reclaim_humongous_time_ms() {
return _cur_fast_reclaim_humongous_time_ms;
}
-
- double average_last_update_rs_time() {
- return _last_update_rs_times_ms.average();
- }
-
- int sum_last_update_rs_processed_buffers() {
- return _last_update_rs_processed_buffers.sum();
- }
-
- double average_last_scan_rs_time(){
- return _last_scan_rs_times_ms.average();
- }
+};
- double average_last_strong_code_root_scan_time(){
- return _last_strong_code_root_scan_times_ms.average();
- }
-
- double average_last_obj_copy_time() {
- return _last_obj_copy_times_ms.average();
- }
-
- double average_last_termination_time() {
- return _last_termination_times_ms.average();
- }
-
- double average_last_ext_root_scan_time() {
- return _last_ext_root_scan_times_ms.average();
- }
-
- double average_last_satb_filtering_times_ms() {
- return _last_satb_filtering_times_ms.average();
- }
+class G1GCParPhaseTimesTracker : public StackObj {
+ double _start_time;
+ G1GCPhaseTimes::GCParPhases _phase;
+ G1GCPhaseTimes* _phase_times;
+ uint _worker_id;
+public:
+ G1GCParPhaseTimesTracker(G1GCPhaseTimes* phase_times, G1GCPhaseTimes::GCParPhases phase, uint worker_id);
+ ~G1GCParPhaseTimesTracker();
};
#endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1GCPHASETIMESLOG_HPP
--- a/hotspot/src/share/vm/gc_implementation/g1/g1HRPrinter.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1HRPrinter.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -27,8 +27,6 @@
#include "gc_implementation/g1/heapRegion.hpp"
#include "utilities/ostream.hpp"
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
const char* G1HRPrinter::action_name(ActionType action) {
switch(action) {
case Alloc: return "ALLOC";
@@ -85,18 +83,18 @@
if (type_str != NULL) {
if (top != NULL) {
gclog_or_tty->print_cr(G1HR_PREFIX" %s(%s) "PTR_FORMAT" "PTR_FORMAT,
- action_str, type_str, bottom, top);
+ action_str, type_str, p2i(bottom), p2i(top));
} else {
gclog_or_tty->print_cr(G1HR_PREFIX" %s(%s) "PTR_FORMAT,
- action_str, type_str, bottom);
+ action_str, type_str, p2i(bottom));
}
} else {
if (top != NULL) {
gclog_or_tty->print_cr(G1HR_PREFIX" %s "PTR_FORMAT" "PTR_FORMAT,
- action_str, bottom, top);
+ action_str, p2i(bottom), p2i(top));
} else {
gclog_or_tty->print_cr(G1HR_PREFIX" %s "PTR_FORMAT,
- action_str, bottom);
+ action_str, p2i(bottom));
}
}
}
@@ -105,7 +103,7 @@
const char* action_str = action_name(action);
gclog_or_tty->print_cr(G1HR_PREFIX" %s ["PTR_FORMAT","PTR_FORMAT"]",
- action_str, bottom, end);
+ action_str, p2i(bottom), p2i(end));
}
void G1HRPrinter::print(PhaseType phase, size_t phase_num) {
--- a/hotspot/src/share/vm/gc_implementation/g1/g1Log.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1Log.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -28,6 +28,7 @@
#include "memory/allocation.hpp"
class G1Log : public AllStatic {
+ public:
typedef enum {
LevelNone,
LevelFine,
@@ -35,6 +36,7 @@
LevelFinest
} LogLevel;
+ private:
static LogLevel _level;
public:
@@ -50,6 +52,10 @@
return _level == LevelFinest;
}
+ static LogLevel level() {
+ return _level;
+ }
+
static void init();
};
--- a/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,7 +31,9 @@
#include "code/icBuffer.hpp"
#include "gc_implementation/g1/g1Log.hpp"
#include "gc_implementation/g1/g1MarkSweep.hpp"
+#include "gc_implementation/g1/g1RootProcessor.hpp"
#include "gc_implementation/g1/g1StringDedup.hpp"
+#include "gc_implementation/shared/markSweep.inline.hpp"
#include "gc_implementation/shared/gcHeapSummary.hpp"
#include "gc_implementation/shared/gcTimer.hpp"
#include "gc_implementation/shared/gcTrace.hpp"
@@ -125,21 +127,22 @@
GCTraceTime tm("phase 1", G1Log::fine() && Verbose, true, gc_timer(), gc_tracer()->gc_id());
GenMarkSweep::trace(" 1");
- SharedHeap* sh = SharedHeap::heap();
+ G1CollectedHeap* g1h = G1CollectedHeap::heap();
// Need cleared claim bits for the roots processing
ClassLoaderDataGraph::clear_claimed_marks();
MarkingCodeBlobClosure follow_code_closure(&GenMarkSweep::follow_root_closure, !CodeBlobToOopClosure::FixRelocations);
- sh->process_strong_roots(true, // activate StrongRootsScope
- SharedHeap::SO_None,
- &GenMarkSweep::follow_root_closure,
- &GenMarkSweep::follow_cld_closure,
- &follow_code_closure);
+ {
+ G1RootProcessor root_processor(g1h);
+ root_processor.process_strong_roots(&GenMarkSweep::follow_root_closure,
+ &GenMarkSweep::follow_cld_closure,
+ &follow_code_closure);
+ }
// Process reference objects found during marking
ReferenceProcessor* rp = GenMarkSweep::ref_processor();
- assert(rp == G1CollectedHeap::heap()->ref_processor_stw(), "Sanity");
+ assert(rp == g1h->ref_processor_stw(), "Sanity");
rp->setup_policy(clear_all_softrefs);
const ReferenceProcessorStats& stats =
@@ -215,7 +218,7 @@
// We must adjust the pointers on the single H object.
oop obj = oop(r->bottom());
// point all the oops to the new location
- obj->adjust_pointers();
+ MarkSweep::adjust_pointers(obj);
}
} else {
// This really ought to be "as_CompactibleSpace"...
@@ -225,6 +228,12 @@
}
};
+class G1AlwaysTrueClosure: public BoolObjectClosure {
+public:
+ bool do_object_b(oop p) { return true; }
+};
+static G1AlwaysTrueClosure always_true;
+
void G1MarkSweep::mark_sweep_phase3() {
G1CollectedHeap* g1h = G1CollectedHeap::heap();
@@ -232,24 +241,23 @@
GCTraceTime tm("phase 3", G1Log::fine() && Verbose, true, gc_timer(), gc_tracer()->gc_id());
GenMarkSweep::trace("3");
- SharedHeap* sh = SharedHeap::heap();
-
// Need cleared claim bits for the roots processing
ClassLoaderDataGraph::clear_claimed_marks();
CodeBlobToOopClosure adjust_code_closure(&GenMarkSweep::adjust_pointer_closure, CodeBlobToOopClosure::FixRelocations);
- sh->process_all_roots(true, // activate StrongRootsScope
- SharedHeap::SO_AllCodeCache,
- &GenMarkSweep::adjust_pointer_closure,
- &GenMarkSweep::adjust_cld_closure,
- &adjust_code_closure);
+ {
+ G1RootProcessor root_processor(g1h);
+ root_processor.process_all_roots(&GenMarkSweep::adjust_pointer_closure,
+ &GenMarkSweep::adjust_cld_closure,
+ &adjust_code_closure);
+ }
assert(GenMarkSweep::ref_processor() == g1h->ref_processor_stw(), "Sanity");
g1h->ref_processor_stw()->weak_oops_do(&GenMarkSweep::adjust_pointer_closure);
// Now adjust pointers in remaining weak roots. (All of which should
// have been cleared if they pointed to non-surviving objects.)
- sh->process_weak_roots(&GenMarkSweep::adjust_pointer_closure);
+ JNIHandles::weak_oops_do(&always_true, &GenMarkSweep::adjust_pointer_closure);
if (G1StringDedup::is_enabled()) {
G1StringDedup::oops_do(&GenMarkSweep::adjust_pointer_closure);
--- a/hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -109,6 +109,18 @@
template <class T> void do_klass_barrier(T* p, oop new_obj);
};
+enum G1Barrier {
+ G1BarrierNone,
+ G1BarrierEvac,
+ G1BarrierKlass
+};
+
+enum G1Mark {
+ G1MarkNone,
+ G1MarkFromRoot,
+ G1MarkPromotedFromRoot
+};
+
template <G1Barrier barrier, G1Mark do_mark_object>
class G1ParCopyClosure : public G1ParCopyHelper {
private:
--- a/hotspot/src/share/vm/gc_implementation/g1/g1ParScanThreadState.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1ParScanThreadState.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,6 @@
#include "gc_implementation/g1/g1OopClosures.inline.hpp"
#include "gc_implementation/g1/g1ParScanThreadState.inline.hpp"
#include "oops/oop.inline.hpp"
-#include "oops/oop.pcgc.inline.hpp"
#include "runtime/prefetch.inline.hpp"
G1ParScanThreadState::G1ParScanThreadState(G1CollectedHeap* g1h, uint queue_num, ReferenceProcessor* rp)
@@ -226,6 +225,8 @@
}
assert(obj_ptr != NULL, "when we get here, allocation should have succeeded");
+ assert(_g1h->is_in_reserved(obj_ptr), "Allocated memory should be in the heap");
+
#ifndef PRODUCT
// Should this evacuation fail?
if (_g1h->evacuation_should_fail()) {
--- a/hotspot/src/share/vm/gc_implementation/g1/g1RegionToSpaceMapper.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1RegionToSpaceMapper.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -57,6 +57,9 @@
public:
MemRegion reserved() { return _storage.reserved(); }
+ size_t reserved_size() { return _storage.reserved_size(); }
+ size_t committed_size() { return _storage.committed_size(); }
+
void set_mapping_changed_listener(G1MappingChangedListener* listener) { _listener = listener; }
virtual ~G1RegionToSpaceMapper() {
--- a/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -39,8 +39,6 @@
#include "utilities/globalDefinitions.hpp"
#include "utilities/intHisto.hpp"
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
#define CARD_REPEAT_HISTO 0
#if CARD_REPEAT_HISTO
@@ -79,7 +77,6 @@
_cards_scanned(NULL), _total_cards_scanned(0),
_prev_period_summary()
{
- _seq_task = new SubTasksDone(NumSeqTasks);
_cset_rs_update_cl = NEW_C_HEAP_ARRAY(G1ParPushHeapRSClosure*, n_workers(), mtGC);
for (uint i = 0; i < n_workers(); i++) {
_cset_rs_update_cl[i] = NULL;
@@ -90,7 +87,6 @@
}
G1RemSet::~G1RemSet() {
- delete _seq_task;
for (uint i = 0; i < n_workers(); i++) {
assert(_cset_rs_update_cl[i] == NULL, "it should be");
}
@@ -109,7 +105,7 @@
double _strong_code_root_scan_time_sec;
uint _worker_i;
- int _block_size;
+ size_t _block_size;
bool _try_claimed;
public:
@@ -127,7 +123,7 @@
_g1h = G1CollectedHeap::heap();
_bot_shared = _g1h->bot_shared();
_ct_bs = _g1h->g1_barrier_set();
- _block_size = MAX2<int>(G1RSetScanBlockSize, 1);
+ _block_size = MAX2<size_t>(G1RSetScanBlockSize, 1);
}
void set_try_claimed() { _try_claimed = true; }
@@ -158,9 +154,9 @@
"RS names card " SIZE_FORMAT_HEX ": "
"[" PTR_FORMAT ", " PTR_FORMAT ")",
_worker_i,
- card_region->bottom(), card_region->end(),
+ p2i(card_region->bottom()), p2i(card_region->end()),
card_index,
- card_start, card_start + G1BlockOffsetSharedArray::N_words);
+ p2i(card_start), p2i(card_start + G1BlockOffsetSharedArray::N_words));
}
void scan_strong_code_roots(HeapRegion* r) {
@@ -248,9 +244,8 @@
assert(_cards_scanned != NULL, "invariant");
_cards_scanned[worker_i] = scanRScl.cards_done();
- _g1p->phase_times()->record_scan_rs_time(worker_i, scan_rs_time_sec * 1000.0);
- _g1p->phase_times()->record_strong_code_root_scan_time(worker_i,
- scanRScl.strong_code_root_scan_time_sec() * 1000.0);
+ _g1p->phase_times()->record_time_secs(G1GCPhaseTimes::ScanRS, worker_i, scan_rs_time_sec);
+ _g1p->phase_times()->record_time_secs(G1GCPhaseTimes::CodeRoots, worker_i, scanRScl.strong_code_root_scan_time_sec());
}
// Closure used for updating RSets and recording references that
@@ -287,13 +282,11 @@
};
void G1RemSet::updateRS(DirtyCardQueue* into_cset_dcq, uint worker_i) {
- double start = os::elapsedTime();
+ G1GCParPhaseTimesTracker x(_g1p->phase_times(), G1GCPhaseTimes::UpdateRS, worker_i);
// Apply the given closure to all remaining log entries.
RefineRecordRefsIntoCSCardTableEntryClosure into_cset_update_rs_cl(_g1, into_cset_dcq);
_g1->iterate_dirty_card_closure(&into_cset_update_rs_cl, into_cset_dcq, false, worker_i);
-
- _g1p->phase_times()->record_update_rs_time(worker_i, (os::elapsedTime() - start) * 1000.0);
}
void G1RemSet::cleanupHRRS() {
@@ -433,7 +426,7 @@
err_msg("Card at "PTR_FORMAT" index "SIZE_FORMAT" representing heap at "PTR_FORMAT" (%u) must be in committed heap",
p2i(card_ptr),
_ct_bs->index_for(_ct_bs->addr_for(card_ptr)),
- _ct_bs->addr_for(card_ptr),
+ p2i(_ct_bs->addr_for(card_ptr)),
_g1->addr_to_region(_ct_bs->addr_for(card_ptr))));
// If the card is no longer dirty, nothing to do.
--- a/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -58,7 +58,6 @@
};
CardTableModRefBS* _ct_bs;
- SubTasksDone* _seq_task;
G1CollectorPolicy* _g1p;
ConcurrentG1Refine* _cg1r;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1RootProcessor.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,337 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include "precompiled.hpp"
+
+#include "classfile/stringTable.hpp"
+#include "classfile/systemDictionary.hpp"
+#include "code/codeCache.hpp"
+#include "gc_implementation/g1/bufferingOopClosure.hpp"
+#include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
+#include "gc_implementation/g1/g1CollectorPolicy.hpp"
+#include "gc_implementation/g1/g1GCPhaseTimes.hpp"
+#include "gc_implementation/g1/g1RemSet.inline.hpp"
+#include "gc_implementation/g1/g1RootProcessor.hpp"
+#include "memory/allocation.inline.hpp"
+#include "runtime/fprofiler.hpp"
+#include "runtime/mutex.hpp"
+#include "services/management.hpp"
+
+class G1CodeBlobClosure : public CodeBlobClosure {
+ class HeapRegionGatheringOopClosure : public OopClosure {
+ G1CollectedHeap* _g1h;
+ OopClosure* _work;
+ nmethod* _nm;
+
+ template <typename T>
+ void do_oop_work(T* p) {
+ _work->do_oop(p);
+ T oop_or_narrowoop = oopDesc::load_heap_oop(p);
+ if (!oopDesc::is_null(oop_or_narrowoop)) {
+ oop o = oopDesc::decode_heap_oop_not_null(oop_or_narrowoop);
+ HeapRegion* hr = _g1h->heap_region_containing_raw(o);
+ assert(!_g1h->obj_in_cs(o) || hr->rem_set()->strong_code_roots_list_contains(_nm), "if o still in CS then evacuation failed and nm must already be in the remset");
+ hr->add_strong_code_root(_nm);
+ }
+ }
+
+ public:
+ HeapRegionGatheringOopClosure(OopClosure* oc) : _g1h(G1CollectedHeap::heap()), _work(oc), _nm(NULL) {}
+
+ void do_oop(oop* o) {
+ do_oop_work(o);
+ }
+
+ void do_oop(narrowOop* o) {
+ do_oop_work(o);
+ }
+
+ void set_nm(nmethod* nm) {
+ _nm = nm;
+ }
+ };
+
+ HeapRegionGatheringOopClosure _oc;
+public:
+ G1CodeBlobClosure(OopClosure* oc) : _oc(oc) {}
+
+ void do_code_blob(CodeBlob* cb) {
+ nmethod* nm = cb->as_nmethod_or_null();
+ if (nm != NULL) {
+ if (!nm->test_set_oops_do_mark()) {
+ _oc.set_nm(nm);
+ nm->oops_do(&_oc);
+ nm->fix_oop_relocations();
+ }
+ }
+ }
+};
+
+
+void G1RootProcessor::worker_has_discovered_all_strong_classes() {
+ uint n_workers = _g1h->n_par_threads();
+ assert(ClassUnloadingWithConcurrentMark, "Currently only needed when doing G1 Class Unloading");
+
+ uint new_value = (uint)Atomic::add(1, &_n_workers_discovered_strong_classes);
+ if (new_value == n_workers) {
+ // This thread is last. Notify the others.
+ MonitorLockerEx ml(&_lock, Mutex::_no_safepoint_check_flag);
+ _lock.notify_all();
+ }
+}
+
+void G1RootProcessor::wait_until_all_strong_classes_discovered() {
+ uint n_workers = _g1h->n_par_threads();
+ assert(ClassUnloadingWithConcurrentMark, "Currently only needed when doing G1 Class Unloading");
+
+ if ((uint)_n_workers_discovered_strong_classes != n_workers) {
+ MonitorLockerEx ml(&_lock, Mutex::_no_safepoint_check_flag);
+ while ((uint)_n_workers_discovered_strong_classes != n_workers) {
+ _lock.wait(Mutex::_no_safepoint_check_flag, 0, false);
+ }
+ }
+}
+
+G1RootProcessor::G1RootProcessor(G1CollectedHeap* g1h) :
+ _g1h(g1h),
+ _process_strong_tasks(new SubTasksDone(G1RP_PS_NumElements)),
+ _srs(g1h),
+ _lock(Mutex::leaf, "G1 Root Scanning barrier lock", false, Monitor::_safepoint_check_never),
+ _n_workers_discovered_strong_classes(0) {}
+
+void G1RootProcessor::evacuate_roots(OopClosure* scan_non_heap_roots,
+ OopClosure* scan_non_heap_weak_roots,
+ CLDClosure* scan_strong_clds,
+ CLDClosure* scan_weak_clds,
+ bool trace_metadata,
+ uint worker_i) {
+ // First scan the shared roots.
+ double ext_roots_start = os::elapsedTime();
+ G1GCPhaseTimes* phase_times = _g1h->g1_policy()->phase_times();
+
+ BufferingOopClosure buf_scan_non_heap_roots(scan_non_heap_roots);
+ BufferingOopClosure buf_scan_non_heap_weak_roots(scan_non_heap_weak_roots);
+
+ OopClosure* const weak_roots = &buf_scan_non_heap_weak_roots;
+ OopClosure* const strong_roots = &buf_scan_non_heap_roots;
+
+ // CodeBlobClosures are not interoperable with BufferingOopClosures
+ G1CodeBlobClosure root_code_blobs(scan_non_heap_roots);
+
+ process_java_roots(strong_roots,
+ trace_metadata ? scan_strong_clds : NULL,
+ scan_strong_clds,
+ trace_metadata ? NULL : scan_weak_clds,
+ &root_code_blobs,
+ phase_times,
+ worker_i);
+
+ // This is the point where this worker thread will not find more strong CLDs/nmethods.
+ // Report this so G1 can synchronize the strong and weak CLDs/nmethods processing.
+ if (trace_metadata) {
+ worker_has_discovered_all_strong_classes();
+ }
+
+ process_vm_roots(strong_roots, weak_roots, phase_times, worker_i);
+
+ {
+ // Now the CM ref_processor roots.
+ G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::CMRefRoots, worker_i);
+ if (!_process_strong_tasks->is_task_claimed(G1RP_PS_refProcessor_oops_do)) {
+ // We need to treat the discovered reference lists of the
+ // concurrent mark ref processor as roots and keep entries
+ // (which are added by the marking threads) on them live
+ // until they can be processed at the end of marking.
+ _g1h->ref_processor_cm()->weak_oops_do(&buf_scan_non_heap_roots);
+ }
+ }
+
+ if (trace_metadata) {
+ {
+ G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::WaitForStrongCLD, worker_i);
+ // Barrier to make sure all workers passed
+ // the strong CLD and strong nmethods phases.
+ wait_until_all_strong_classes_discovered();
+ }
+
+ // Now take the complement of the strong CLDs.
+ G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::WeakCLDRoots, worker_i);
+ ClassLoaderDataGraph::roots_cld_do(NULL, scan_weak_clds);
+ } else {
+ phase_times->record_time_secs(G1GCPhaseTimes::WaitForStrongCLD, worker_i, 0.0);
+ phase_times->record_time_secs(G1GCPhaseTimes::WeakCLDRoots, worker_i, 0.0);
+ }
+
+ // Finish up any enqueued closure apps (attributed as object copy time).
+ buf_scan_non_heap_roots.done();
+ buf_scan_non_heap_weak_roots.done();
+
+ double obj_copy_time_sec = buf_scan_non_heap_roots.closure_app_seconds()
+ + buf_scan_non_heap_weak_roots.closure_app_seconds();
+
+ phase_times->record_time_secs(G1GCPhaseTimes::ObjCopy, worker_i, obj_copy_time_sec);
+
+ double ext_root_time_sec = os::elapsedTime() - ext_roots_start - obj_copy_time_sec;
+
+ phase_times->record_time_secs(G1GCPhaseTimes::ExtRootScan, worker_i, ext_root_time_sec);
+
+ // During conc marking we have to filter the per-thread SATB buffers
+ // to make sure we remove any oops into the CSet (which will show up
+ // as implicitly live).
+ {
+ G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::SATBFiltering, worker_i);
+ if (!_process_strong_tasks->is_task_claimed(G1RP_PS_filter_satb_buffers) && _g1h->mark_in_progress()) {
+ JavaThread::satb_mark_queue_set().filter_thread_buffers();
+ }
+ }
+
+ _process_strong_tasks->all_tasks_completed();
+}
+
+void G1RootProcessor::process_strong_roots(OopClosure* oops,
+ CLDClosure* clds,
+ CodeBlobClosure* blobs) {
+
+ process_java_roots(oops, clds, clds, NULL, blobs, NULL, 0);
+ process_vm_roots(oops, NULL, NULL, 0);
+
+ _process_strong_tasks->all_tasks_completed();
+}
+
+void G1RootProcessor::process_all_roots(OopClosure* oops,
+ CLDClosure* clds,
+ CodeBlobClosure* blobs) {
+
+ process_java_roots(oops, NULL, clds, clds, NULL, NULL, 0);
+ process_vm_roots(oops, oops, NULL, 0);
+
+ if (!_process_strong_tasks->is_task_claimed(G1RP_PS_CodeCache_oops_do)) {
+ CodeCache::blobs_do(blobs);
+ }
+
+ _process_strong_tasks->all_tasks_completed();
+}
+
+void G1RootProcessor::process_java_roots(OopClosure* strong_roots,
+ CLDClosure* thread_stack_clds,
+ CLDClosure* strong_clds,
+ CLDClosure* weak_clds,
+ CodeBlobClosure* strong_code,
+ G1GCPhaseTimes* phase_times,
+ uint worker_i) {
+ assert(thread_stack_clds == NULL || weak_clds == NULL, "There is overlap between those, only one may be set");
+ // Iterating over the CLDG and the Threads are done early to allow us to
+ // first process the strong CLDs and nmethods and then, after a barrier,
+ // let the thread process the weak CLDs and nmethods.
+ {
+ G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::CLDGRoots, worker_i);
+ if (!_process_strong_tasks->is_task_claimed(G1RP_PS_ClassLoaderDataGraph_oops_do)) {
+ ClassLoaderDataGraph::roots_cld_do(strong_clds, weak_clds);
+ }
+ }
+
+ {
+ G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::ThreadRoots, worker_i);
+ Threads::possibly_parallel_oops_do(strong_roots, thread_stack_clds, strong_code);
+ }
+}
+
+void G1RootProcessor::process_vm_roots(OopClosure* strong_roots,
+ OopClosure* weak_roots,
+ G1GCPhaseTimes* phase_times,
+ uint worker_i) {
+ {
+ G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::UniverseRoots, worker_i);
+ if (!_process_strong_tasks->is_task_claimed(G1RP_PS_Universe_oops_do)) {
+ Universe::oops_do(strong_roots);
+ }
+ }
+
+ {
+ G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::JNIRoots, worker_i);
+ if (!_process_strong_tasks->is_task_claimed(G1RP_PS_JNIHandles_oops_do)) {
+ JNIHandles::oops_do(strong_roots);
+ }
+ }
+
+ {
+ G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::ObjectSynchronizerRoots, worker_i);
+ if (!_process_strong_tasks-> is_task_claimed(G1RP_PS_ObjectSynchronizer_oops_do)) {
+ ObjectSynchronizer::oops_do(strong_roots);
+ }
+ }
+
+ {
+ G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::FlatProfilerRoots, worker_i);
+ if (!_process_strong_tasks->is_task_claimed(G1RP_PS_FlatProfiler_oops_do)) {
+ FlatProfiler::oops_do(strong_roots);
+ }
+ }
+
+ {
+ G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::ManagementRoots, worker_i);
+ if (!_process_strong_tasks->is_task_claimed(G1RP_PS_Management_oops_do)) {
+ Management::oops_do(strong_roots);
+ }
+ }
+
+ {
+ G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::JVMTIRoots, worker_i);
+ if (!_process_strong_tasks->is_task_claimed(G1RP_PS_jvmti_oops_do)) {
+ JvmtiExport::oops_do(strong_roots);
+ }
+ }
+
+ {
+ G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::SystemDictionaryRoots, worker_i);
+ if (!_process_strong_tasks->is_task_claimed(G1RP_PS_SystemDictionary_oops_do)) {
+ SystemDictionary::roots_oops_do(strong_roots, weak_roots);
+ }
+ }
+
+ {
+ G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::StringTableRoots, worker_i);
+ // All threads execute the following. A specific chunk of buckets
+ // from the StringTable are the individual tasks.
+ if (weak_roots != NULL) {
+ StringTable::possibly_parallel_oops_do(weak_roots);
+ }
+ }
+}
+
+void G1RootProcessor::scan_remembered_sets(G1ParPushHeapRSClosure* scan_rs,
+ OopClosure* scan_non_heap_weak_roots,
+ uint worker_i) {
+ G1GCPhaseTimes* phase_times = _g1h->g1_policy()->phase_times();
+ G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::CodeCacheRoots, worker_i);
+
+ // Now scan the complement of the collection set.
+ G1CodeBlobClosure scavenge_cs_nmethods(scan_non_heap_weak_roots);
+
+ _g1h->g1_rem_set()->oops_into_collection_set_do(scan_rs, &scavenge_cs_nmethods, worker_i);
+}
+
+void G1RootProcessor::set_num_workers(int active_workers) {
+ _process_strong_tasks->set_n_threads(active_workers);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1RootProcessor.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_ROOTPROCESSOR_HPP
+#define SHARE_VM_GC_IMPLEMENTATION_G1_ROOTPROCESSOR_HPP
+
+#include "memory/allocation.hpp"
+#include "memory/sharedHeap.hpp"
+#include "runtime/mutex.hpp"
+
+class CLDClosure;
+class CodeBlobClosure;
+class G1CollectedHeap;
+class G1GCPhaseTimes;
+class G1ParPushHeapRSClosure;
+class Monitor;
+class OopClosure;
+class SubTasksDone;
+
+// Scoped object to assist in applying oop, CLD and code blob closures to
+// root locations. Handles claiming of different root scanning tasks
+// and takes care of global state for root scanning via a StrongRootsScope.
+// In the parallel case there is a shared G1RootProcessor object where all
+// worker thread call the process_roots methods.
+class G1RootProcessor : public StackObj {
+ G1CollectedHeap* _g1h;
+ SubTasksDone* _process_strong_tasks;
+ SharedHeap::StrongRootsScope _srs;
+
+ // Used to implement the Thread work barrier.
+ Monitor _lock;
+ volatile jint _n_workers_discovered_strong_classes;
+
+ enum G1H_process_roots_tasks {
+ G1RP_PS_Universe_oops_do,
+ G1RP_PS_JNIHandles_oops_do,
+ G1RP_PS_ObjectSynchronizer_oops_do,
+ G1RP_PS_FlatProfiler_oops_do,
+ G1RP_PS_Management_oops_do,
+ G1RP_PS_SystemDictionary_oops_do,
+ G1RP_PS_ClassLoaderDataGraph_oops_do,
+ G1RP_PS_jvmti_oops_do,
+ G1RP_PS_CodeCache_oops_do,
+ G1RP_PS_filter_satb_buffers,
+ G1RP_PS_refProcessor_oops_do,
+ // Leave this one last.
+ G1RP_PS_NumElements
+ };
+
+ void worker_has_discovered_all_strong_classes();
+ void wait_until_all_strong_classes_discovered();
+
+ void process_java_roots(OopClosure* scan_non_heap_roots,
+ CLDClosure* thread_stack_clds,
+ CLDClosure* scan_strong_clds,
+ CLDClosure* scan_weak_clds,
+ CodeBlobClosure* scan_strong_code,
+ G1GCPhaseTimes* phase_times,
+ uint worker_i);
+
+ void process_vm_roots(OopClosure* scan_non_heap_roots,
+ OopClosure* scan_non_heap_weak_roots,
+ G1GCPhaseTimes* phase_times,
+ uint worker_i);
+
+public:
+ G1RootProcessor(G1CollectedHeap* g1h);
+
+ // Apply closures to the strongly and weakly reachable roots in the system
+ // in a single pass.
+ // Record and report timing measurements for sub phases using the worker_i
+ void evacuate_roots(OopClosure* scan_non_heap_roots,
+ OopClosure* scan_non_heap_weak_roots,
+ CLDClosure* scan_strong_clds,
+ CLDClosure* scan_weak_clds,
+ bool trace_metadata,
+ uint worker_i);
+
+ // Apply oops, clds and blobs to all strongly reachable roots in the system
+ void process_strong_roots(OopClosure* oops,
+ CLDClosure* clds,
+ CodeBlobClosure* blobs);
+
+ // Apply oops, clds and blobs to strongly and weakly reachable roots in the system
+ void process_all_roots(OopClosure* oops,
+ CLDClosure* clds,
+ CodeBlobClosure* blobs);
+
+ // Apply scan_rs to all locations in the union of the remembered sets for all
+ // regions in the collection set
+ // (having done "set_region" to indicate the region in which the root resides),
+ void scan_remembered_sets(G1ParPushHeapRSClosure* scan_rs,
+ OopClosure* scan_non_heap_weak_roots,
+ uint worker_i);
+
+ // Inform the root processor about the number of worker threads
+ void set_num_workers(int active_workers);
+};
+
+#endif // SHARE_VM_GC_IMPLEMENTATION_G1_ROOTPROCESSOR_HPP
--- a/hotspot/src/share/vm/gc_implementation/g1/g1StringDedup.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1StringDedup.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -106,7 +106,7 @@
void G1StringDedup::oops_do(OopClosure* keep_alive) {
assert(is_enabled(), "String deduplication not enabled");
- unlink_or_oops_do(NULL, keep_alive);
+ unlink_or_oops_do(NULL, keep_alive, true /* allow_resize_and_rehash */);
}
void G1StringDedup::unlink(BoolObjectClosure* is_alive) {
@@ -123,45 +123,39 @@
class G1StringDedupUnlinkOrOopsDoTask : public AbstractGangTask {
private:
G1StringDedupUnlinkOrOopsDoClosure _cl;
+ G1GCPhaseTimes* _phase_times;
public:
G1StringDedupUnlinkOrOopsDoTask(BoolObjectClosure* is_alive,
OopClosure* keep_alive,
- bool allow_resize_and_rehash) :
+ bool allow_resize_and_rehash,
+ G1GCPhaseTimes* phase_times) :
AbstractGangTask("G1StringDedupUnlinkOrOopsDoTask"),
- _cl(is_alive, keep_alive, allow_resize_and_rehash) {
- }
+ _cl(is_alive, keep_alive, allow_resize_and_rehash), _phase_times(phase_times) { }
virtual void work(uint worker_id) {
- double queue_fixup_start = os::elapsedTime();
- G1StringDedupQueue::unlink_or_oops_do(&_cl);
-
- double table_fixup_start = os::elapsedTime();
- G1StringDedupTable::unlink_or_oops_do(&_cl, worker_id);
-
- double queue_fixup_time_ms = (table_fixup_start - queue_fixup_start) * 1000.0;
- double table_fixup_time_ms = (os::elapsedTime() - table_fixup_start) * 1000.0;
- G1CollectorPolicy* g1p = G1CollectedHeap::heap()->g1_policy();
- g1p->phase_times()->record_string_dedup_queue_fixup_worker_time(worker_id, queue_fixup_time_ms);
- g1p->phase_times()->record_string_dedup_table_fixup_worker_time(worker_id, table_fixup_time_ms);
+ {
+ G1GCParPhaseTimesTracker x(_phase_times, G1GCPhaseTimes::StringDedupQueueFixup, worker_id);
+ G1StringDedupQueue::unlink_or_oops_do(&_cl);
+ }
+ {
+ G1GCParPhaseTimesTracker x(_phase_times, G1GCPhaseTimes::StringDedupTableFixup, worker_id);
+ G1StringDedupTable::unlink_or_oops_do(&_cl, worker_id);
+ }
}
};
-void G1StringDedup::unlink_or_oops_do(BoolObjectClosure* is_alive, OopClosure* keep_alive, bool allow_resize_and_rehash) {
+void G1StringDedup::unlink_or_oops_do(BoolObjectClosure* is_alive,
+ OopClosure* keep_alive,
+ bool allow_resize_and_rehash,
+ G1GCPhaseTimes* phase_times) {
assert(is_enabled(), "String deduplication not enabled");
- G1CollectorPolicy* g1p = G1CollectedHeap::heap()->g1_policy();
- g1p->phase_times()->note_string_dedup_fixup_start();
- double fixup_start = os::elapsedTime();
- G1StringDedupUnlinkOrOopsDoTask task(is_alive, keep_alive, allow_resize_and_rehash);
+ G1StringDedupUnlinkOrOopsDoTask task(is_alive, keep_alive, allow_resize_and_rehash, phase_times);
G1CollectedHeap* g1h = G1CollectedHeap::heap();
g1h->set_par_threads();
g1h->workers()->run_task(&task);
g1h->set_par_threads(0);
-
- double fixup_time_ms = (os::elapsedTime() - fixup_start) * 1000.0;
- g1p->phase_times()->record_string_dedup_fixup_time(fixup_time_ms);
- g1p->phase_times()->note_string_dedup_fixup_end();
}
void G1StringDedup::threads_do(ThreadClosure* tc) {
--- a/hotspot/src/share/vm/gc_implementation/g1/g1StringDedup.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1StringDedup.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -91,6 +91,7 @@
class ThreadClosure;
class outputStream;
class G1StringDedupTable;
+class G1GCPhaseTimes;
//
// Main interface for interacting with string deduplication.
@@ -131,7 +132,7 @@
static void oops_do(OopClosure* keep_alive);
static void unlink(BoolObjectClosure* is_alive);
static void unlink_or_oops_do(BoolObjectClosure* is_alive, OopClosure* keep_alive,
- bool allow_resize_and_rehash = true);
+ bool allow_resize_and_rehash, G1GCPhaseTimes* phase_times = NULL);
static void threads_do(ThreadClosure* tc);
static void print_worker_threads_on(outputStream* st);
--- a/hotspot/src/share/vm/gc_implementation/g1/g1_globals.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1_globals.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -86,7 +86,7 @@
"If true, enable reference discovery during concurrent " \
"marking and reference processing at the end of remark.") \
\
- product(intx, G1SATBBufferSize, 1*K, \
+ product(size_t, G1SATBBufferSize, 1*K, \
"Number of entries in an SATB log buffer.") \
\
develop(intx, G1SATBProcessCompletedThreshold, 20, \
@@ -112,7 +112,7 @@
"Prints the liveness information for all regions in the heap " \
"at the end of a marking cycle.") \
\
- product(intx, G1UpdateBufferSize, 256, \
+ product(size_t, G1UpdateBufferSize, 256, \
"Size of an update buffer") \
\
product(intx, G1ConcRefinementYellowZone, 0, \
@@ -148,7 +148,7 @@
"Select green, yellow and red zones adaptively to meet the " \
"the pause requirements.") \
\
- product(uintx, G1ConcRSLogCacheSize, 10, \
+ product(size_t, G1ConcRSLogCacheSize, 10, \
"Log base 2 of the length of conc RS hot-card cache.") \
\
product(uintx, G1ConcRSHotCardLimit, 4, \
@@ -210,7 +210,7 @@
"When set, G1 will fail when it encounters an FP 'error', " \
"so as to allow debugging") \
\
- product(uintx, G1HeapRegionSize, 0, \
+ product(size_t, G1HeapRegionSize, 0, \
"Size of the G1 regions.") \
\
product(uintx, G1ConcRefinementThreads, 0, \
@@ -220,7 +220,7 @@
develop(bool, G1VerifyCTCleanup, false, \
"Verify card table cleanup.") \
\
- product(uintx, G1RSetScanBlockSize, 64, \
+ product(size_t, G1RSetScanBlockSize, 64, \
"Size of a work unit of cards claimed by a worker thread" \
"during RSet scanning.") \
\
--- a/hotspot/src/share/vm/gc_implementation/g1/g1_specialized_oop_closures.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1_specialized_oop_closures.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,23 +30,8 @@
// non-virtually, using a mechanism defined in this file. Extend these
// macros in the obvious way to add specializations for new closures.
-enum G1Barrier {
- G1BarrierNone,
- G1BarrierEvac,
- G1BarrierKlass
-};
-
-enum G1Mark {
- G1MarkNone,
- G1MarkFromRoot,
- G1MarkPromotedFromRoot
-};
-
// Forward declarations.
-template<G1Barrier barrier, G1Mark do_mark_object>
-class G1ParCopyClosure;
-
class G1ParScanClosure;
class G1ParPushHeapRSClosure;
@@ -61,26 +46,16 @@
class G1InvokeIfNotTriggeredClosure;
class G1UpdateRSOrPushRefOopClosure;
-#ifdef FURTHER_SPECIALIZED_OOP_OOP_ITERATE_CLOSURES
-#error "FURTHER_SPECIALIZED_OOP_OOP_ITERATE_CLOSURES already defined."
-#endif
-
-#define FURTHER_SPECIALIZED_OOP_OOP_ITERATE_CLOSURES(f) \
- f(G1ParScanClosure,_nv) \
- f(G1ParPushHeapRSClosure,_nv) \
- f(FilterIntoCSClosure,_nv) \
- f(FilterOutOfRegionClosure,_nv) \
- f(G1CMOopClosure,_nv) \
- f(G1RootRegionScanClosure,_nv) \
- f(G1Mux2Closure,_nv) \
- f(G1TriggerClosure,_nv) \
- f(G1InvokeIfNotTriggeredClosure,_nv) \
+#define SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_G1(f) \
+ f(G1ParScanClosure,_nv) \
+ f(G1ParPushHeapRSClosure,_nv) \
+ f(FilterIntoCSClosure,_nv) \
+ f(FilterOutOfRegionClosure,_nv) \
+ f(G1CMOopClosure,_nv) \
+ f(G1RootRegionScanClosure,_nv) \
+ f(G1Mux2Closure,_nv) \
+ f(G1TriggerClosure,_nv) \
+ f(G1InvokeIfNotTriggeredClosure,_nv) \
f(G1UpdateRSOrPushRefOopClosure,_nv)
-#ifdef FURTHER_SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES
-#error "FURTHER_SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES already defined."
-#endif
-
-#define FURTHER_SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES(f)
-
#endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1_SPECIALIZED_OOP_CLOSURES_HPP
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -39,8 +39,6 @@
#include "runtime/atomic.inline.hpp"
#include "runtime/orderAccess.inline.hpp"
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
int HeapRegion::LogOfHRGrainBytes = 0;
int HeapRegion::LogOfHRGrainWords = 0;
size_t HeapRegion::GrainBytes = 0;
@@ -106,18 +104,18 @@
}
void HeapRegion::setup_heap_region_size(size_t initial_heap_size, size_t max_heap_size) {
- uintx region_size = G1HeapRegionSize;
+ size_t region_size = G1HeapRegionSize;
if (FLAG_IS_DEFAULT(G1HeapRegionSize)) {
size_t average_heap_size = (initial_heap_size + max_heap_size) / 2;
region_size = MAX2(average_heap_size / HeapRegionBounds::target_number(),
- (uintx) HeapRegionBounds::min_size());
+ HeapRegionBounds::min_size());
}
int region_size_log = log2_long((jlong) region_size);
// Recalculate the region size to make sure it's a power of
// 2. This means that region_size is the largest power of 2 that's
// <= what we've calculated so far.
- region_size = ((uintx)1 << region_size_log);
+ region_size = ((size_t)1 << region_size_log);
// Now make sure that we don't go over or under our limits.
if (region_size < HeapRegionBounds::min_size()) {
@@ -139,7 +137,7 @@
guarantee(GrainBytes == 0, "we should only set it once");
// The cast to int is safe, given that we've bounded region_size by
// MIN_REGION_SIZE and MAX_REGION_SIZE.
- GrainBytes = (size_t)region_size;
+ GrainBytes = region_size;
guarantee(GrainWords == 0, "we should only set it once");
GrainWords = GrainBytes >> LogHeapWordSize;
@@ -505,7 +503,7 @@
gclog_or_tty->print_cr("Object "PTR_FORMAT" in region "
"["PTR_FORMAT", "PTR_FORMAT") is above "
"top "PTR_FORMAT,
- (void *)obj, _hr->bottom(), _hr->end(), _hr->top());
+ p2i(obj), p2i(_hr->bottom()), p2i(_hr->end()), p2i(_hr->top()));
_failures = true;
return;
}
@@ -540,7 +538,7 @@
if (!nm->is_alive()) {
gclog_or_tty->print_cr("region ["PTR_FORMAT","PTR_FORMAT"] has dead nmethod "
PTR_FORMAT" in its strong code roots",
- _hr->bottom(), _hr->end(), nm);
+ p2i(_hr->bottom()), p2i(_hr->end()), p2i(nm));
_failures = true;
} else {
VerifyStrongCodeRootOopClosure oop_cl(_hr, nm);
@@ -549,12 +547,12 @@
gclog_or_tty->print_cr("region ["PTR_FORMAT","PTR_FORMAT"] has nmethod "
PTR_FORMAT" in its strong code roots "
"with no pointers into region",
- _hr->bottom(), _hr->end(), nm);
+ p2i(_hr->bottom()), p2i(_hr->end()), p2i(nm));
_failures = true;
} else if (oop_cl.failures()) {
gclog_or_tty->print_cr("region ["PTR_FORMAT","PTR_FORMAT"] has other "
"failures for nmethod "PTR_FORMAT,
- _hr->bottom(), _hr->end(), nm);
+ p2i(_hr->bottom()), p2i(_hr->end()), p2i(nm));
_failures = true;
}
}
@@ -589,7 +587,7 @@
if (strong_code_roots_length > 0) {
gclog_or_tty->print_cr("region ["PTR_FORMAT","PTR_FORMAT"] is empty "
"but has "SIZE_FORMAT" code root entries",
- bottom(), end(), strong_code_roots_length);
+ p2i(bottom()), p2i(end()), strong_code_roots_length);
*failures = true;
}
return;
@@ -624,7 +622,7 @@
st->print(" ");
st->print(" TS %5d", _gc_time_stamp);
st->print(" PTAMS "PTR_FORMAT" NTAMS "PTR_FORMAT,
- prev_top_at_mark_start(), next_top_at_mark_start());
+ p2i(prev_top_at_mark_start()), p2i(next_top_at_mark_start()));
G1OffsetTableContigSpace::print_on(st);
}
@@ -687,23 +685,23 @@
gclog_or_tty->print_cr("Field "PTR_FORMAT
" of live obj "PTR_FORMAT" in region "
"["PTR_FORMAT", "PTR_FORMAT")",
- p, (void*) _containing_obj,
- from->bottom(), from->end());
+ p2i(p), p2i(_containing_obj),
+ p2i(from->bottom()), p2i(from->end()));
print_object(gclog_or_tty, _containing_obj);
gclog_or_tty->print_cr("points to obj "PTR_FORMAT" not in the heap",
- (void*) obj);
+ p2i(obj));
} else {
HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p);
HeapRegion* to = _g1h->heap_region_containing((HeapWord*)obj);
gclog_or_tty->print_cr("Field "PTR_FORMAT
" of live obj "PTR_FORMAT" in region "
"["PTR_FORMAT", "PTR_FORMAT")",
- p, (void*) _containing_obj,
- from->bottom(), from->end());
+ p2i(p), p2i(_containing_obj),
+ p2i(from->bottom()), p2i(from->end()));
print_object(gclog_or_tty, _containing_obj);
gclog_or_tty->print_cr("points to dead obj "PTR_FORMAT" in region "
"["PTR_FORMAT", "PTR_FORMAT")",
- (void*) obj, to->bottom(), to->end());
+ p2i(obj), p2i(to->bottom()), p2i(to->end()));
print_object(gclog_or_tty, obj);
}
gclog_or_tty->print_cr("----------");
@@ -741,12 +739,12 @@
gclog_or_tty->print_cr("Field "PTR_FORMAT" "
"of obj "PTR_FORMAT", "
"in region "HR_FORMAT,
- p, (void*) _containing_obj,
+ p2i(p), p2i(_containing_obj),
HR_FORMAT_PARAMS(from));
_containing_obj->print_on(gclog_or_tty);
gclog_or_tty->print_cr("points to obj "PTR_FORMAT" "
"in region "HR_FORMAT,
- (void*) obj,
+ p2i(obj),
HR_FORMAT_PARAMS(to));
obj->print_on(gclog_or_tty);
gclog_or_tty->print_cr("Obj head CTE = %d, field CTE = %d.",
@@ -783,7 +781,7 @@
!g1->is_obj_dead(obj, this)) { // Dead objects may have bigger block_size since they span several objects.
gclog_or_tty->print_cr("obj "PTR_FORMAT" is of %shumongous size ("
SIZE_FORMAT" words) in a %shumongous region",
- p, g1->is_humongous(obj_size) ? "" : "non-",
+ p2i(p), g1->is_humongous(obj_size) ? "" : "non-",
obj_size, is_region_humongous ? "" : "non-");
*failures = true;
return;
@@ -797,12 +795,12 @@
ClassLoaderDataGraph::unload_list_contains(klass));
if (!is_metaspace_object) {
gclog_or_tty->print_cr("klass "PTR_FORMAT" of object "PTR_FORMAT" "
- "not metadata", klass, (void *)obj);
+ "not metadata", p2i(klass), p2i(obj));
*failures = true;
return;
} else if (!klass->is_klass()) {
gclog_or_tty->print_cr("klass "PTR_FORMAT" of object "PTR_FORMAT" "
- "not a klass", klass, (void *)obj);
+ "not a klass", p2i(klass), p2i(obj));
*failures = true;
return;
} else {
@@ -817,7 +815,7 @@
}
}
} else {
- gclog_or_tty->print_cr(PTR_FORMAT" no an oop", (void *)obj);
+ gclog_or_tty->print_cr(PTR_FORMAT" no an oop", p2i(obj));
*failures = true;
return;
}
@@ -832,7 +830,7 @@
if (p != top()) {
gclog_or_tty->print_cr("end of last object "PTR_FORMAT" "
- "does not match top "PTR_FORMAT, p, top());
+ "does not match top "PTR_FORMAT, p2i(p), p2i(top()));
*failures = true;
return;
}
@@ -849,7 +847,7 @@
if (b_start_1 != p) {
gclog_or_tty->print_cr("BOT look up for top: "PTR_FORMAT" "
" yielded "PTR_FORMAT", expecting "PTR_FORMAT,
- addr_1, b_start_1, p);
+ p2i(addr_1), p2i(b_start_1), p2i(p));
*failures = true;
return;
}
@@ -861,7 +859,7 @@
if (b_start_2 != p) {
gclog_or_tty->print_cr("BOT look up for top + 1: "PTR_FORMAT" "
" yielded "PTR_FORMAT", expecting "PTR_FORMAT,
- addr_2, b_start_2, p);
+ p2i(addr_2), p2i(b_start_2), p2i(p));
*failures = true;
return;
}
@@ -875,7 +873,7 @@
if (b_start_3 != p) {
gclog_or_tty->print_cr("BOT look up for top + diff: "PTR_FORMAT" "
" yielded "PTR_FORMAT", expecting "PTR_FORMAT,
- addr_3, b_start_3, p);
+ p2i(addr_3), p2i(b_start_3), p2i(p));
*failures = true;
return;
}
@@ -887,7 +885,7 @@
if (b_start_4 != p) {
gclog_or_tty->print_cr("BOT look up for end - 1: "PTR_FORMAT" "
" yielded "PTR_FORMAT", expecting "PTR_FORMAT,
- addr_4, b_start_4, p);
+ p2i(addr_4), p2i(b_start_4), p2i(p));
*failures = true;
return;
}
@@ -896,7 +894,7 @@
if (is_region_humongous && object_num > 1) {
gclog_or_tty->print_cr("region ["PTR_FORMAT","PTR_FORMAT"] is humongous "
"but has "SIZE_FORMAT", objects",
- bottom(), end(), object_num);
+ p2i(bottom()), p2i(end()), object_num);
*failures = true;
return;
}
@@ -933,11 +931,21 @@
_offsets.resize(new_end - bottom());
}
+#ifndef PRODUCT
+void G1OffsetTableContigSpace::mangle_unused_area() {
+ mangle_unused_area_complete();
+}
+
+void G1OffsetTableContigSpace::mangle_unused_area_complete() {
+ SpaceMangler::mangle_region(MemRegion(top(), end()));
+}
+#endif
+
void G1OffsetTableContigSpace::print() const {
print_short();
gclog_or_tty->print_cr(" [" INTPTR_FORMAT ", " INTPTR_FORMAT ", "
INTPTR_FORMAT ", " INTPTR_FORMAT ")",
- bottom(), top(), _offsets.threshold(), end());
+ p2i(bottom()), p2i(top()), p2i(_offsets.threshold()), p2i(end()));
}
HeapWord* G1OffsetTableContigSpace::initialize_threshold() {
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -27,7 +27,6 @@
#include "gc_implementation/g1/g1AllocationContext.hpp"
#include "gc_implementation/g1/g1BlockOffsetTable.hpp"
-#include "gc_implementation/g1/g1_specialized_oop_closures.hpp"
#include "gc_implementation/g1/heapRegionType.hpp"
#include "gc_implementation/g1/survRateGroup.hpp"
#include "gc_implementation/shared/ageTable.hpp"
@@ -155,6 +154,9 @@
void set_bottom(HeapWord* value);
void set_end(HeapWord* value);
+ void mangle_unused_area() PRODUCT_RETURN;
+ void mangle_unused_area_complete() PRODUCT_RETURN;
+
HeapWord* scan_top() const;
void record_timestamp();
void reset_gc_time_stamp() { _gc_time_stamp = 0; }
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionManager.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionManager.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -145,6 +145,24 @@
}
}
+MemoryUsage HeapRegionManager::get_auxiliary_data_memory_usage() const {
+ size_t used_sz =
+ _prev_bitmap_mapper->committed_size() +
+ _next_bitmap_mapper->committed_size() +
+ _bot_mapper->committed_size() +
+ _cardtable_mapper->committed_size() +
+ _card_counts_mapper->committed_size();
+
+ size_t committed_sz =
+ _prev_bitmap_mapper->reserved_size() +
+ _next_bitmap_mapper->reserved_size() +
+ _bot_mapper->reserved_size() +
+ _cardtable_mapper->reserved_size() +
+ _card_counts_mapper->reserved_size();
+
+ return MemoryUsage(0, used_sz, committed_sz, committed_sz);
+}
+
uint HeapRegionManager::expand_by(uint num_regions) {
return expand_at(0, num_regions);
}
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionManager.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionManager.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,7 @@
#include "gc_implementation/g1/g1BiasedArray.hpp"
#include "gc_implementation/g1/g1RegionToSpaceMapper.hpp"
#include "gc_implementation/g1/heapRegionSet.hpp"
+#include "services/memoryUsage.hpp"
class HeapRegion;
class HeapRegionClosure;
@@ -196,6 +197,8 @@
// Return the maximum number of regions in the heap.
uint max_length() const { return (uint)_regions.length(); }
+ MemoryUsage get_auxiliary_data_memory_usage() const;
+
MemRegion reserved() const { return MemRegion(heap_bottom(), heap_end()); }
// Expand the sequence to reflect that the heap has grown. Either create new
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -37,8 +37,6 @@
#include "utilities/globalDefinitions.hpp"
#include "utilities/growableArray.hpp"
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
class PerRegionTable: public CHeapObj<mtGC> {
friend class OtherRegionsTable;
friend class HeapRegionRemSetIterator;
@@ -93,10 +91,10 @@
if (G1TraceHeapRegionRememberedSet) {
gclog_or_tty->print_cr(" PRT::Add_reference_work(" PTR_FORMAT "->" PTR_FORMAT").",
- from,
+ p2i(from),
UseCompressedOops
- ? (void *)oopDesc::load_decode_heap_oop((narrowOop*)from)
- : (void *)oopDesc::load_decode_heap_oop((oop*)from));
+ ? p2i(oopDesc::load_decode_heap_oop((narrowOop*)from))
+ : p2i(oopDesc::load_decode_heap_oop((oop*)from)));
}
HeapRegion* loc_hr = hr();
@@ -412,17 +410,17 @@
if (G1TraceHeapRegionRememberedSet) {
gclog_or_tty->print_cr("ORT::add_reference_work(" PTR_FORMAT "->" PTR_FORMAT ").",
- from,
+ p2i(from),
UseCompressedOops
- ? (void *)oopDesc::load_decode_heap_oop((narrowOop*)from)
- : (void *)oopDesc::load_decode_heap_oop((oop*)from));
+ ? p2i(oopDesc::load_decode_heap_oop((narrowOop*)from))
+ : p2i(oopDesc::load_decode_heap_oop((oop*)from)));
}
int from_card = (int)(uintptr_t(from) >> CardTableModRefBS::card_shift);
if (G1TraceHeapRegionRememberedSet) {
gclog_or_tty->print_cr("Table for [" PTR_FORMAT "...): card %d (cache = %d)",
- _hr->bottom(), from_card,
+ p2i(_hr->bottom()), from_card,
FromCardCache::at(tid, cur_hrm_ind));
}
@@ -471,7 +469,7 @@
"[" PTR_FORMAT "...) for ref " PTR_FORMAT ".\n",
align_size_down(uintptr_t(from),
CardTableModRefBS::card_size),
- _hr->bottom(), from);
+ p2i(_hr->bottom()), p2i(from));
}
}
if (G1TraceHeapRegionRememberedSet) {
@@ -533,7 +531,7 @@
"[" PTR_FORMAT "...) for ref " PTR_FORMAT ".\n",
align_size_down(uintptr_t(from),
CardTableModRefBS::card_size),
- _hr->bottom(), from);
+ p2i(_hr->bottom()), p2i(from));
}
}
assert(contains_reference(from), "We just added it!");
@@ -602,8 +600,8 @@
if (G1TraceHeapRegionRememberedSet) {
gclog_or_tty->print("Coarsened entry in region [" PTR_FORMAT "...] "
"for region [" PTR_FORMAT "...] (" SIZE_FORMAT " coarse entries).\n",
- _hr->bottom(),
- max->hr()->bottom(),
+ p2i(_hr->bottom()),
+ p2i(max->hr()->bottom()),
_n_coarse_entries);
}
}
@@ -857,7 +855,7 @@
while (iter.has_next(card_index)) {
HeapWord* card_start =
G1CollectedHeap::heap()->bot_shared()->address_for_index(card_index);
- gclog_or_tty->print_cr(" Card " PTR_FORMAT, card_start);
+ gclog_or_tty->print_cr(" Card " PTR_FORMAT, p2i(card_start));
}
if (iter.n_yielded() != occupied()) {
gclog_or_tty->print_cr("Yielded disagrees with occupied:");
@@ -1152,8 +1150,8 @@
}
gclog_or_tty->print("Added card " PTR_FORMAT " to region [" PTR_FORMAT "...]"
" for ref " PTR_FORMAT ".\n",
- _recorded_cards[i], _recorded_regions[i]->bottom(),
- _recorded_oops[i]);
+ p2i(_recorded_cards[i]), p2i(_recorded_regions[i]->bottom()),
+ p2i(_recorded_oops[i]));
}
}
@@ -1240,7 +1238,7 @@
while (iter.has_next(card_index)) {
HeapWord* card_start =
G1CollectedHeap::heap()->bot_shared()->address_for_index(card_index);
- gclog_or_tty->print_cr(" Card " PTR_FORMAT ".", card_start);
+ gclog_or_tty->print_cr(" Card " PTR_FORMAT ".", p2i(card_start));
sum++;
}
guarantee(sum == 11 - 3 + 2048, "Failure");
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionSet.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionSet.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -27,8 +27,6 @@
#include "gc_implementation/g1/heapRegionRemSet.hpp"
#include "gc_implementation/g1/heapRegionSet.inline.hpp"
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
uint FreeRegionList::_unrealistically_long_length = 0;
void HeapRegionSetBase::fill_in_ext_msg(hrs_ext_msg* msg, const char* message) {
@@ -84,7 +82,7 @@
void HeapRegionSetBase::print_on(outputStream* out, bool print_contents) {
out->cr();
- out->print_cr("Set: %s ("PTR_FORMAT")", name(), this);
+ out->print_cr("Set: %s ("PTR_FORMAT")", name(), p2i(this));
out->print_cr(" Region Assumptions");
out->print_cr(" humongous : %s", BOOL_TO_STR(regions_humongous()));
out->print_cr(" free : %s", BOOL_TO_STR(regions_free()));
@@ -106,7 +104,7 @@
}
void FreeRegionList::fill_in_ext_msg_extra(hrs_ext_msg* msg) {
- msg->append(" hd: "PTR_FORMAT" tl: "PTR_FORMAT, _head, _tail);
+ msg->append(" hd: "PTR_FORMAT" tl: "PTR_FORMAT, p2i(_head), p2i(_tail));
}
void FreeRegionList::remove_all() {
@@ -277,8 +275,8 @@
void FreeRegionList::print_on(outputStream* out, bool print_contents) {
HeapRegionSetBase::print_on(out, print_contents);
out->print_cr(" Linking");
- out->print_cr(" head : "PTR_FORMAT, _head);
- out->print_cr(" tail : "PTR_FORMAT, _tail);
+ out->print_cr(" head : "PTR_FORMAT, p2i(_head));
+ out->print_cr(" tail : "PTR_FORMAT, p2i(_tail));
if (print_contents) {
out->print_cr(" Contents");
@@ -306,7 +304,8 @@
count++;
guarantee(count < _unrealistically_long_length,
- hrs_err_msg("[%s] the calculated length: %u seems very long, is there maybe a cycle? curr: "PTR_FORMAT" prev0: "PTR_FORMAT" " "prev1: "PTR_FORMAT" length: %u", name(), count, curr, prev0, prev1, length()));
+ hrs_err_msg("[%s] the calculated length: %u seems very long, is there maybe a cycle? curr: "PTR_FORMAT" prev0: "PTR_FORMAT" " "prev1: "PTR_FORMAT" length: %u",
+ name(), count, p2i(curr), p2i(prev0), p2i(prev1), length()));
if (curr->next() != NULL) {
guarantee(curr->next()->prev() == curr, "Next or prev pointers messed up");
--- a/hotspot/src/share/vm/gc_implementation/g1/satbQueue.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/satbQueue.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -32,8 +32,6 @@
#include "runtime/thread.hpp"
#include "runtime/vmThread.hpp"
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
void ObjPtrQueue::flush() {
// The buffer might contain refs into the CSet. We have to filter it
// first before we flush it, otherwise we might end up with an
@@ -182,7 +180,7 @@
void** buf, size_t index, size_t sz) {
gclog_or_tty->print_cr(" SATB BUFFER [%s] buf: "PTR_FORMAT" "
"index: "SIZE_FORMAT" sz: "SIZE_FORMAT,
- name, buf, index, sz);
+ name, p2i(buf), index, sz);
}
#endif // PRODUCT
--- a/hotspot/src/share/vm/gc_implementation/g1/survRateGroup.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/survRateGroup.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -29,8 +29,6 @@
#include "gc_implementation/g1/survRateGroup.hpp"
#include "memory/allocation.hpp"
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
SurvRateGroup::SurvRateGroup(G1CollectorPolicy* g1p,
const char* name,
size_t summary_surv_rates_len) :
--- a/hotspot/src/share/vm/gc_implementation/parNew/parCardTableModRefBS.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parNew/parCardTableModRefBS.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -36,8 +36,6 @@
#include "runtime/virtualspace.hpp"
#include "runtime/vmThread.hpp"
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
void CardTableModRefBS::non_clean_card_iterate_parallel_work(Space* sp, MemRegion mr,
OopsInGenClosure* cl,
CardTableRS* ct,
@@ -153,8 +151,7 @@
// result of the dirty card iteration below.
OrderAccess::storestore();
- // We do not call the non_clean_card_iterate_serial() version because
- // we want to clear the cards: clear_cl here does the work of finding
+ // We want to clear the cards: clear_cl here does the work of finding
// contiguous dirty ranges of cards to process and clear.
clear_cl.do_MemRegion(chunk_mr);
@@ -376,13 +373,14 @@
" does not exceed used.end() = " PTR_FORMAT ","
" yet last_chunk_index_to_check " INTPTR_FORMAT
" exceeds last_chunk_index " INTPTR_FORMAT,
- last_block, last_block + last_block_size,
- used.end(),
+ p2i(last_block), p2i(last_block + last_block_size),
+ p2i(used.end()),
last_chunk_index_to_check, last_chunk_index));
assert(sp->used_region().end() > used.end(),
err_msg("Expansion did not happen: "
"[" PTR_FORMAT "," PTR_FORMAT ") -> [" PTR_FORMAT "," PTR_FORMAT ")",
- sp->used_region().start(), sp->used_region().end(), used.start(), used.end()));
+ p2i(sp->used_region().start()), p2i(sp->used_region().end()),
+ p2i(used.start()), p2i(used.end())));
NOISY(tty->print_cr(" process_chunk_boundary: heap expanded; explicitly bounding last_chunk");)
last_chunk_index_to_check = last_chunk_index;
}
--- a/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -23,6 +23,7 @@
*/
#include "precompiled.hpp"
+#include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp"
#include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp"
#include "gc_implementation/parNew/parNewGeneration.hpp"
#include "gc_implementation/parNew/parOopClosures.inline.hpp"
@@ -45,7 +46,6 @@
#include "memory/space.hpp"
#include "oops/objArrayOop.hpp"
#include "oops/oop.inline.hpp"
-#include "oops/oop.pcgc.inline.hpp"
#include "runtime/atomic.inline.hpp"
#include "runtime/handles.hpp"
#include "runtime/handles.inline.hpp"
@@ -55,8 +55,6 @@
#include "utilities/globalDefinitions.hpp"
#include "utilities/workgroup.hpp"
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
#ifdef _MSC_VER
#pragma warning( push )
#pragma warning( disable:4355 ) // 'this' : used in base member initializer list
@@ -325,7 +323,7 @@
private:
ParallelTaskTerminator& _term;
ParNewGeneration& _gen;
- Generation& _next_gen;
+ Generation& _old_gen;
public:
bool is_valid(int id) const { return id < length(); }
ParallelTaskTerminator* terminator() { return &_term; }
@@ -338,7 +336,7 @@
Stack<oop, mtGC>* overflow_stacks,
size_t desired_plab_sz, ParallelTaskTerminator& term)
: ResourceArray(sizeof(ParScanThreadState), num_threads),
- _gen(gen), _next_gen(old_gen), _term(term)
+ _gen(gen), _old_gen(old_gen), _term(term)
{
assert(num_threads > 0, "sanity check!");
assert(ParGCUseLocalOverflow == (overflow_stacks != NULL),
@@ -471,8 +469,8 @@
_gen.age_table()->merge(local_table);
// Inform old gen that we're done.
- _next_gen.par_promote_alloc_done(i);
- _next_gen.par_oop_since_save_marks_iterate_done(i);
+ _old_gen.par_promote_alloc_done(i);
+ _old_gen.par_oop_since_save_marks_iterate_done(i);
}
if (UseConcMarkSweepGC) {
@@ -574,10 +572,10 @@
par_scan_state()->end_term_time();
}
-ParNewGenTask::ParNewGenTask(ParNewGeneration* gen, Generation* next_gen,
- HeapWord* young_old_boundary, ParScanThreadStateSet* state_set) :
+ParNewGenTask::ParNewGenTask(ParNewGeneration* gen, Generation* old_gen,
+ HeapWord* young_old_boundary, ParScanThreadStateSet* state_set) :
AbstractGangTask("ParNewGeneration collection"),
- _gen(gen), _next_gen(next_gen),
+ _gen(gen), _old_gen(old_gen),
_young_old_boundary(young_old_boundary),
_state_set(state_set)
{}
@@ -601,8 +599,6 @@
// We would need multiple old-gen queues otherwise.
assert(gch->n_gens() == 2, "Par young collection currently only works with one older gen.");
- Generation* old_gen = gch->next_gen(_gen);
-
ParScanThreadState& par_scan_state = _state_set->thread_state(worker_id);
assert(_state_set->is_valid(worker_id), "Should not have been called");
@@ -619,7 +615,7 @@
true, // Process younger gens, if any,
// as strong roots.
false, // no scope; this is parallel code
- SharedHeap::SO_ScavengeCodeCache,
+ GenCollectedHeap::SO_ScavengeCodeCache,
GenCollectedHeap::StrongAndWeakRoots,
&par_scan_state.to_space_root_closure(),
&par_scan_state.older_gen_closure(),
@@ -763,8 +759,9 @@
class ParNewRefProcTaskProxy: public AbstractGangTask {
typedef AbstractRefProcTaskExecutor::ProcessTask ProcessTask;
public:
- ParNewRefProcTaskProxy(ProcessTask& task, ParNewGeneration& gen,
- Generation& next_gen,
+ ParNewRefProcTaskProxy(ProcessTask& task,
+ ParNewGeneration& gen,
+ Generation& old_gen,
HeapWord* young_old_boundary,
ParScanThreadStateSet& state_set);
@@ -776,20 +773,20 @@
private:
ParNewGeneration& _gen;
ProcessTask& _task;
- Generation& _next_gen;
+ Generation& _old_gen;
HeapWord* _young_old_boundary;
ParScanThreadStateSet& _state_set;
};
-ParNewRefProcTaskProxy::ParNewRefProcTaskProxy(
- ProcessTask& task, ParNewGeneration& gen,
- Generation& next_gen,
- HeapWord* young_old_boundary,
- ParScanThreadStateSet& state_set)
+ParNewRefProcTaskProxy::ParNewRefProcTaskProxy(ProcessTask& task,
+ ParNewGeneration& gen,
+ Generation& old_gen,
+ HeapWord* young_old_boundary,
+ ParScanThreadStateSet& state_set)
: AbstractGangTask("ParNewGeneration parallel reference processing"),
_gen(gen),
_task(task),
- _next_gen(next_gen),
+ _old_gen(old_gen),
_young_old_boundary(young_old_boundary),
_state_set(state_set)
{
@@ -893,7 +890,7 @@
from()->set_next_compaction_space(to());
gch->set_incremental_collection_failed();
// Inform the next generation that a promotion failure occurred.
- _next_gen->promotion_failure_occurred();
+ _old_gen->promotion_failure_occurred();
// Trace promotion failure in the parallel GC threads
thread_state_set.trace_promotion_failed(gc_tracer());
@@ -927,7 +924,7 @@
workers->set_active_workers(active_workers);
assert(gch->n_gens() == 2,
"Par collection currently only works with single older gen.");
- _next_gen = gch->next_gen(this);
+ _old_gen = gch->old_gen();
// If the next generation is too full to accommodate worst-case promotion
// from this generation, pass on collection; let the next generation
@@ -952,8 +949,6 @@
// Capture heap used before collection (for printing).
size_t gch_prev_used = gch->used();
- SpecializationStats::clear();
-
age_table()->clear();
to()->clear(SpaceDecorator::Mangle);
@@ -968,10 +963,10 @@
// because only those workers go through the termination protocol.
ParallelTaskTerminator _term(n_workers, task_queues());
ParScanThreadStateSet thread_state_set(workers->active_workers(),
- *to(), *this, *_next_gen, *task_queues(),
+ *to(), *this, *_old_gen, *task_queues(),
_overflow_stacks, desired_plab_sz(), _term);
- ParNewGenTask tsk(this, _next_gen, reserved().end(), &thread_state_set);
+ ParNewGenTask tsk(this, _old_gen, reserved().end(), &thread_state_set);
gch->set_par_threads(n_workers);
gch->rem_set()->prepare_for_younger_refs_iterate(true);
// It turns out that even when we're using 1 thread, doing the work in a
@@ -1073,8 +1068,6 @@
jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
update_time_of_last_gc(now);
- SpecializationStats::print();
-
rp->set_enqueuing_is_done(true);
if (rp->processing_is_mt()) {
ParNewRefProcTaskExecutor task_executor(*this, thread_state_set);
@@ -1127,14 +1120,6 @@
return forward_ptr;
}
-#ifdef ASSERT
-bool ParNewGeneration::is_legal_forward_ptr(oop p) {
- return
- (p == ClaimedForwardPtr)
- || Universe::heap()->is_in_reserved(p);
-}
-#endif
-
void ParNewGeneration::preserve_mark_if_necessary(oop obj, markOop m) {
if (m->must_be_preserved_for_promotion_failure(obj)) {
// We should really have separate per-worker stacks, rather
@@ -1191,8 +1176,8 @@
}
if (!_promotion_failed) {
- new_obj = _next_gen->par_promote(par_scan_state->thread_num(),
- old, m, sz);
+ new_obj = _old_gen->par_promote(par_scan_state->thread_num(),
+ old, m, sz);
}
if (new_obj == NULL) {
@@ -1209,6 +1194,7 @@
} else {
// Is in to-space; do copying ourselves.
Copy::aligned_disjoint_words((HeapWord*)old, (HeapWord*)new_obj, sz);
+ assert(Universe::heap()->is_in_reserved(new_obj), "illegal forwarding pointer value.");
forward_ptr = old->forward_to_atomic(new_obj);
// Restore the mark word copied above.
new_obj->set_mark(m);
@@ -1224,7 +1210,7 @@
if (TraceScavenge) {
gclog_or_tty->print_cr("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
is_in_reserved(new_obj) ? "copying" : "tenuring",
- new_obj->klass()->internal_name(), (void *)old, (void *)new_obj, new_obj->size());
+ new_obj->klass()->internal_name(), p2i(old), p2i(new_obj), new_obj->size());
}
#endif
--- a/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
#ifndef SHARE_VM_GC_IMPLEMENTATION_PARNEW_PARNEWGENERATION_HPP
#define SHARE_VM_GC_IMPLEMENTATION_PARNEW_PARNEWGENERATION_HPP
+#include "gc_implementation/parNew/parOopClosures.hpp"
#include "gc_implementation/shared/gcTrace.hpp"
#include "gc_implementation/shared/parGCAllocBuffer.hpp"
#include "gc_implementation/shared/copyFailedInfo.hpp"
@@ -233,13 +234,13 @@
class ParNewGenTask: public AbstractGangTask {
private:
ParNewGeneration* _gen;
- Generation* _next_gen;
+ Generation* _old_gen;
HeapWord* _young_old_boundary;
class ParScanThreadStateSet* _state_set;
public:
ParNewGenTask(ParNewGeneration* gen,
- Generation* next_gen,
+ Generation* old_gen,
HeapWord* young_old_boundary,
ParScanThreadStateSet* state_set);
@@ -419,8 +420,6 @@
}
static oop real_forwardee(oop obj);
-
- DEBUG_ONLY(static bool is_legal_forward_ptr(oop p);)
};
#endif // SHARE_VM_GC_IMPLEMENTATION_PARNEW_PARNEWGENERATION_HPP
--- a/hotspot/src/share/vm/gc_implementation/parNew/parOopClosures.inline.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parNew/parOopClosures.inline.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,7 @@
#include "gc_implementation/parNew/parOopClosures.hpp"
#include "memory/cardTableRS.hpp"
#include "memory/genCollectedHeap.hpp"
+#include "memory/genOopClosures.inline.hpp"
template <class T> inline void ParScanWeakRefClosure::do_oop_work(T* p) {
assert (!oopDesc::is_null(*p), "null weak reference?");
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/cardTableExtension.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/cardTableExtension.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -26,12 +26,11 @@
#include "gc_implementation/parallelScavenge/cardTableExtension.hpp"
#include "gc_implementation/parallelScavenge/gcTaskManager.hpp"
#include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
-#include "gc_implementation/parallelScavenge/psPromotionManager.hpp"
+#include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
#include "gc_implementation/parallelScavenge/psScavenge.hpp"
#include "gc_implementation/parallelScavenge/psTasks.hpp"
#include "gc_implementation/parallelScavenge/psYoungGen.hpp"
#include "oops/oop.inline.hpp"
-#include "oops/oop.psgc.inline.hpp"
#include "runtime/prefetch.inline.hpp"
// Checks an individual oop for missing precise marks. Mark
@@ -291,7 +290,7 @@
Prefetch::write(p, interval);
oop m = oop(p);
assert(m->is_oop_or_null(), err_msg("Expected an oop or NULL for header field at " PTR_FORMAT, p2i(m)));
- m->push_contents(pm);
+ pm->push_contents(m);
p += m->size();
}
pm->drain_stacks_cond_depth();
@@ -299,7 +298,7 @@
while (p < to) {
oop m = oop(p);
assert(m->is_oop_or_null(), err_msg("Expected an oop or NULL for header field at " PTR_FORMAT, p2i(m)));
- m->push_contents(pm);
+ pm->push_contents(m);
p += m->size();
}
pm->drain_stacks_cond_depth();
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/gcTaskManager.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/gcTaskManager.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -32,8 +32,6 @@
#include "runtime/mutexLocker.hpp"
#include "runtime/orderAccess.inline.hpp"
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
//
// GCTask
//
@@ -101,7 +99,7 @@
NOT_PRODUCT(
void GCTask::print(const char* message) const {
tty->print(INTPTR_FORMAT " <- " INTPTR_FORMAT "(%u) -> " INTPTR_FORMAT,
- newer(), this, affinity(), older());
+ p2i(newer()), p2i(this), affinity(), p2i(older()));
}
)
@@ -113,7 +111,7 @@
GCTaskQueue* result = new GCTaskQueue(false);
if (TraceGCTaskQueue) {
tty->print_cr("GCTaskQueue::create()"
- " returns " INTPTR_FORMAT, result);
+ " returns " INTPTR_FORMAT, p2i(result));
}
return result;
}
@@ -123,7 +121,7 @@
if (TraceGCTaskQueue) {
tty->print_cr("GCTaskQueue::create_on_c_heap()"
" returns " INTPTR_FORMAT,
- result);
+ p2i(result));
}
return result;
}
@@ -134,7 +132,7 @@
if (TraceGCTaskQueue) {
tty->print_cr("[" INTPTR_FORMAT "]"
" GCTaskQueue::GCTaskQueue() constructor",
- this);
+ p2i(this));
}
}
@@ -147,7 +145,7 @@
tty->print_cr("[" INTPTR_FORMAT "]"
" GCTaskQueue::destroy()"
" is_c_heap_obj: %s",
- that,
+ p2i(that),
that->is_c_heap_obj() ? "true" : "false");
}
// That instance may have been allocated as a CHeapObj,
@@ -173,7 +171,7 @@
tty->print_cr("[" INTPTR_FORMAT "]"
" GCTaskQueue::enqueue(task: "
INTPTR_FORMAT ")",
- this, task);
+ p2i(this), p2i(task));
print("before:");
}
assert(task != NULL, "shouldn't have null task");
@@ -200,7 +198,7 @@
tty->print_cr("[" INTPTR_FORMAT "]"
" GCTaskQueue::enqueue(list: "
INTPTR_FORMAT ")",
- this, list);
+ p2i(this), p2i(list));
print("before:");
list->print("list:");
}
@@ -234,14 +232,14 @@
GCTask* GCTaskQueue::dequeue() {
if (TraceGCTaskQueue) {
tty->print_cr("[" INTPTR_FORMAT "]"
- " GCTaskQueue::dequeue()", this);
+ " GCTaskQueue::dequeue()", p2i(this));
print("before:");
}
assert(!is_empty(), "shouldn't dequeue from empty list");
GCTask* result = remove();
assert(result != NULL, "shouldn't have NULL task");
if (TraceGCTaskQueue) {
- tty->print_cr(" return: " INTPTR_FORMAT, result);
+ tty->print_cr(" return: " INTPTR_FORMAT, p2i(result));
print("after:");
}
return result;
@@ -251,7 +249,7 @@
GCTask* GCTaskQueue::dequeue(uint affinity) {
if (TraceGCTaskQueue) {
tty->print_cr("[" INTPTR_FORMAT "]"
- " GCTaskQueue::dequeue(%u)", this, affinity);
+ " GCTaskQueue::dequeue(%u)", p2i(this), affinity);
print("before:");
}
assert(!is_empty(), "shouldn't dequeue from empty list");
@@ -275,7 +273,7 @@
result = remove();
}
if (TraceGCTaskQueue) {
- tty->print_cr(" return: " INTPTR_FORMAT, result);
+ tty->print_cr(" return: " INTPTR_FORMAT, p2i(result));
print("after:");
}
return result;
@@ -345,7 +343,7 @@
" remove_end: " INTPTR_FORMAT
" length: %d"
" %s",
- this, insert_end(), remove_end(), length(), message);
+ p2i(this), p2i(insert_end()), p2i(remove_end()), length(), message);
uint count = 0;
for (GCTask* element = insert_end();
element != NULL;
@@ -486,7 +484,7 @@
assert(!all_workers_active() || active_workers() == ParallelGCThreads,
err_msg("all_workers_active() is incorrect: "
- "active %d ParallelGCThreads %d", active_workers(),
+ "active %d ParallelGCThreads " UINTX_FORMAT, active_workers(),
ParallelGCThreads));
if (TraceDynamicGCThreads) {
gclog_or_tty->print_cr("GCTaskManager::set_active_gang(): "
@@ -598,7 +596,7 @@
MutexLockerEx ml(monitor(), Mutex::_no_safepoint_check_flag);
if (TraceGCTaskManager) {
tty->print_cr("GCTaskManager::add_task(" INTPTR_FORMAT " [%s])",
- task, GCTask::Kind::to_string(task->kind()));
+ p2i(task), GCTask::Kind::to_string(task->kind()));
}
queue()->enqueue(task);
// Notify with the lock held to avoid missed notifies.
@@ -678,7 +676,7 @@
assert(result != NULL, "shouldn't have null task");
if (TraceGCTaskManager) {
tty->print_cr("GCTaskManager::get_task(%u) => " INTPTR_FORMAT " [%s]",
- which, result, GCTask::Kind::to_string(result->kind()));
+ which, p2i(result), GCTask::Kind::to_string(result->kind()));
tty->print_cr(" %s", result->name());
}
if (!result->is_idle_task()) {
@@ -864,7 +862,7 @@
tty->print_cr("[" INTPTR_FORMAT "]"
" IdleGCTask:::do_it()"
" should_wait: %s",
- this, wait_for_task->should_wait() ? "true" : "false");
+ p2i(this), wait_for_task->should_wait() ? "true" : "false");
}
MutexLockerEx ml(manager->monitor(), Mutex::_no_safepoint_check_flag);
if (TraceDynamicGCThreads) {
@@ -878,7 +876,7 @@
tty->print_cr("[" INTPTR_FORMAT "]"
" IdleGCTask::do_it()"
" [" INTPTR_FORMAT "] (%s)->wait()",
- this, manager->monitor(), manager->monitor()->name());
+ p2i(this), p2i(manager->monitor()), manager->monitor()->name());
}
manager->monitor()->wait(Mutex::_no_safepoint_check_flag, 0);
}
@@ -890,7 +888,7 @@
tty->print_cr("[" INTPTR_FORMAT "]"
" IdleGCTask::do_it() returns"
" should_wait: %s",
- this, wait_for_task->should_wait() ? "true" : "false");
+ p2i(this), wait_for_task->should_wait() ? "true" : "false");
}
// Release monitor().
}
@@ -1000,7 +998,7 @@
tty->print_cr("[" INTPTR_FORMAT "]"
" WaitForBarrierGCTask::WaitForBarrierGCTask()"
" monitor: " INTPTR_FORMAT,
- this, monitor());
+ p2i(this), p2i(monitor()));
}
}
@@ -1011,9 +1009,9 @@
" WaitForBarrierGCTask::destroy()"
" is_c_heap_obj: %s"
" monitor: " INTPTR_FORMAT,
- that,
+ p2i(that),
that->is_c_heap_obj() ? "true" : "false",
- that->monitor());
+ p2i(that->monitor()));
}
that->destruct();
if (that->is_c_heap_obj()) {
@@ -1028,7 +1026,7 @@
tty->print_cr("[" INTPTR_FORMAT "]"
" WaitForBarrierGCTask::destruct()"
" monitor: " INTPTR_FORMAT,
- this, monitor());
+ p2i(this), p2i(monitor()));
}
this->BarrierGCTask::destruct();
// Clean up that should be in the destructor,
@@ -1044,7 +1042,7 @@
tty->print_cr("[" INTPTR_FORMAT "]"
" WaitForBarrierGCTask::do_it() waiting for idle"
" monitor: " INTPTR_FORMAT,
- this, monitor());
+ p2i(this), p2i(monitor()));
}
{
// First, wait for the barrier to arrive.
@@ -1062,7 +1060,7 @@
tty->print_cr("[" INTPTR_FORMAT "]"
" WaitForBarrierGCTask::do_it()"
" [" INTPTR_FORMAT "] (%s)->notify_all()",
- this, monitor(), monitor()->name());
+ p2i(this), p2i(monitor()), monitor()->name());
}
monitor()->notify_all();
// Release monitor().
@@ -1074,7 +1072,7 @@
tty->print_cr("[" INTPTR_FORMAT "]"
" WaitForBarrierGCTask::wait_for()"
" should_wait: %s",
- this, should_wait() ? "true" : "false");
+ p2i(this), should_wait() ? "true" : "false");
}
{
// Grab the lock and check again.
@@ -1084,7 +1082,7 @@
tty->print_cr("[" INTPTR_FORMAT "]"
" WaitForBarrierGCTask::wait_for()"
" [" INTPTR_FORMAT "] (%s)->wait()",
- this, monitor(), monitor()->name());
+ p2i(this), p2i(monitor()), monitor()->name());
}
monitor()->wait(Mutex::_no_safepoint_check_flag, 0);
}
@@ -1096,7 +1094,7 @@
tty->print_cr("[" INTPTR_FORMAT "]"
" WaitForBarrierGCTask::wait_for() returns"
" should_wait: %s",
- this, should_wait() ? "true" : "false");
+ p2i(this), should_wait() ? "true" : "false");
}
// Release monitor().
}
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/gcTaskThread.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/gcTaskThread.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -34,8 +34,6 @@
#include "runtime/os.hpp"
#include "runtime/thread.hpp"
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
GCTaskThread::GCTaskThread(GCTaskManager* manager,
uint which,
uint processor_id) :
@@ -79,7 +77,7 @@
tty->print_cr("GC-Thread %u entries: %d", id(), _time_stamp_index);
for(uint i=0; i<_time_stamp_index; i++) {
GCTaskTimeStamp* time_stamp = time_stamp_at(i);
- tty->print_cr("\t[ %s " INT64_FORMAT " " INT64_FORMAT " ]",
+ tty->print_cr("\t[ %s " JLONG_FORMAT " " JLONG_FORMAT " ]",
time_stamp->name(),
time_stamp->entry_time(),
time_stamp->exit_time());
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -203,17 +203,6 @@
return is_in_young((oop)addr);
}
-#ifdef ASSERT
-// Don't implement this by using is_in_young(). This method is used
-// in some cases to check that is_in_young() is correct.
-bool ParallelScavengeHeap::is_in_partial_collection(const void *p) {
- assert(is_in_reserved(p) || p == NULL,
- "Does not work if address is non-null and outside of the heap");
- // The order of the generations is old (low addr), young (high addr)
- return p >= old_gen()->reserved().end();
-}
-#endif
-
// There are two levels of allocation policy here.
//
// When an allocation request fails, the requesting thread must invoke a VM
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -83,7 +83,7 @@
MarkSweep
};
- ParallelScavengeHeap::Name kind() const {
+ virtual Name kind() const {
return CollectedHeap::ParallelScavengeHeap;
}
@@ -141,10 +141,6 @@
bool is_in_reserved(const void* p) const;
-#ifdef ASSERT
- virtual bool is_in_partial_collection(const void *p);
-#endif
-
bool is_in_young(oop p); // reserved part
bool is_in_old(oop p); // reserved part
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,9 @@
#include "precompiled.hpp"
#include "classfile/systemDictionary.hpp"
#include "code/codeCache.hpp"
+#include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
#include "gc_implementation/parallelScavenge/pcTasks.hpp"
+#include "gc_implementation/parallelScavenge/psCompactionManager.inline.hpp"
#include "gc_implementation/parallelScavenge/psParallelCompact.hpp"
#include "gc_implementation/shared/gcTimer.hpp"
#include "gc_implementation/shared/gcTraceTime.hpp"
@@ -33,7 +35,6 @@
#include "memory/universe.hpp"
#include "oops/objArrayKlass.inline.hpp"
#include "oops/oop.inline.hpp"
-#include "oops/oop.pcgc.inline.hpp"
#include "prims/jvmtiExport.hpp"
#include "runtime/fprofiler.hpp"
#include "runtime/jniHandles.hpp"
@@ -41,8 +42,6 @@
#include "runtime/vmThread.hpp"
#include "services/management.hpp"
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
//
// ThreadRootsMarkingTask
//
@@ -220,12 +219,11 @@
int random_seed = 17;
do {
while (ParCompactionManager::steal_objarray(which, &random_seed, task)) {
- ObjArrayKlass* k = (ObjArrayKlass*)task.obj()->klass();
- k->oop_follow_contents(cm, task.obj(), task.index());
+ cm->follow_contents((objArrayOop)task.obj(), task.index());
cm->follow_marking_stacks();
}
while (ParCompactionManager::steal(which, &random_seed, obj)) {
- obj->follow_contents(cm);
+ cm->follow_contents(obj);
cm->follow_marking_stacks();
}
} while (!terminator()->offer_termination());
@@ -256,7 +254,7 @@
which_stack_index = which;
assert(manager->active_workers() == ParallelGCThreads,
err_msg("all_workers_active has been incorrectly set: "
- " active %d ParallelGCThreads %d", manager->active_workers(),
+ " active %d ParallelGCThreads " UINTX_FORMAT, manager->active_workers(),
ParallelGCThreads));
} else {
which_stack_index = ParCompactionManager::pop_recycled_stack_index();
@@ -268,7 +266,7 @@
gclog_or_tty->print_cr("StealRegionCompactionTask::do_it "
"region_stack_index %d region_stack = " PTR_FORMAT " "
" empty (%d) use all workers %d",
- which_stack_index, ParCompactionManager::region_list(which_stack_index),
+ which_stack_index, p2i(ParCompactionManager::region_list(which_stack_index)),
cm->region_stack()->is_empty(),
use_all_workers);
}
@@ -335,7 +333,7 @@
which_stack_index = which;
assert(manager->active_workers() == ParallelGCThreads,
err_msg("all_workers_active has been incorrectly set: "
- " active %d ParallelGCThreads %d", manager->active_workers(),
+ " active %d ParallelGCThreads " UINTX_FORMAT, manager->active_workers(),
ParallelGCThreads));
} else {
which_stack_index = stack_index();
@@ -369,7 +367,7 @@
void* old_region_stack = (void*) cm->region_stack();
int old_region_stack_index = cm->region_stack_index();
gclog_or_tty->print_cr("Pushing region stack " PTR_FORMAT "/%d",
- old_region_stack, old_region_stack_index);
+ p2i(old_region_stack), old_region_stack_index);
}
cm->set_region_stack(NULL);
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psAdaptiveSizePolicy.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psAdaptiveSizePolicy.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -35,8 +35,6 @@
#include <math.h>
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
PSAdaptiveSizePolicy::PSAdaptiveSizePolicy(size_t init_eden_size,
size_t init_promo_size,
size_t init_survivor_size,
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psCompactionManager.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psCompactionManager.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,12 +28,11 @@
#include "gc_implementation/parallelScavenge/objectStartArray.hpp"
#include "gc_implementation/parallelScavenge/parMarkBitMap.hpp"
#include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
-#include "gc_implementation/parallelScavenge/psCompactionManager.hpp"
+#include "gc_implementation/parallelScavenge/psCompactionManager.inline.hpp"
#include "gc_implementation/parallelScavenge/psOldGen.hpp"
#include "gc_implementation/parallelScavenge/psParallelCompact.hpp"
#include "oops/objArrayKlass.inline.hpp"
#include "oops/oop.inline.hpp"
-#include "oops/oop.pcgc.inline.hpp"
#include "runtime/atomic.inline.hpp"
#include "utilities/stack.inline.hpp"
@@ -180,17 +179,16 @@
// Drain the overflow stack first, to allow stealing from the marking stack.
oop obj;
while (marking_stack()->pop_overflow(obj)) {
- obj->follow_contents(this);
+ follow_contents(obj);
}
while (marking_stack()->pop_local(obj)) {
- obj->follow_contents(this);
+ follow_contents(obj);
}
// Process ObjArrays one at a time to avoid marking stack bloat.
ObjArrayTask task;
if (_objarray_stack.pop_overflow(task) || _objarray_stack.pop_local(task)) {
- ObjArrayKlass* k = (ObjArrayKlass*)task.obj()->klass();
- k->oop_follow_contents(this, task.obj(), task.index());
+ follow_contents((objArrayOop)task.obj(), task.index());
}
} while (!marking_stacks_empty());
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psCompactionManager.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psCompactionManager.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -196,6 +196,10 @@
// Process tasks remaining on any stack
void drain_region_stacks();
+ void follow_contents(oop obj);
+ void follow_contents(objArrayOop array, int index);
+
+ void update_contents(oop obj);
};
inline ParCompactionManager* ParCompactionManager::manager_array(int index) {
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psCompactionManager.inline.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psCompactionManager.inline.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
#include "gc_implementation/parallelScavenge/psCompactionManager.hpp"
#include "gc_implementation/parallelScavenge/psParallelCompact.hpp"
+#include "oops/objArrayKlass.inline.hpp"
+#include "oops/oop.pcgc.inline.hpp"
void ParCompactionManager::push_objarray(oop obj, size_t index)
{
@@ -46,4 +48,17 @@
region_stack()->push(index);
}
+inline void ParCompactionManager::follow_contents(oop obj) {
+ obj->follow_contents(this);
+}
+
+inline void ParCompactionManager::follow_contents(objArrayOop obj, int index) {
+ ObjArrayKlass* k = (ObjArrayKlass*)obj->klass();
+ k->oop_follow_contents(this, obj, index);
+}
+
+inline void ParCompactionManager::update_contents(oop obj) {
+ obj->update_contents(this);
+}
+
#endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSCOMPACTIONMANAGER_INLINE_HPP
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -54,8 +54,6 @@
#include "utilities/events.hpp"
#include "utilities/stack.inline.hpp"
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
elapsedTimer PSMarkSweep::_accumulated_time;
jlong PSMarkSweep::_time_of_last_gc = 0;
CollectorCounters* PSMarkSweep::_counters = NULL;
@@ -670,7 +668,7 @@
jlong ret_val = now - _time_of_last_gc;
// XXX See note in genCollectedHeap::millis_since_last_gc().
if (ret_val < 0) {
- NOT_PRODUCT(warning("time warp: "INT64_FORMAT, ret_val);)
+ NOT_PRODUCT(warning("time warp: " JLONG_FORMAT, ret_val);)
return 0;
}
return ret_val;
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,7 @@
#define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSMARKSWEEP_HPP
#include "gc_implementation/shared/collectorCounters.hpp"
-#include "gc_implementation/shared/markSweep.inline.hpp"
+#include "gc_implementation/shared/markSweep.hpp"
#include "utilities/stack.hpp"
class PSAdaptiveSizePolicy;
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweepDecorator.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweepDecorator.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -303,7 +303,7 @@
while (q < end) {
// point all the oops to the new location
- size_t size = oop(q)->adjust_pointers();
+ size_t size = MarkSweep::adjust_pointers(oop(q));
q += size;
}
@@ -324,7 +324,7 @@
if (oop(q)->is_gc_marked()) {
// q is alive
// point all the oops to the new location
- size_t size = oop(q)->adjust_pointers();
+ size_t size = MarkSweep::adjust_pointers(oop(q));
debug_only(prev_q = q);
q += size;
} else {
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psOldGen.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psOldGen.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -33,8 +33,6 @@
#include "oops/oop.inline.hpp"
#include "runtime/java.hpp"
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
inline const char* PSOldGen::select_name() {
return UseParallelOldGC ? "ParOldGen" : "PSOldGen";
}
@@ -440,9 +438,9 @@
capacity_in_bytes()/K, used_in_bytes()/K);
}
st->print_cr(" [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " INTPTR_FORMAT ")",
- virtual_space()->low_boundary(),
- virtual_space()->high(),
- virtual_space()->high_boundary());
+ p2i(virtual_space()->low_boundary()),
+ p2i(virtual_space()->high()),
+ p2i(virtual_space()->high_boundary()));
st->print(" object"); object_space()->print_on(st);
}
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -50,7 +50,6 @@
#include "memory/referenceProcessor.hpp"
#include "oops/methodData.hpp"
#include "oops/oop.inline.hpp"
-#include "oops/oop.pcgc.inline.hpp"
#include "runtime/atomic.inline.hpp"
#include "runtime/fprofiler.hpp"
#include "runtime/safepoint.hpp"
@@ -63,8 +62,6 @@
#include <math.h>
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
// All sizes are in HeapWords.
const size_t ParallelCompactData::Log2RegionSize = 16; // 64K words
const size_t ParallelCompactData::RegionSize = (size_t)1 << Log2RegionSize;
@@ -223,7 +220,7 @@
REGION_IDX_FORMAT " " PTR_FORMAT " "
REGION_DATA_FORMAT " " REGION_DATA_FORMAT " "
REGION_DATA_FORMAT " " REGION_IDX_FORMAT " %d",
- i, c->data_location(), dci, c->destination(),
+ i, p2i(c->data_location()), dci, p2i(c->destination()),
c->partial_obj_size(), c->live_obj_size(),
c->data_size(), c->source_region(), c->destination_count());
@@ -273,7 +270,7 @@
tty->print(SIZE_FORMAT_W(5) " " PTR_FORMAT " "
SIZE_FORMAT_W(5) " " SIZE_FORMAT_W(5) " "
SIZE_FORMAT_W(5) " " SIZE_FORMAT_W(5) " %d",
- i, c->destination(),
+ i, p2i(c->destination()),
c->partial_obj_size(), c->live_obj_size(),
c->data_size(), c->source_region(), c->destination_count());
if (newline) tty->cr();
@@ -634,13 +631,13 @@
const char * split_type = partial_obj_size == 0 ? "easy" : "hard";
gclog_or_tty->print_cr("%s split: src=" PTR_FORMAT " src_c=" SIZE_FORMAT
" pos=" SIZE_FORMAT,
- split_type, source_next, split_region,
+ split_type, p2i(source_next), split_region,
partial_obj_size);
gclog_or_tty->print_cr("%s split: dst=" PTR_FORMAT " dst_c=" SIZE_FORMAT
" tn=" PTR_FORMAT,
- split_type, split_destination,
+ split_type, p2i(split_destination),
addr_to_region_idx(split_destination),
- *target_next);
+ p2i(*target_next));
if (partial_obj_size != 0) {
HeapWord* const po_beg = split_info.destination();
@@ -649,8 +646,8 @@
"po_beg=" PTR_FORMAT " " SIZE_FORMAT " "
"po_end=" PTR_FORMAT " " SIZE_FORMAT,
split_type,
- po_beg, addr_to_region_idx(po_beg),
- po_end, addr_to_region_idx(po_end));
+ p2i(po_beg), addr_to_region_idx(po_beg),
+ p2i(po_end), addr_to_region_idx(po_end));
}
}
@@ -667,8 +664,8 @@
HeapWord* const source_next_val = source_next == NULL ? NULL : *source_next;
tty->print_cr("sb=" PTR_FORMAT " se=" PTR_FORMAT " sn=" PTR_FORMAT
"tb=" PTR_FORMAT " te=" PTR_FORMAT " tn=" PTR_FORMAT,
- source_beg, source_end, source_next_val,
- target_beg, target_end, *target_next);
+ p2i(source_beg), p2i(source_end), p2i(source_next_val),
+ p2i(target_beg), p2i(target_end), p2i(*target_next));
}
size_t cur_region = addr_to_region_idx(source_beg);
@@ -1133,9 +1130,9 @@
const size_t cur_deadwood = pointer_delta(dense_prefix, region_destination);
if (TraceParallelOldGCDensePrefix && Verbose) {
tty->print_cr("c#=" SIZE_FORMAT_W(4) " dst=" PTR_FORMAT " "
- "dp=" SIZE_FORMAT_W(8) " " "cdw=" SIZE_FORMAT_W(8),
- sd.region(cp), region_destination,
- dense_prefix, cur_deadwood);
+ "dp=" PTR_FORMAT " " "cdw=" SIZE_FORMAT_W(8),
+ sd.region(cp), p2i(region_destination),
+ p2i(dense_prefix), cur_deadwood);
}
if (cur_deadwood >= deadwood_goal) {
@@ -1201,7 +1198,7 @@
"d2l=" SIZE_FORMAT " d2l%%=%6.4f "
"d2r=" SIZE_FORMAT " l2r=" SIZE_FORMAT
" ratio=%10.8f",
- algorithm, addr, region_idx,
+ algorithm, p2i(addr), region_idx,
space_live,
dead_to_left, dead_to_left_pct,
dead_to_right, live_to_right,
@@ -1469,7 +1466,7 @@
{
if (TraceParallelOldGCSummaryPhase) {
tty->print_cr("fill_with_live_objects [" PTR_FORMAT " " PTR_FORMAT ") "
- SIZE_FORMAT, start, start + words, words);
+ SIZE_FORMAT, p2i(start), p2i(start + words), words);
}
ObjectStartArray* const start_array = _space_info[id].start_array();
@@ -1811,9 +1808,9 @@
tty->print_cr("id=%d cap=" SIZE_FORMAT " dp=" PTR_FORMAT " "
"dp_region=" SIZE_FORMAT " " "dp_count=" SIZE_FORMAT " "
"cr_count=" SIZE_FORMAT " " "nt=" PTR_FORMAT,
- id, space->capacity_in_words(), dense_prefix_end,
+ id, space->capacity_in_words(), p2i(dense_prefix_end),
dp_region, dp_words / region_size,
- cr_words / region_size, new_top);
+ cr_words / region_size, p2i(new_top));
}
}
@@ -1831,10 +1828,10 @@
SIZE_FORMAT "-" SIZE_FORMAT,
src_space_id, space_names[src_space_id],
dst_space_id, space_names[dst_space_id],
- src_beg, src_end,
+ p2i(src_beg), p2i(src_end),
_summary_data.addr_to_region_idx(src_beg),
_summary_data.addr_to_region_idx(src_end),
- dst_beg, dst_end,
+ p2i(dst_beg), p2i(dst_end),
_summary_data.addr_to_region_idx(dst_beg),
_summary_data.addr_to_region_idx(dst_end));
}
@@ -2234,8 +2231,8 @@
heap->trace_heap_after_gc(&_gc_tracer);
if (PrintGCTaskTimeStamps) {
- gclog_or_tty->print_cr("VM-Thread " INT64_FORMAT " " INT64_FORMAT " "
- INT64_FORMAT,
+ gclog_or_tty->print_cr("VM-Thread " JLONG_FORMAT " " JLONG_FORMAT " "
+ JLONG_FORMAT,
marking_start.ticks(), compaction_start.ticks(),
collection_exit.ticks());
gc_task_manager()->print_task_time_stamps();
@@ -2754,7 +2751,7 @@
const RegionData* const c = sd.region(cur_region);
if (!c->completed()) {
warning("region " SIZE_FORMAT " not filled: "
- "destination_count=" SIZE_FORMAT,
+ "destination_count=%u",
cur_region, c->destination_count());
issued_a_warning = true;
}
@@ -2764,7 +2761,7 @@
const RegionData* const c = sd.region(cur_region);
if (!c->available()) {
warning("region " SIZE_FORMAT " not empty: "
- "destination_count=" SIZE_FORMAT,
+ "destination_count=%u",
cur_region, c->destination_count());
issued_a_warning = true;
}
@@ -2776,6 +2773,11 @@
}
#endif // #ifdef ASSERT
+inline void UpdateOnlyClosure::do_addr(HeapWord* addr) {
+ _start_array->allocate_block(addr);
+ compaction_manager()->update_contents(oop(addr));
+}
+
// Update interior oops in the ranges of regions [beg_region, end_region).
void
PSParallelCompact::update_and_deadwood_in_dense_prefix(ParCompactionManager* cm,
@@ -2876,7 +2878,7 @@
if (start_array != NULL) {
start_array->allocate_block(addr);
}
- oop(addr)->update_contents(cm);
+ cm->update_contents(oop(addr));
assert(oop(addr)->is_oop_or_null(), err_msg("Expected an oop or NULL at " PTR_FORMAT, p2i(oop(addr))));
}
}
@@ -3294,7 +3296,7 @@
jlong ret_val = now - _time_of_last_gc;
// XXX See note in genCollectedHeap::millis_since_last_gc().
if (ret_val < 0) {
- NOT_PRODUCT(warning("time warp: "INT64_FORMAT, ret_val);)
+ NOT_PRODUCT(warning("time warp: " JLONG_FORMAT, ret_val);)
return 0;
}
return ret_val;
@@ -3360,7 +3362,7 @@
}
oop moved_oop = (oop) destination();
- moved_oop->update_contents(compaction_manager());
+ compaction_manager()->update_contents(moved_oop);
assert(moved_oop->is_oop_or_null(), err_msg("Expected an oop or NULL at " PTR_FORMAT, p2i(moved_oop)));
update_state(words);
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,6 @@
#include "gc_implementation/parallelScavenge/parMarkBitMap.hpp"
#include "gc_implementation/parallelScavenge/psCompactionManager.hpp"
#include "gc_implementation/shared/collectorCounters.hpp"
-#include "gc_implementation/shared/markSweep.hpp"
#include "gc_implementation/shared/mutableSpace.hpp"
#include "memory/sharedHeap.hpp"
#include "oops/oop.hpp"
@@ -1026,9 +1025,6 @@
bool maximum_heap_compaction,
ParallelOldTracer *gc_tracer);
- template <class T>
- static inline void follow_root(ParCompactionManager* cm, T* p);
-
// Compute the dense prefix for the designated space. This is an experimental
// implementation currently not used in production.
static HeapWord* compute_dense_prefix_via_density(const SpaceId id,
@@ -1337,23 +1333,6 @@
}
template <class T>
-inline void PSParallelCompact::follow_root(ParCompactionManager* cm, T* p) {
- assert(!Universe::heap()->is_in_reserved(p),
- "roots shouldn't be things within the heap");
-
- T heap_oop = oopDesc::load_heap_oop(p);
- if (!oopDesc::is_null(heap_oop)) {
- oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
- if (mark_bitmap()->is_unmarked(obj)) {
- if (mark_obj(obj)) {
- obj->follow_contents(cm);
- }
- }
- }
- cm->follow_marking_stacks();
-}
-
-template <class T>
inline void PSParallelCompact::mark_and_push(ParCompactionManager* cm, T* p) {
T heap_oop = oopDesc::load_heap_oop(p);
if (!oopDesc::is_null(heap_oop)) {
@@ -1525,12 +1504,6 @@
inline void do_addr(HeapWord* addr);
};
-inline void UpdateOnlyClosure::do_addr(HeapWord* addr)
-{
- _start_array->allocate_block(addr);
- oop(addr)->update_contents(compaction_manager());
-}
-
class FillClosure: public ParMarkBitMapClosure
{
public:
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -33,9 +33,7 @@
#include "memory/memRegion.hpp"
#include "memory/padded.inline.hpp"
#include "oops/oop.inline.hpp"
-#include "oops/oop.psgc.inline.hpp"
-
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
+#include "utilities/stack.inline.hpp"
PaddedEnd<PSPromotionManager>* PSPromotionManager::_manager_array = NULL;
OopStarTaskQueueSet* PSPromotionManager::_stack_array_depth = NULL;
@@ -324,7 +322,7 @@
_promotion_failed_info.register_copy_failure(obj->size());
- obj->push_contents(this);
+ push_contents(obj);
// Save the mark if needed
PSScavenge::oop_promotion_failed(obj, obj_mark);
@@ -341,7 +339,7 @@
gclog_or_tty->print_cr("{%s %s " PTR_FORMAT " (%d)}",
"promotion-failure",
obj->klass()->internal_name(),
- (void *)obj, obj->size());
+ p2i(obj), obj->size());
}
#endif
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -212,6 +212,8 @@
template <class T> inline void claim_or_forward_depth(T* p);
TASKQUEUE_STATS_ONLY(inline void record_steal(StarTask& p);)
+
+ void push_contents(oop obj);
};
#endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSPROMOTIONMANAGER_HPP
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -91,6 +91,9 @@
}
}
+inline void PSPromotionManager::push_contents(oop obj) {
+ obj->push_contents(this);
+}
//
// This method is pretty bulky. It would be nice to split it up
// into smaller submethods, but we need to be careful not to hurt
@@ -227,7 +230,7 @@
TASKQUEUE_STATS_ONLY(++_arrays_chunked; ++_masked_pushes);
} else {
// we'll just push its contents
- new_obj->push_contents(this);
+ push_contents(new_obj);
}
} else {
// We lost, someone else "owns" this object
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -46,7 +46,6 @@
#include "memory/referenceProcessor.hpp"
#include "memory/resourceArea.hpp"
#include "oops/oop.inline.hpp"
-#include "oops/oop.psgc.inline.hpp"
#include "runtime/biasedLocking.hpp"
#include "runtime/fprofiler.hpp"
#include "runtime/handles.inline.hpp"
@@ -56,8 +55,6 @@
#include "services/memoryService.hpp"
#include "utilities/stack.inline.hpp"
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
HeapWord* PSScavenge::_to_space_top_before_gc = NULL;
int PSScavenge::_consecutive_skipped_scavenges = 0;
ReferenceProcessor* PSScavenge::_ref_processor = NULL;
@@ -551,8 +548,8 @@
if (PrintTenuringDistribution) {
gclog_or_tty->cr();
- gclog_or_tty->print_cr("Desired survivor size " SIZE_FORMAT " bytes, new threshold "
- UINTX_FORMAT " (max threshold " UINTX_FORMAT ")",
+ gclog_or_tty->print_cr("Desired survivor size " SIZE_FORMAT " bytes, new threshold %u"
+ " (max threshold " UINTX_FORMAT ")",
size_policy->calculated_survivor_size_in_bytes(),
_tenuring_threshold, MaxTenuringThreshold);
}
@@ -694,7 +691,7 @@
scavenge_exit.update();
if (PrintGCTaskTimeStamps) {
- tty->print_cr("VM-Thread " INT64_FORMAT " " INT64_FORMAT " " INT64_FORMAT,
+ tty->print_cr("VM-Thread " JLONG_FORMAT " " JLONG_FORMAT " " JLONG_FORMAT,
scavenge_entry.ticks(), scavenge_midpoint.ticks(),
scavenge_exit.ticks());
gc_task_manager()->print_task_time_stamps();
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psTasks.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psTasks.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -35,11 +35,11 @@
#include "memory/iterator.hpp"
#include "memory/universe.hpp"
#include "oops/oop.inline.hpp"
-#include "oops/oop.psgc.inline.hpp"
#include "runtime/fprofiler.hpp"
#include "runtime/thread.hpp"
#include "runtime/vmThread.hpp"
#include "services/management.hpp"
+#include "utilities/stack.inline.hpp"
#include "utilities/taskqueue.hpp"
//
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psVirtualspace.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psVirtualspace.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -27,8 +27,6 @@
#include "runtime/os.hpp"
#include "runtime/virtualspace.hpp"
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
// PSVirtualSpace
PSVirtualSpace::PSVirtualSpace(ReservedSpace rs, size_t alignment) :
@@ -218,22 +216,22 @@
void PSVirtualSpace::print() const {
gclog_or_tty->print_cr("virtual space [" PTR_FORMAT "]: alignment="
SIZE_FORMAT "K grows %s%s",
- this, alignment() / K, grows_up() ? "up" : "down",
+ p2i(this), alignment() / K, grows_up() ? "up" : "down",
special() ? " (pinned in memory)" : "");
gclog_or_tty->print_cr(" reserved=" SIZE_FORMAT "K"
" [" PTR_FORMAT "," PTR_FORMAT "]"
" committed=" SIZE_FORMAT "K"
" [" PTR_FORMAT "," PTR_FORMAT "]",
reserved_size() / K,
- reserved_low_addr(), reserved_high_addr(),
+ p2i(reserved_low_addr()), p2i(reserved_high_addr()),
committed_size() / K,
- committed_low_addr(), committed_high_addr());
+ p2i(committed_low_addr()), p2i(committed_high_addr()));
}
#endif // #ifndef PRODUCT
void PSVirtualSpace::print_space_boundaries_on(outputStream* st) const {
st->print_cr(" [" PTR_FORMAT ", " PTR_FORMAT ", " PTR_FORMAT ")",
- low_boundary(), high(), high_boundary());
+ p2i(low_boundary()), p2i(high()), p2i(high_boundary()));
}
PSVirtualSpaceHighToLow::PSVirtualSpaceHighToLow(ReservedSpace rs,
@@ -350,5 +348,5 @@
void
PSVirtualSpaceHighToLow::print_space_boundaries_on(outputStream* st) const {
st->print_cr(" (" PTR_FORMAT ", " PTR_FORMAT ", " PTR_FORMAT "]",
- high_boundary(), low(), low_boundary());
+ p2i(high_boundary()), p2i(low()), p2i(low_boundary()));
}
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psYoungGen.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psYoungGen.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -33,8 +33,6 @@
#include "oops/oop.inline.hpp"
#include "runtime/java.hpp"
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
PSYoungGen::PSYoungGen(size_t initial_size,
size_t min_size,
size_t max_size) :
@@ -419,20 +417,22 @@
// s1
gclog_or_tty->print_cr("Current region: [" PTR_FORMAT ", " PTR_FORMAT ") "
"New region: [" PTR_FORMAT ", " PTR_FORMAT ")",
- s1->bottom(), s1->end(), s1MR.start(), s1MR.end());
+ p2i(s1->bottom()), p2i(s1->end()),
+ p2i(s1MR.start()), p2i(s1MR.end()));
gclog_or_tty->print_cr(" Mangle before: [" PTR_FORMAT ", "
PTR_FORMAT ") Mangle after: [" PTR_FORMAT ", " PTR_FORMAT ")",
- delta1_left.start(), delta1_left.end(), delta1_right.start(),
- delta1_right.end());
+ p2i(delta1_left.start()), p2i(delta1_left.end()),
+ p2i(delta1_right.start()), p2i(delta1_right.end()));
// s2
gclog_or_tty->print_cr("Current region: [" PTR_FORMAT ", " PTR_FORMAT ") "
"New region: [" PTR_FORMAT ", " PTR_FORMAT ")",
- s2->bottom(), s2->end(), s2MR.start(), s2MR.end());
+ p2i(s2->bottom()), p2i(s2->end()),
+ p2i(s2MR.start()), p2i(s2MR.end()));
gclog_or_tty->print_cr(" Mangle before: [" PTR_FORMAT ", "
PTR_FORMAT ") Mangle after: [" PTR_FORMAT ", " PTR_FORMAT ")",
- delta2_left.start(), delta2_left.end(), delta2_right.start(),
- delta2_right.end());
+ p2i(delta2_left.start()), p2i(delta2_left.end()),
+ p2i(delta2_right.start()), p2i(delta2_right.end()));
}
}
@@ -456,22 +456,22 @@
requested_eden_size, requested_survivor_size);
gclog_or_tty->print_cr(" eden: [" PTR_FORMAT ".." PTR_FORMAT ") "
SIZE_FORMAT,
- eden_space()->bottom(),
- eden_space()->end(),
+ p2i(eden_space()->bottom()),
+ p2i(eden_space()->end()),
pointer_delta(eden_space()->end(),
eden_space()->bottom(),
sizeof(char)));
gclog_or_tty->print_cr(" from: [" PTR_FORMAT ".." PTR_FORMAT ") "
SIZE_FORMAT,
- from_space()->bottom(),
- from_space()->end(),
+ p2i(from_space()->bottom()),
+ p2i(from_space()->end()),
pointer_delta(from_space()->end(),
from_space()->bottom(),
sizeof(char)));
gclog_or_tty->print_cr(" to: [" PTR_FORMAT ".." PTR_FORMAT ") "
SIZE_FORMAT,
- to_space()->bottom(),
- to_space()->end(),
+ p2i(to_space()->bottom()),
+ p2i(to_space()->end()),
pointer_delta( to_space()->end(),
to_space()->bottom(),
sizeof(char)));
@@ -572,18 +572,18 @@
if (PrintAdaptiveSizePolicy && Verbose) {
gclog_or_tty->print_cr(" [eden_start .. eden_end): "
"[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT,
- eden_start,
- eden_end,
+ p2i(eden_start),
+ p2i(eden_end),
pointer_delta(eden_end, eden_start, sizeof(char)));
gclog_or_tty->print_cr(" [from_start .. from_end): "
"[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT,
- from_start,
- from_end,
+ p2i(from_start),
+ p2i(from_end),
pointer_delta(from_end, from_start, sizeof(char)));
gclog_or_tty->print_cr(" [ to_start .. to_end): "
"[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT,
- to_start,
- to_end,
+ p2i(to_start),
+ p2i(to_end),
pointer_delta( to_end, to_start, sizeof(char)));
}
} else {
@@ -629,18 +629,18 @@
if (PrintAdaptiveSizePolicy && Verbose) {
gclog_or_tty->print_cr(" [eden_start .. eden_end): "
"[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT,
- eden_start,
- eden_end,
+ p2i(eden_start),
+ p2i(eden_end),
pointer_delta(eden_end, eden_start, sizeof(char)));
gclog_or_tty->print_cr(" [ to_start .. to_end): "
"[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT,
- to_start,
- to_end,
+ p2i(to_start),
+ p2i(to_end),
pointer_delta( to_end, to_start, sizeof(char)));
gclog_or_tty->print_cr(" [from_start .. from_end): "
"[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT,
- from_start,
- from_end,
+ p2i(from_start),
+ p2i(from_end),
pointer_delta(from_end, from_start, sizeof(char)));
}
}
--- a/hotspot/src/share/vm/gc_implementation/shared/cSpaceCounters.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/shared/cSpaceCounters.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -63,3 +63,20 @@
_space->capacity(), CHECK);
}
}
+
+void CSpaceCounters::update_capacity() {
+ _capacity->set_value(_space->capacity());
+}
+
+void CSpaceCounters::update_used() {
+ _used->set_value(_space->used());
+}
+
+void CSpaceCounters::update_all() {
+ update_used();
+ update_capacity();
+}
+
+jlong ContiguousSpaceUsedHelper::take_sample(){
+ return _space->used();
+}
--- a/hotspot/src/share/vm/gc_implementation/shared/cSpaceCounters.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/shared/cSpaceCounters.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,7 @@
#define SHARE_VM_GC_IMPLEMENTATION_SHARED_CSPACECOUNTERS_HPP
#include "gc_implementation/shared/generationCounters.hpp"
-#include "memory/space.inline.hpp"
+#include "memory/space.hpp"
#include "runtime/perfData.hpp"
// A CSpaceCounters is a holder class for performance counters
@@ -56,18 +56,9 @@
if (_name_space != NULL) FREE_C_HEAP_ARRAY(char, _name_space);
}
- virtual inline void update_capacity() {
- _capacity->set_value(_space->capacity());
- }
-
- virtual inline void update_used() {
- _used->set_value(_space->used());
- }
-
- virtual inline void update_all() {
- update_used();
- update_capacity();
- }
+ virtual void update_capacity();
+ virtual void update_used();
+ virtual void update_all();
const char* name_space() const { return _name_space; }
};
@@ -79,9 +70,7 @@
public:
ContiguousSpaceUsedHelper(ContiguousSpace* space) : _space(space) { }
- inline jlong take_sample() {
- return _space->used();
- }
+ jlong take_sample();
};
#endif // SHARE_VM_GC_IMPLEMENTATION_SHARED_CSPACECOUNTERS_HPP
--- a/hotspot/src/share/vm/gc_implementation/shared/markSweep.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/shared/markSweep.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,8 +32,6 @@
#include "oops/objArrayKlass.inline.hpp"
#include "oops/oop.inline.hpp"
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
uint MarkSweep::_total_invocations = 0;
Stack<oop, mtGC> MarkSweep::_marking_stack;
@@ -64,18 +62,22 @@
MarkSweep::follow_cld_closure.do_cld(cld);
}
+void MarkSweep::follow_array(objArrayOop array, int index) {
+ ObjArrayKlass* k = (ObjArrayKlass*)array->klass();
+ k->oop_follow_contents(array, index);
+}
+
void MarkSweep::follow_stack() {
do {
while (!_marking_stack.is_empty()) {
oop obj = _marking_stack.pop();
assert (obj->is_gc_marked(), "p must be marked");
- obj->follow_contents();
+ follow_object(obj);
}
// Process ObjArrays one at a time to avoid marking stack bloat.
if (!_objarray_stack.is_empty()) {
ObjArrayTask task = _objarray_stack.pop();
- ObjArrayKlass* k = (ObjArrayKlass*)task.obj()->klass();
- k->oop_follow_contents(task.obj(), task.index());
+ follow_array(objArrayOop(task.obj()), task.index());
}
} while (!_marking_stack.is_empty() || !_objarray_stack.is_empty());
}
@@ -84,6 +86,14 @@
void MarkSweep::FollowStackClosure::do_void() { follow_stack(); }
+void PreservedMark::adjust_pointer() {
+ MarkSweep::adjust_pointer(&_obj);
+}
+
+void PreservedMark::restore() {
+ _obj->set_mark(_mark);
+}
+
// We preserve the mark which should be replaced at the end and the location
// that it will go. Note that the object that this markOop belongs to isn't
// currently at that address but it will be after phase4
--- a/hotspot/src/share/vm/gc_implementation/shared/markSweep.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/shared/markSweep.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,8 @@
#define SHARE_VM_GC_IMPLEMENTATION_SHARED_MARKSWEEP_HPP
#include "gc_interface/collectedHeap.hpp"
-#include "memory/universe.hpp"
+#include "memory/genOopClosures.hpp"
+#include "memory/iterator.hpp"
#include "oops/markOop.hpp"
#include "oops/oop.hpp"
#include "runtime/timer.hpp"
@@ -159,10 +160,16 @@
static void follow_stack(); // Empty marking stack.
+ static void follow_object(oop obj);
+
+ static void follow_array(objArrayOop array, int index);
+
static void follow_klass(Klass* klass);
static void follow_class_loader(ClassLoaderData* cld);
+ static int adjust_pointers(oop obj);
+
static void preserve_mark(oop p, markOop mark);
// Save the mark word so it can be restored later
static void adjust_marks(); // Adjust the pointers in the preserved marks table
@@ -182,13 +189,8 @@
_mark = mark;
}
- void adjust_pointer() {
- MarkSweep::adjust_pointer(&_obj);
- }
-
- void restore() {
- _obj->set_mark(_mark);
- }
+ void adjust_pointer();
+ void restore();
};
#endif // SHARE_VM_GC_IMPLEMENTATION_SHARED_MARKSWEEP_HPP
--- a/hotspot/src/share/vm/gc_implementation/shared/markSweep.inline.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/shared/markSweep.inline.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -58,6 +58,10 @@
MarkSweep::mark_and_push(&op);
}
+inline void MarkSweep::follow_object(oop obj) {
+ obj->follow_contents();
+}
+
template <class T> inline void MarkSweep::follow_root(T* p) {
assert(!Universe::heap()->is_in_reserved(p),
"roots shouldn't be things within the heap");
@@ -66,7 +70,7 @@
oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
if (!obj->mark()->is_marked()) {
mark_object(obj);
- obj->follow_contents();
+ follow_object(obj);
}
}
follow_stack();
@@ -90,6 +94,10 @@
_objarray_stack.push(task);
}
+inline int MarkSweep::adjust_pointers(oop obj) {
+ return obj->adjust_pointers();
+}
+
template <class T> inline void MarkSweep::adjust_pointer(T* p) {
T heap_oop = oopDesc::load_heap_oop(p);
if (!oopDesc::is_null(heap_oop)) {
--- a/hotspot/src/share/vm/gc_implementation/shared/mutableNUMASpace.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/shared/mutableNUMASpace.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -31,8 +31,6 @@
#include "runtime/atomic.inline.hpp"
#include "runtime/thread.inline.hpp"
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
MutableNUMASpace::MutableNUMASpace(size_t alignment) : MutableSpace(alignment) {
_lgrp_spaces = new (ResourceObj::C_HEAP, mtGC) GrowableArray<LGRPSpace*>(0, true);
_page_size = os::vm_page_size();
@@ -973,7 +971,7 @@
break;
}
if (e != scan_end) {
- assert(e < scan_end, err_msg("e: " PTR_FORMAT " scan_end: " PTR_FORMAT, e, scan_end));
+ assert(e < scan_end, err_msg("e: " PTR_FORMAT " scan_end: " PTR_FORMAT, p2i(e), p2i(scan_end)));
if ((page_expected.size != page_size || page_expected.lgrp_id != lgrp_id())
&& page_expected.size != 0) {
--- a/hotspot/src/share/vm/gc_implementation/shared/mutableSpace.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/shared/mutableSpace.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -33,8 +33,6 @@
#include "runtime/thread.hpp"
#endif // INCLUDE_ALL_GCS
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
MutableSpace::MutableSpace(size_t alignment): ImmutableSpace(), _top(NULL), _alignment(alignment) {
assert(MutableSpace::alignment() % os::vm_page_size() == 0,
"Space should be aligned");
@@ -253,7 +251,7 @@
void MutableSpace::print_on(outputStream* st) const {
MutableSpace::print_short_on(st);
st->print_cr(" [" INTPTR_FORMAT "," INTPTR_FORMAT "," INTPTR_FORMAT ")",
- bottom(), top(), end());
+ p2i(bottom()), p2i(top()), p2i(end()));
}
void MutableSpace::verify() {
--- a/hotspot/src/share/vm/gc_implementation/shared/spaceDecorator.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/shared/spaceDecorator.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -27,8 +27,6 @@
#include "memory/space.inline.hpp"
#include "utilities/copy.hpp"
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
// Catch-all file for utility classes
#ifndef PRODUCT
@@ -86,7 +84,7 @@
assert(ZapUnusedHeapArea, "Mangling should not be in use");
#ifdef ASSERT
if(TraceZapUnusedHeapArea) {
- gclog_or_tty->print("Mangling [" PTR_FORMAT " to " PTR_FORMAT ")", mr.start(), mr.end());
+ gclog_or_tty->print("Mangling [" PTR_FORMAT " to " PTR_FORMAT ")", p2i(mr.start()), p2i(mr.end()));
}
Copy::fill_to_words(mr.start(), mr.word_size(), badHeapWord);
if(TraceZapUnusedHeapArea) {
--- a/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -98,7 +98,7 @@
if (!is_init_completed()) {
vm_exit_during_initialization(
err_msg("GC triggered before VM initialization completed. Try increasing "
- "NewSize, current value " UINTX_FORMAT "%s.",
+ "NewSize, current value " SIZE_FORMAT "%s.",
byte_size_in_proper_unit(NewSize),
proper_unit_for_byte_size(NewSize)));
}
--- a/hotspot/src/share/vm/gc_interface/collectedHeap.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/gc_interface/collectedHeap.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -185,8 +185,6 @@
public:
enum Name {
- Abstract,
- SharedHeap,
GenCollectedHeap,
ParallelScavengeHeap,
G1CollectedHeap
@@ -196,7 +194,7 @@
return _filler_array_max_size;
}
- virtual CollectedHeap::Name kind() const { return CollectedHeap::Abstract; }
+ virtual Name kind() const = 0;
/**
* Returns JNI error code JNI_ENOMEM if memory could not be allocated,
@@ -291,12 +289,6 @@
return p == NULL || is_in_closed_subset(p);
}
-#ifdef ASSERT
- // Returns true if "p" is in the part of the
- // heap being collected.
- virtual bool is_in_partial_collection(const void *p) = 0;
-#endif
-
// An object is scavengable if its location may move during a scavenge.
// (A scavenge is a GC which is not a full GC.)
virtual bool is_scavengable(const void *p) = 0;
--- a/hotspot/src/share/vm/memory/cardTableModRefBS.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/memory/cardTableModRefBS.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -470,13 +470,9 @@
fatal("Parallel gc not supported here.");
#endif // INCLUDE_ALL_GCS
} else {
- // We do not call the non_clean_card_iterate_serial() version below because
- // we want to clear the cards (which non_clean_card_iterate_serial() does not
- // do for us): clear_cl here does the work of finding contiguous dirty ranges
- // of cards to process and clear.
+ // clear_cl finds contiguous dirty ranges of cards to process and clear.
- DirtyCardToOopClosure* dcto_cl = sp->new_dcto_cl(cl, precision(),
- cl->gen_boundary());
+ DirtyCardToOopClosure* dcto_cl = sp->new_dcto_cl(cl, precision(), cl->gen_boundary());
ClearNoncleanCardWrapper clear_cl(dcto_cl, ct);
clear_cl.do_MemRegion(mr);
@@ -484,46 +480,6 @@
}
}
-// The iterator itself is not MT-aware, but
-// MT-aware callers and closures can use this to
-// accomplish dirty card iteration in parallel. The
-// iterator itself does not clear the dirty cards, or
-// change their values in any manner.
-void CardTableModRefBS::non_clean_card_iterate_serial(MemRegion mr,
- MemRegionClosure* cl) {
- bool is_par = (SharedHeap::heap()->n_par_threads() > 0);
- assert(!is_par ||
- (SharedHeap::heap()->n_par_threads() ==
- SharedHeap::heap()->workers()->active_workers()), "Mismatch");
- for (int i = 0; i < _cur_covered_regions; i++) {
- MemRegion mri = mr.intersection(_covered[i]);
- if (mri.word_size() > 0) {
- jbyte* cur_entry = byte_for(mri.last());
- jbyte* limit = byte_for(mri.start());
- while (cur_entry >= limit) {
- jbyte* next_entry = cur_entry - 1;
- if (*cur_entry != clean_card) {
- size_t non_clean_cards = 1;
- // Should the next card be included in this range of dirty cards.
- while (next_entry >= limit && *next_entry != clean_card) {
- non_clean_cards++;
- cur_entry = next_entry;
- next_entry--;
- }
- // The memory region may not be on a card boundary. So that
- // objects beyond the end of the region are not processed, make
- // cur_cards precise with regard to the end of the memory region.
- MemRegion cur_cards(addr_for(cur_entry),
- non_clean_cards * card_size_in_words);
- MemRegion dirty_region = cur_cards.intersection(mri);
- cl->do_MemRegion(dirty_region);
- }
- cur_entry = next_entry;
- }
- }
- }
-}
-
void CardTableModRefBS::dirty_MemRegion(MemRegion mr) {
assert((HeapWord*)align_size_down((uintptr_t)mr.start(), HeapWordSize) == mr.start(), "Unaligned start");
assert((HeapWord*)align_size_up ((uintptr_t)mr.end(), HeapWordSize) == mr.end(), "Unaligned end" );
--- a/hotspot/src/share/vm/memory/cardTableModRefBS.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/memory/cardTableModRefBS.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -37,7 +37,7 @@
// the head of "o" is dirtied, not necessarily the card containing the
// modified field itself. For object arrays, however, the barrier *is*
// precise; only the card containing the modified element is dirtied.
-// Any MemRegionClosures used to scan dirty cards should take these
+// Closures used to scan dirty cards should take these
// considerations into account.
class Generation;
@@ -176,16 +176,7 @@
// Iterate over the portion of the card-table which covers the given
// region mr in the given space and apply cl to any dirty sub-regions
- // of mr. Dirty cards are _not_ cleared by the iterator method itself,
- // but closures may arrange to do so on their own should they so wish.
- void non_clean_card_iterate_serial(MemRegion mr, MemRegionClosure* cl);
-
- // A variant of the above that will operate in a parallel mode if
- // worker threads are available, and clear the dirty cards as it
- // processes them.
- // XXX ??? MemRegionClosure above vs OopsInGenClosure below XXX
- // XXX some new_dcto_cl's take OopClosure's, plus as above there are
- // some MemRegionClosures. Clean this up everywhere. XXX
+ // of mr. Clears the dirty cards as they are processed.
void non_clean_card_iterate_possibly_parallel(Space* sp, MemRegion mr,
OopsInGenClosure* cl, CardTableRS* ct);
@@ -379,24 +370,6 @@
// *** Card-table-RemSet-specific things.
- // Invoke "cl.do_MemRegion" on a set of MemRegions that collectively
- // includes all the modified cards (expressing each card as a
- // MemRegion). Thus, several modified cards may be lumped into one
- // region. The regions are non-overlapping, and are visited in
- // *decreasing* address order. (This order aids with imprecise card
- // marking, where a dirty card may cause scanning, and summarization
- // marking, of objects that extend onto subsequent cards.)
- void mod_card_iterate(MemRegionClosure* cl) {
- non_clean_card_iterate_serial(_whole_heap, cl);
- }
-
- // Like the "mod_cards_iterate" above, except only invokes the closure
- // for cards within the MemRegion "mr" (which is required to be
- // card-aligned and sized.)
- void mod_card_iterate(MemRegion mr, MemRegionClosure* cl) {
- non_clean_card_iterate_serial(mr, cl);
- }
-
static uintx ct_max_alignment_constraint();
// Apply closure "cl" to the dirty cards containing some part of
--- a/hotspot/src/share/vm/memory/cardTableRS.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/memory/cardTableRS.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -27,7 +27,7 @@
#include "memory/cardTableRS.hpp"
#include "memory/genCollectedHeap.hpp"
#include "memory/generation.hpp"
-#include "memory/space.hpp"
+#include "memory/space.inline.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/atomic.inline.hpp"
#include "runtime/java.hpp"
--- a/hotspot/src/share/vm/memory/collectorPolicy.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/memory/collectorPolicy.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -104,15 +104,15 @@
// User inputs from -Xmx and -Xms must be aligned
_min_heap_byte_size = align_size_up(_min_heap_byte_size, _heap_alignment);
- uintx aligned_initial_heap_size = align_size_up(InitialHeapSize, _heap_alignment);
- uintx aligned_max_heap_size = align_size_up(MaxHeapSize, _heap_alignment);
+ size_t aligned_initial_heap_size = align_size_up(InitialHeapSize, _heap_alignment);
+ size_t aligned_max_heap_size = align_size_up(MaxHeapSize, _heap_alignment);
// Write back to flags if the values changed
if (aligned_initial_heap_size != InitialHeapSize) {
- FLAG_SET_ERGO(uintx, InitialHeapSize, aligned_initial_heap_size);
+ FLAG_SET_ERGO(size_t, InitialHeapSize, aligned_initial_heap_size);
}
if (aligned_max_heap_size != MaxHeapSize) {
- FLAG_SET_ERGO(uintx, MaxHeapSize, aligned_max_heap_size);
+ FLAG_SET_ERGO(size_t, MaxHeapSize, aligned_max_heap_size);
}
if (FLAG_IS_CMDLINE(InitialHeapSize) && _min_heap_byte_size != 0 &&
@@ -120,9 +120,9 @@
vm_exit_during_initialization("Incompatible minimum and initial heap sizes specified");
}
if (!FLAG_IS_DEFAULT(InitialHeapSize) && InitialHeapSize > MaxHeapSize) {
- FLAG_SET_ERGO(uintx, MaxHeapSize, InitialHeapSize);
+ FLAG_SET_ERGO(size_t, MaxHeapSize, InitialHeapSize);
} else if (!FLAG_IS_DEFAULT(MaxHeapSize) && InitialHeapSize > MaxHeapSize) {
- FLAG_SET_ERGO(uintx, InitialHeapSize, MaxHeapSize);
+ FLAG_SET_ERGO(size_t, InitialHeapSize, MaxHeapSize);
if (InitialHeapSize < _min_heap_byte_size) {
_min_heap_byte_size = InitialHeapSize;
}
@@ -131,7 +131,7 @@
_initial_heap_byte_size = InitialHeapSize;
_max_heap_byte_size = MaxHeapSize;
- FLAG_SET_ERGO(uintx, MinHeapDeltaBytes, align_size_up(MinHeapDeltaBytes, _space_alignment));
+ FLAG_SET_ERGO(size_t, MinHeapDeltaBytes, align_size_up(MinHeapDeltaBytes, _space_alignment));
DEBUG_ONLY(CollectorPolicy::assert_flags();)
}
@@ -190,11 +190,12 @@
_min_young_size(0),
_initial_young_size(0),
_max_young_size(0),
- _gen_alignment(0),
_min_old_size(0),
_initial_old_size(0),
_max_old_size(0),
- _generations(NULL)
+ _gen_alignment(0),
+ _young_gen_spec(NULL),
+ _old_gen_spec(NULL)
{}
size_t GenCollectorPolicy::scale_by_NewRatio_aligned(size_t base_size) {
@@ -282,18 +283,18 @@
// All generational heaps have a youngest gen; handle those flags here
// Make sure the heap is large enough for two generations
- uintx smallest_new_size = young_gen_size_lower_bound();
- uintx smallest_heap_size = align_size_up(smallest_new_size + align_size_up(_space_alignment, _gen_alignment),
+ size_t smallest_new_size = young_gen_size_lower_bound();
+ size_t smallest_heap_size = align_size_up(smallest_new_size + align_size_up(_space_alignment, _gen_alignment),
_heap_alignment);
if (MaxHeapSize < smallest_heap_size) {
- FLAG_SET_ERGO(uintx, MaxHeapSize, smallest_heap_size);
+ FLAG_SET_ERGO(size_t, MaxHeapSize, smallest_heap_size);
_max_heap_byte_size = MaxHeapSize;
}
// If needed, synchronize _min_heap_byte size and _initial_heap_byte_size
if (_min_heap_byte_size < smallest_heap_size) {
_min_heap_byte_size = smallest_heap_size;
if (InitialHeapSize < _min_heap_byte_size) {
- FLAG_SET_ERGO(uintx, InitialHeapSize, smallest_heap_size);
+ FLAG_SET_ERGO(size_t, InitialHeapSize, smallest_heap_size);
_initial_heap_byte_size = smallest_heap_size;
}
}
@@ -306,8 +307,8 @@
// Now take the actual NewSize into account. We will silently increase NewSize
// if the user specified a smaller or unaligned value.
- uintx bounded_new_size = bound_minus_alignment(NewSize, MaxHeapSize);
- bounded_new_size = MAX2(smallest_new_size, (uintx)align_size_down(bounded_new_size, _gen_alignment));
+ size_t bounded_new_size = bound_minus_alignment(NewSize, MaxHeapSize);
+ bounded_new_size = MAX2(smallest_new_size, (size_t)align_size_down(bounded_new_size, _gen_alignment));
if (bounded_new_size != NewSize) {
// Do not use FLAG_SET_ERGO to update NewSize here, since this will override
// if NewSize was set on the command line or not. This information is needed
@@ -320,21 +321,21 @@
if (!FLAG_IS_DEFAULT(MaxNewSize)) {
if (MaxNewSize >= MaxHeapSize) {
// Make sure there is room for an old generation
- uintx smaller_max_new_size = MaxHeapSize - _gen_alignment;
+ size_t smaller_max_new_size = MaxHeapSize - _gen_alignment;
if (FLAG_IS_CMDLINE(MaxNewSize)) {
warning("MaxNewSize (" SIZE_FORMAT "k) is equal to or greater than the entire "
"heap (" SIZE_FORMAT "k). A new max generation size of " SIZE_FORMAT "k will be used.",
MaxNewSize/K, MaxHeapSize/K, smaller_max_new_size/K);
}
- FLAG_SET_ERGO(uintx, MaxNewSize, smaller_max_new_size);
+ FLAG_SET_ERGO(size_t, MaxNewSize, smaller_max_new_size);
if (NewSize > MaxNewSize) {
- FLAG_SET_ERGO(uintx, NewSize, MaxNewSize);
+ FLAG_SET_ERGO(size_t, NewSize, MaxNewSize);
_initial_young_size = NewSize;
}
} else if (MaxNewSize < _initial_young_size) {
- FLAG_SET_ERGO(uintx, MaxNewSize, _initial_young_size);
+ FLAG_SET_ERGO(size_t, MaxNewSize, _initial_young_size);
} else if (!is_size_aligned(MaxNewSize, _gen_alignment)) {
- FLAG_SET_ERGO(uintx, MaxNewSize, align_size_down(MaxNewSize, _gen_alignment));
+ FLAG_SET_ERGO(size_t, MaxNewSize, align_size_down(MaxNewSize, _gen_alignment));
}
_max_young_size = MaxNewSize;
}
@@ -347,7 +348,7 @@
"A new max generation size of " SIZE_FORMAT "k will be used.",
NewSize/K, MaxNewSize/K, NewSize/K);
}
- FLAG_SET_ERGO(uintx, MaxNewSize, NewSize);
+ FLAG_SET_ERGO(size_t, MaxNewSize, NewSize);
_max_young_size = MaxNewSize;
}
@@ -369,9 +370,9 @@
size_t calculated_heapsize = (OldSize / NewRatio) * (NewRatio + 1);
calculated_heapsize = align_size_up(calculated_heapsize, _heap_alignment);
- FLAG_SET_ERGO(uintx, MaxHeapSize, calculated_heapsize);
+ FLAG_SET_ERGO(size_t, MaxHeapSize, calculated_heapsize);
_max_heap_byte_size = MaxHeapSize;
- FLAG_SET_ERGO(uintx, InitialHeapSize, calculated_heapsize);
+ FLAG_SET_ERGO(size_t, InitialHeapSize, calculated_heapsize);
_initial_heap_byte_size = InitialHeapSize;
}
@@ -380,19 +381,19 @@
if (_max_heap_size_cmdline) {
// Somebody has set a maximum heap size with the intention that we should not
// exceed it. Adjust New/OldSize as necessary.
- uintx calculated_size = NewSize + OldSize;
+ size_t calculated_size = NewSize + OldSize;
double shrink_factor = (double) MaxHeapSize / calculated_size;
- uintx smaller_new_size = align_size_down((uintx)(NewSize * shrink_factor), _gen_alignment);
- FLAG_SET_ERGO(uintx, NewSize, MAX2(young_gen_size_lower_bound(), smaller_new_size));
+ size_t smaller_new_size = align_size_down((size_t)(NewSize * shrink_factor), _gen_alignment);
+ FLAG_SET_ERGO(size_t, NewSize, MAX2(young_gen_size_lower_bound(), smaller_new_size));
_initial_young_size = NewSize;
// OldSize is already aligned because above we aligned MaxHeapSize to
// _heap_alignment, and we just made sure that NewSize is aligned to
// _gen_alignment. In initialize_flags() we verified that _heap_alignment
// is a multiple of _gen_alignment.
- FLAG_SET_ERGO(uintx, OldSize, MaxHeapSize - NewSize);
+ FLAG_SET_ERGO(size_t, OldSize, MaxHeapSize - NewSize);
} else {
- FLAG_SET_ERGO(uintx, MaxHeapSize, align_size_up(NewSize + OldSize, _heap_alignment));
+ FLAG_SET_ERGO(size_t, MaxHeapSize, align_size_up(NewSize + OldSize, _heap_alignment));
_max_heap_byte_size = MaxHeapSize;
}
}
@@ -405,7 +406,7 @@
// Need to compare against the flag value for max since _max_young_size
// might not have been set yet.
if (new_size >= _min_young_size && new_size <= MaxNewSize) {
- FLAG_SET_ERGO(uintx, NewSize, new_size);
+ FLAG_SET_ERGO(size_t, NewSize, new_size);
_initial_young_size = NewSize;
}
}
@@ -561,15 +562,15 @@
// Write back to flags if necessary.
if (NewSize != _initial_young_size) {
- FLAG_SET_ERGO(uintx, NewSize, _initial_young_size);
+ FLAG_SET_ERGO(size_t, NewSize, _initial_young_size);
}
if (MaxNewSize != _max_young_size) {
- FLAG_SET_ERGO(uintx, MaxNewSize, _max_young_size);
+ FLAG_SET_ERGO(size_t, MaxNewSize, _max_young_size);
}
if (OldSize != _initial_old_size) {
- FLAG_SET_ERGO(uintx, OldSize, _initial_old_size);
+ FLAG_SET_ERGO(size_t, OldSize, _initial_old_size);
}
if (PrintGCDetails && Verbose) {
@@ -601,7 +602,7 @@
HandleMark hm; // Discard any handles allocated in each iteration.
// First allocation attempt is lock-free.
- Generation *young = gch->get_gen(0);
+ Generation *young = gch->young_gen();
assert(young->supports_inline_contig_alloc(),
"Otherwise, must do alloc within heap lock");
if (young->should_allocate(size, is_tlab)) {
@@ -615,8 +616,8 @@
{
MutexLocker ml(Heap_lock);
if (PrintGC && Verbose) {
- gclog_or_tty->print_cr("TwoGenerationCollectorPolicy::mem_allocate_work:"
- " attempting locked slow path allocation");
+ gclog_or_tty->print_cr("GenCollectorPolicy::mem_allocate_work:"
+ " attempting locked slow path allocation");
}
// Note that only large objects get a shot at being
// allocated in later generations.
@@ -705,7 +706,7 @@
// Give a warning if we seem to be looping forever.
if ((QueuedAllocationWarningCount > 0) &&
(try_count % QueuedAllocationWarningCount == 0)) {
- warning("TwoGenerationCollectorPolicy::mem_allocate_work retries %d times \n\t"
+ warning("GenCollectorPolicy::mem_allocate_work retries %d times \n\t"
" size=" SIZE_FORMAT " %s", try_count, size, is_tlab ? "(TLAB)" : "");
}
}
@@ -715,10 +716,14 @@
bool is_tlab) {
GenCollectedHeap *gch = GenCollectedHeap::heap();
HeapWord* result = NULL;
- for (int i = number_of_generations() - 1; i >= 0 && result == NULL; i--) {
- Generation *gen = gch->get_gen(i);
- if (gen->should_allocate(size, is_tlab)) {
- result = gen->expand_and_allocate(size, is_tlab);
+ Generation *old = gch->old_gen();
+ if (old->should_allocate(size, is_tlab)) {
+ result = old->expand_and_allocate(size, is_tlab);
+ }
+ if (result == NULL) {
+ Generation *young = gch->young_gen();
+ if (young->should_allocate(size, is_tlab)) {
+ result = young->expand_and_allocate(size, is_tlab);
}
}
assert(result == NULL || gch->is_in_reserved(result), "result not in heap");
@@ -891,7 +896,7 @@
bool GenCollectorPolicy::should_try_older_generation_allocation(
size_t word_size) const {
GenCollectedHeap* gch = GenCollectedHeap::heap();
- size_t young_capacity = gch->get_gen(0)->capacity_before_gc();
+ size_t young_capacity = gch->young_gen()->capacity_before_gc();
return (word_size > heap_word_size(young_capacity))
|| GC_locker::is_active_and_needs_gc()
|| gch->incremental_collection_failed();
@@ -903,14 +908,13 @@
//
void MarkSweepPolicy::initialize_alignments() {
- _space_alignment = _gen_alignment = (uintx)Generation::GenGrain;
+ _space_alignment = _gen_alignment = (size_t)Generation::GenGrain;
_heap_alignment = compute_heap_alignment();
}
void MarkSweepPolicy::initialize_generations() {
- _generations = NEW_C_HEAP_ARRAY(GenerationSpecPtr, number_of_generations(), mtGC);
- _generations[0] = new GenerationSpec(Generation::DefNew, _initial_young_size, _max_young_size);
- _generations[1] = new GenerationSpec(Generation::MarkSweepCompact, _initial_old_size, _max_old_size);
+ _young_gen_spec = new GenerationSpec(Generation::DefNew, _initial_young_size, _max_young_size, _gen_alignment);
+ _old_gen_spec = new GenerationSpec(Generation::MarkSweepCompact, _initial_old_size, _max_old_size, _gen_alignment);
}
void MarkSweepPolicy::initialize_gc_policy_counters() {
@@ -935,18 +939,18 @@
// for both min and initial young size if less than min heap.
flag_value = 20 * M;
set_basic_flag_values();
- FLAG_SET_CMDLINE(uintx, NewSize, flag_value);
+ FLAG_SET_CMDLINE(size_t, NewSize, flag_value);
verify_young_min(flag_value);
set_basic_flag_values();
- FLAG_SET_CMDLINE(uintx, NewSize, flag_value);
+ FLAG_SET_CMDLINE(size_t, NewSize, flag_value);
verify_young_initial(flag_value);
// If NewSize is set on command line, but is larger than the min
// heap size, it should only be used for initial young size.
flag_value = 80 * M;
set_basic_flag_values();
- FLAG_SET_CMDLINE(uintx, NewSize, flag_value);
+ FLAG_SET_CMDLINE(size_t, NewSize, flag_value);
verify_young_initial(flag_value);
// If NewSize has been ergonomically set, the collector policy
@@ -954,11 +958,11 @@
// using NewRatio.
flag_value = 20 * M;
set_basic_flag_values();
- FLAG_SET_ERGO(uintx, NewSize, flag_value);
+ FLAG_SET_ERGO(size_t, NewSize, flag_value);
verify_young_min(flag_value);
set_basic_flag_values();
- FLAG_SET_ERGO(uintx, NewSize, flag_value);
+ FLAG_SET_ERGO(size_t, NewSize, flag_value);
verify_scaled_young_initial(InitialHeapSize);
restore_flags();
@@ -974,11 +978,11 @@
// for both min and initial old size if less than min heap.
flag_value = 20 * M;
set_basic_flag_values();
- FLAG_SET_CMDLINE(uintx, OldSize, flag_value);
+ FLAG_SET_CMDLINE(size_t, OldSize, flag_value);
verify_old_min(flag_value);
set_basic_flag_values();
- FLAG_SET_CMDLINE(uintx, OldSize, flag_value);
+ FLAG_SET_CMDLINE(size_t, OldSize, flag_value);
// Calculate what we expect the flag to be.
size_t expected_old_initial = align_size_up(InitialHeapSize, heap_alignment) - MaxNewSize;
verify_old_initial(expected_old_initial);
@@ -989,10 +993,10 @@
// We intentionally set MaxNewSize + OldSize > MaxHeapSize (see over_size).
flag_value = 30 * M;
set_basic_flag_values();
- FLAG_SET_CMDLINE(uintx, OldSize, flag_value);
+ FLAG_SET_CMDLINE(size_t, OldSize, flag_value);
size_t over_size = 20*M;
size_t new_size_value = align_size_up(MaxHeapSize, heap_alignment) - flag_value + over_size;
- FLAG_SET_CMDLINE(uintx, MaxNewSize, new_size_value);
+ FLAG_SET_CMDLINE(size_t, MaxNewSize, new_size_value);
// Calculate what we expect the flag to be.
expected_old_initial = align_size_up(MaxHeapSize, heap_alignment) - MaxNewSize;
verify_old_initial(expected_old_initial);
@@ -1053,11 +1057,11 @@
static size_t original_OldSize;
static void set_basic_flag_values() {
- FLAG_SET_ERGO(uintx, MaxHeapSize, 180 * M);
- FLAG_SET_ERGO(uintx, InitialHeapSize, 100 * M);
- FLAG_SET_ERGO(uintx, OldSize, 4 * M);
- FLAG_SET_ERGO(uintx, NewSize, 1 * M);
- FLAG_SET_ERGO(uintx, MaxNewSize, 80 * M);
+ FLAG_SET_ERGO(size_t, MaxHeapSize, 180 * M);
+ FLAG_SET_ERGO(size_t, InitialHeapSize, 100 * M);
+ FLAG_SET_ERGO(size_t, OldSize, 4 * M);
+ FLAG_SET_ERGO(size_t, NewSize, 1 * M);
+ FLAG_SET_ERGO(size_t, MaxNewSize, 80 * M);
Arguments::set_min_heap_size(40 * M);
}
--- a/hotspot/src/share/vm/memory/collectorPolicy.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/memory/collectorPolicy.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -208,7 +208,8 @@
};
class GenCollectorPolicy : public CollectorPolicy {
-friend class TestGenCollectorPolicy;
+ friend class TestGenCollectorPolicy;
+ friend class VMStructs;
protected:
size_t _min_young_size;
size_t _initial_young_size;
@@ -221,7 +222,8 @@
// time. When using large pages they can differ.
size_t _gen_alignment;
- GenerationSpec **_generations;
+ GenerationSpec* _young_gen_spec;
+ GenerationSpec* _old_gen_spec;
// Return true if an allocation should be attempted in the older generation
// if it fails in the younger generation. Return false, otherwise.
@@ -261,9 +263,14 @@
int number_of_generations() { return 2; }
- virtual GenerationSpec **generations() {
- assert(_generations != NULL, "Sanity check");
- return _generations;
+ GenerationSpec* young_gen_spec() const {
+ assert(_young_gen_spec != NULL, "_young_gen_spec should have been initialized");
+ return _young_gen_spec;
+ }
+
+ GenerationSpec* old_gen_spec() const {
+ assert(_old_gen_spec != NULL, "_old_gen_spec should have been initialized");
+ return _old_gen_spec;
}
virtual GenCollectorPolicy* as_generation_policy() { return this; }
--- a/hotspot/src/share/vm/memory/defNewGeneration.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/memory/defNewGeneration.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -49,8 +49,6 @@
#include "utilities/globalDefinitions.hpp"
#include "utilities/stack.inline.hpp"
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
//
// DefNewGeneration functions.
@@ -137,7 +135,7 @@
if (TraceScavenge) {
ResourceMark rm;
gclog_or_tty->print_cr("KlassScanClosure::do_klass " PTR_FORMAT ", %s, dirty: %s",
- klass,
+ p2i(klass),
klass->external_name(),
klass->has_modified_oops() ? "true" : "false");
}
@@ -226,7 +224,7 @@
compute_space_boundaries(0, SpaceDecorator::Clear, SpaceDecorator::Mangle);
update_counters();
- _next_gen = NULL;
+ _old_gen = NULL;
_tenuring_threshold = MaxTenuringThreshold;
_pretenure_size_threshold_words = PretenureSizeThreshold >> LogHeapWordSize;
@@ -380,11 +378,11 @@
int next_level = level() + 1;
GenCollectedHeap* gch = GenCollectedHeap::heap();
- assert(next_level < gch->_n_gens,
+ assert(next_level < gch->n_gens(),
"DefNewGeneration cannot be an oldest gen");
- Generation* next_gen = gch->get_gen(next_level);
- size_t old_size = next_gen->capacity();
+ Generation* old_gen = gch->old_gen();
+ size_t old_size = old_gen->capacity();
size_t new_size_before = _virtual_space.committed_size();
size_t min_new_size = spec()->init_size();
size_t max_new_size = reserved().byte_size();
@@ -568,7 +566,7 @@
DefNewTracer gc_tracer;
gc_tracer.report_gc_start(gch->gc_cause(), _gc_timer->gc_start());
- _next_gen = gch->next_gen(this);
+ _old_gen = gch->old_gen();
// If the next generation is too full to accommodate promotion
// from this generation, pass on collection; let the next generation
@@ -590,8 +588,6 @@
gch->trace_heap_before_gc(&gc_tracer);
- SpecializationStats::clear();
-
// These can be shared for all code paths
IsAliveClosure is_alive(this);
ScanWeakRefClosure scan_weak_ref(this);
@@ -628,7 +624,7 @@
true, // Process younger gens, if any,
// as strong roots.
true, // activate StrongRootsScope
- SharedHeap::SO_ScavengeCodeCache,
+ GenCollectedHeap::SO_ScavengeCodeCache,
GenCollectedHeap::StrongAndWeakRoots,
&fsc_with_no_gc_barrier,
&fsc_with_gc_barrier,
@@ -688,7 +684,7 @@
gch->set_incremental_collection_failed();
// Inform the next generation that a promotion failure occurred.
- _next_gen->promotion_failure_occurred();
+ _old_gen->promotion_failure_occurred();
gc_tracer.report_promotion_failed(_promotion_failed_info);
// Reset the PromotionFailureALot counters.
@@ -700,7 +696,6 @@
// set new iteration safe limit for the survivor spaces
from()->set_concurrent_iteration_safe_limit(from()->top());
to()->set_concurrent_iteration_safe_limit(to()->top());
- SpecializationStats::print();
// We need to use a monotonically non-decreasing time in ms
// or we will see time-warp warnings and os::javaTimeMillis()
@@ -793,7 +788,7 @@
// Otherwise try allocating obj tenured
if (obj == NULL) {
- obj = _next_gen->promote(old, s);
+ obj = _old_gen->promote(old, s);
if (obj == NULL) {
handle_promotion_failure(old);
return old;
@@ -898,11 +893,11 @@
}
return false;
}
- if (_next_gen == NULL) {
+ if (_old_gen == NULL) {
GenCollectedHeap* gch = GenCollectedHeap::heap();
- _next_gen = gch->next_gen(this);
+ _old_gen = gch->old_gen();
}
- return _next_gen->promotion_attempt_is_safe(used());
+ return _old_gen->promotion_attempt_is_safe(used());
}
void DefNewGeneration::gc_epilogue(bool full) {
@@ -1022,8 +1017,7 @@
return eden();
}
-HeapWord* DefNewGeneration::allocate(size_t word_size,
- bool is_tlab) {
+HeapWord* DefNewGeneration::allocate(size_t word_size, bool is_tlab) {
// This is the slow-path allocation for the DefNewGeneration.
// Most allocations are fast-path in compiled code.
// We try to allocate from the eden. If that works, we are happy.
@@ -1031,8 +1025,8 @@
// have to use it here, as well.
HeapWord* result = eden()->par_allocate(word_size);
if (result != NULL) {
- if (CMSEdenChunksRecordAlways && _next_gen != NULL) {
- _next_gen->sample_eden_chunk();
+ if (CMSEdenChunksRecordAlways && _old_gen != NULL) {
+ _old_gen->sample_eden_chunk();
}
} else {
// If the eden is full and the last collection bailed out, we are running
@@ -1047,8 +1041,8 @@
HeapWord* DefNewGeneration::par_allocate(size_t word_size,
bool is_tlab) {
HeapWord* res = eden()->par_allocate(word_size);
- if (CMSEdenChunksRecordAlways && _next_gen != NULL) {
- _next_gen->sample_eden_chunk();
+ if (CMSEdenChunksRecordAlways && _old_gen != NULL) {
+ _old_gen->sample_eden_chunk();
}
return res;
}
--- a/hotspot/src/share/vm/memory/defNewGeneration.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/memory/defNewGeneration.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,11 +29,14 @@
#include "gc_implementation/shared/cSpaceCounters.hpp"
#include "gc_implementation/shared/generationCounters.hpp"
#include "gc_implementation/shared/copyFailedInfo.hpp"
+#include "memory/generation.hpp"
#include "utilities/stack.hpp"
class ContiguousSpace;
class ScanClosure;
class STWGCTimer;
+class CSpaceCounters;
+class ScanWeakRefClosure;
// DefNewGeneration is a young generation containing eden, from- and
// to-space.
@@ -42,7 +45,7 @@
friend class VMStructs;
protected:
- Generation* _next_gen;
+ Generation* _old_gen;
uint _tenuring_threshold; // Tenuring threshold for next collection.
ageTable _age_table;
// Size of object to pretenure in words; command line provides bytes
--- a/hotspot/src/share/vm/memory/defNewGeneration.inline.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/memory/defNewGeneration.inline.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,8 +25,10 @@
#ifndef SHARE_VM_MEMORY_DEFNEWGENERATION_INLINE_HPP
#define SHARE_VM_MEMORY_DEFNEWGENERATION_INLINE_HPP
+#include "gc_interface/collectedHeap.hpp"
#include "memory/cardTableRS.hpp"
#include "memory/defNewGeneration.hpp"
+#include "memory/genOopClosures.inline.hpp"
#include "memory/space.hpp"
// Methods of protected closure types
--- a/hotspot/src/share/vm/memory/genCollectedHeap.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/memory/genCollectedHeap.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -26,6 +26,7 @@
#include "classfile/symbolTable.hpp"
#include "classfile/systemDictionary.hpp"
#include "classfile/vmSymbols.hpp"
+#include "code/codeCache.hpp"
#include "code/icBuffer.hpp"
#include "gc_implementation/shared/collectorCounters.hpp"
#include "gc_implementation/shared/gcTrace.hpp"
@@ -47,6 +48,7 @@
#include "runtime/handles.inline.hpp"
#include "runtime/java.hpp"
#include "runtime/vmThread.hpp"
+#include "services/management.hpp"
#include "services/memoryService.hpp"
#include "utilities/vmError.hpp"
#include "utilities/workgroup.hpp"
@@ -61,30 +63,33 @@
// The set of potentially parallel tasks in root scanning.
enum GCH_strong_roots_tasks {
- // We probably want to parallelize both of these internally, but for now...
+ GCH_PS_Universe_oops_do,
+ GCH_PS_JNIHandles_oops_do,
+ GCH_PS_ObjectSynchronizer_oops_do,
+ GCH_PS_FlatProfiler_oops_do,
+ GCH_PS_Management_oops_do,
+ GCH_PS_SystemDictionary_oops_do,
+ GCH_PS_ClassLoaderDataGraph_oops_do,
+ GCH_PS_jvmti_oops_do,
+ GCH_PS_CodeCache_oops_do,
GCH_PS_younger_gens,
// Leave this one last.
GCH_PS_NumElements
};
GenCollectedHeap::GenCollectedHeap(GenCollectorPolicy *policy) :
- SharedHeap(policy),
+ SharedHeap(),
_rem_set(NULL),
_gen_policy(policy),
- _gen_process_roots_tasks(new SubTasksDone(GCH_PS_NumElements)),
+ _process_strong_tasks(new SubTasksDone(GCH_PS_NumElements)),
_full_collections_completed(0)
{
- if (_gen_process_roots_tasks == NULL ||
- !_gen_process_roots_tasks->valid()) {
- vm_exit_during_initialization("Failed necessary allocation.");
- }
assert(policy != NULL, "Sanity check");
}
jint GenCollectedHeap::initialize() {
CollectedHeap::pre_initialize();
- int i;
_n_gens = gen_policy()->number_of_generations();
assert(_n_gens == 2, "There is no support for more than two generations");
@@ -95,16 +100,6 @@
// HeapWordSize).
guarantee(HeapWordSize == wordSize, "HeapWordSize must equal wordSize");
- // The heap must be at least as aligned as generations.
- size_t gen_alignment = Generation::GenGrain;
-
- _gen_specs = gen_policy()->generations();
-
- // Make sure the sizes are all aligned.
- for (i = 0; i < _n_gens; i++) {
- _gen_specs[i]->align(gen_alignment);
- }
-
// Allocate space for the heap.
char* heap_address;
@@ -127,12 +122,12 @@
_gch = this;
- ReservedSpace young_rs = heap_rs.first_part(_gen_specs[0]->max_size(), false, false);
- _young_gen = _gen_specs[0]->init(young_rs, 0, rem_set());
- heap_rs = heap_rs.last_part(_gen_specs[0]->max_size());
+ ReservedSpace young_rs = heap_rs.first_part(gen_policy()->young_gen_spec()->max_size(), false, false);
+ _young_gen = gen_policy()->young_gen_spec()->init(young_rs, 0, rem_set());
+ heap_rs = heap_rs.last_part(gen_policy()->young_gen_spec()->max_size());
- ReservedSpace old_rs = heap_rs.first_part(_gen_specs[1]->max_size(), false, false);
- _old_gen = _gen_specs[1]->init(old_rs, 1, rem_set());
+ ReservedSpace old_rs = heap_rs.first_part(gen_policy()->old_gen_spec()->max_size(), false, false);
+ _old_gen = gen_policy()->old_gen_spec()->init(old_rs, 1, rem_set());
clear_incremental_collection_failed();
#if INCLUDE_ALL_GCS
@@ -149,21 +144,18 @@
char* GenCollectedHeap::allocate(size_t alignment,
ReservedSpace* heap_rs){
- const char overflow_msg[] = "The size of the object heap + VM data exceeds "
- "the maximum representable size";
-
// Now figure out the total size.
- size_t total_reserved = 0;
- const size_t pageSize = UseLargePages ?
- os::large_page_size() : os::vm_page_size();
-
+ const size_t pageSize = UseLargePages ? os::large_page_size() : os::vm_page_size();
assert(alignment % pageSize == 0, "Must be");
- for (int i = 0; i < _n_gens; i++) {
- total_reserved += _gen_specs[i]->max_size();
- if (total_reserved < _gen_specs[i]->max_size()) {
- vm_exit_during_initialization(overflow_msg);
- }
+ GenerationSpec* young_spec = gen_policy()->young_gen_spec();
+ GenerationSpec* old_spec = gen_policy()->old_gen_spec();
+
+ // Check for overflow.
+ size_t total_reserved = young_spec->max_size() + old_spec->max_size();
+ if (total_reserved < young_spec->max_size()) {
+ vm_exit_during_initialization("The size of the object heap + VM data exceeds "
+ "the maximum representable size");
}
assert(total_reserved % alignment == 0,
err_msg("Gen size; total_reserved=" SIZE_FORMAT ", alignment="
@@ -177,18 +169,17 @@
SharedHeap::post_initialize();
GenCollectorPolicy *policy = (GenCollectorPolicy *)collector_policy();
guarantee(policy->is_generation_policy(), "Illegal policy type");
- assert((get_gen(0)->kind() == Generation::DefNew) ||
- (get_gen(0)->kind() == Generation::ParNew),
+ assert((_young_gen->kind() == Generation::DefNew) ||
+ (_young_gen->kind() == Generation::ParNew),
"Wrong youngest generation type");
- DefNewGeneration* def_new_gen = (DefNewGeneration*)get_gen(0);
+ DefNewGeneration* def_new_gen = (DefNewGeneration*)_young_gen;
- Generation* old_gen = get_gen(1);
- assert(old_gen->kind() == Generation::ConcurrentMarkSweep ||
- old_gen->kind() == Generation::MarkSweepCompact,
+ assert(_old_gen->kind() == Generation::ConcurrentMarkSweep ||
+ _old_gen->kind() == Generation::MarkSweepCompact,
"Wrong generation kind");
policy->initialize_size_policy(def_new_gen->eden()->capacity(),
- old_gen->capacity(),
+ _old_gen->capacity(),
def_new_gen->from()->capacity());
policy->initialize_gc_policy_counters();
}
@@ -570,29 +561,137 @@
void GenCollectedHeap::set_par_threads(uint t) {
SharedHeap::set_par_threads(t);
- _gen_process_roots_tasks->set_n_threads(t);
+ set_n_termination(t);
+}
+
+void GenCollectedHeap::set_n_termination(uint t) {
+ _process_strong_tasks->set_n_threads(t);
}
-void GenCollectedHeap::
-gen_process_roots(int level,
- bool younger_gens_as_roots,
- bool activate_scope,
- SharedHeap::ScanningOption so,
- OopsInGenClosure* not_older_gens,
- OopsInGenClosure* weak_roots,
- OopsInGenClosure* older_gens,
- CLDClosure* cld_closure,
- CLDClosure* weak_cld_closure,
- CodeBlobClosure* code_closure) {
+#ifdef ASSERT
+class AssertNonScavengableClosure: public OopClosure {
+public:
+ virtual void do_oop(oop* p) {
+ assert(!GenCollectedHeap::heap()->is_in_partial_collection(*p),
+ "Referent should not be scavengable."); }
+ virtual void do_oop(narrowOop* p) { ShouldNotReachHere(); }
+};
+static AssertNonScavengableClosure assert_is_non_scavengable_closure;
+#endif
+
+void GenCollectedHeap::process_roots(bool activate_scope,
+ ScanningOption so,
+ OopClosure* strong_roots,
+ OopClosure* weak_roots,
+ CLDClosure* strong_cld_closure,
+ CLDClosure* weak_cld_closure,
+ CodeBlobClosure* code_roots) {
+ StrongRootsScope srs(this, activate_scope);
// General roots.
- SharedHeap::process_roots(activate_scope, so,
- not_older_gens, weak_roots,
- cld_closure, weak_cld_closure,
- code_closure);
+ assert(Threads::thread_claim_parity() != 0, "must have called prologue code");
+ assert(code_roots != NULL, "code root closure should always be set");
+ // _n_termination for _process_strong_tasks should be set up stream
+ // in a method not running in a GC worker. Otherwise the GC worker
+ // could be trying to change the termination condition while the task
+ // is executing in another GC worker.
+
+ if (!_process_strong_tasks->is_task_claimed(GCH_PS_ClassLoaderDataGraph_oops_do)) {
+ ClassLoaderDataGraph::roots_cld_do(strong_cld_closure, weak_cld_closure);
+ }
+
+ // Some CLDs contained in the thread frames should be considered strong.
+ // Don't process them if they will be processed during the ClassLoaderDataGraph phase.
+ CLDClosure* roots_from_clds_p = (strong_cld_closure != weak_cld_closure) ? strong_cld_closure : NULL;
+ // Only process code roots from thread stacks if we aren't visiting the entire CodeCache anyway
+ CodeBlobClosure* roots_from_code_p = (so & SO_AllCodeCache) ? NULL : code_roots;
+
+ Threads::possibly_parallel_oops_do(strong_roots, roots_from_clds_p, roots_from_code_p);
+
+ if (!_process_strong_tasks->is_task_claimed(GCH_PS_Universe_oops_do)) {
+ Universe::oops_do(strong_roots);
+ }
+ // Global (strong) JNI handles
+ if (!_process_strong_tasks->is_task_claimed(GCH_PS_JNIHandles_oops_do)) {
+ JNIHandles::oops_do(strong_roots);
+ }
+
+ if (!_process_strong_tasks->is_task_claimed(GCH_PS_ObjectSynchronizer_oops_do)) {
+ ObjectSynchronizer::oops_do(strong_roots);
+ }
+ if (!_process_strong_tasks->is_task_claimed(GCH_PS_FlatProfiler_oops_do)) {
+ FlatProfiler::oops_do(strong_roots);
+ }
+ if (!_process_strong_tasks->is_task_claimed(GCH_PS_Management_oops_do)) {
+ Management::oops_do(strong_roots);
+ }
+ if (!_process_strong_tasks->is_task_claimed(GCH_PS_jvmti_oops_do)) {
+ JvmtiExport::oops_do(strong_roots);
+ }
+
+ if (!_process_strong_tasks->is_task_claimed(GCH_PS_SystemDictionary_oops_do)) {
+ SystemDictionary::roots_oops_do(strong_roots, weak_roots);
+ }
+
+ // All threads execute the following. A specific chunk of buckets
+ // from the StringTable are the individual tasks.
+ if (weak_roots != NULL) {
+ if (CollectedHeap::use_parallel_gc_threads()) {
+ StringTable::possibly_parallel_oops_do(weak_roots);
+ } else {
+ StringTable::oops_do(weak_roots);
+ }
+ }
+
+ if (!_process_strong_tasks->is_task_claimed(GCH_PS_CodeCache_oops_do)) {
+ if (so & SO_ScavengeCodeCache) {
+ assert(code_roots != NULL, "must supply closure for code cache");
+
+ // We only visit parts of the CodeCache when scavenging.
+ CodeCache::scavenge_root_nmethods_do(code_roots);
+ }
+ if (so & SO_AllCodeCache) {
+ assert(code_roots != NULL, "must supply closure for code cache");
+
+ // CMSCollector uses this to do intermediate-strength collections.
+ // We scan the entire code cache, since CodeCache::do_unloading is not called.
+ CodeCache::blobs_do(code_roots);
+ }
+ // Verify that the code cache contents are not subject to
+ // movement by a scavenging collection.
+ DEBUG_ONLY(CodeBlobToOopClosure assert_code_is_non_scavengable(&assert_is_non_scavengable_closure, !CodeBlobToOopClosure::FixRelocations));
+ DEBUG_ONLY(CodeCache::asserted_non_scavengable_nmethods_do(&assert_code_is_non_scavengable));
+ }
+
+}
+
+void GenCollectedHeap::gen_process_roots(int level,
+ bool younger_gens_as_roots,
+ bool activate_scope,
+ ScanningOption so,
+ bool only_strong_roots,
+ OopsInGenClosure* not_older_gens,
+ OopsInGenClosure* older_gens,
+ CLDClosure* cld_closure) {
+ const bool is_adjust_phase = !only_strong_roots && !younger_gens_as_roots;
+
+ bool is_moving_collection = false;
+ if (level == 0 || is_adjust_phase) {
+ // young collections are always moving
+ is_moving_collection = true;
+ }
+
+ MarkingCodeBlobClosure mark_code_closure(not_older_gens, is_moving_collection);
+ OopsInGenClosure* weak_roots = only_strong_roots ? NULL : not_older_gens;
+ CLDClosure* weak_cld_closure = only_strong_roots ? NULL : cld_closure;
+
+ process_roots(activate_scope, so,
+ not_older_gens, weak_roots,
+ cld_closure, weak_cld_closure,
+ &mark_code_closure);
if (younger_gens_as_roots) {
- if (!_gen_process_roots_tasks->is_task_claimed(GCH_PS_younger_gens)) {
+ if (!_process_strong_tasks->is_task_claimed(GCH_PS_younger_gens)) {
if (level == 1) {
not_older_gens->set_generation(_young_gen);
_young_gen->oop_iterate(not_older_gens);
@@ -608,43 +707,18 @@
older_gens->reset_generation();
}
- _gen_process_roots_tasks->all_tasks_completed();
+ _process_strong_tasks->all_tasks_completed();
}
-void GenCollectedHeap::
-gen_process_roots(int level,
- bool younger_gens_as_roots,
- bool activate_scope,
- SharedHeap::ScanningOption so,
- bool only_strong_roots,
- OopsInGenClosure* not_older_gens,
- OopsInGenClosure* older_gens,
- CLDClosure* cld_closure) {
- const bool is_adjust_phase = !only_strong_roots && !younger_gens_as_roots;
-
- bool is_moving_collection = false;
- if (level == 0 || is_adjust_phase) {
- // young collections are always moving
- is_moving_collection = true;
- }
-
- MarkingCodeBlobClosure mark_code_closure(not_older_gens, is_moving_collection);
- CodeBlobClosure* code_closure = &mark_code_closure;
-
- gen_process_roots(level,
- younger_gens_as_roots,
- activate_scope, so,
- not_older_gens, only_strong_roots ? NULL : not_older_gens,
- older_gens,
- cld_closure, only_strong_roots ? NULL : cld_closure,
- code_closure);
-
-}
+class AlwaysTrueClosure: public BoolObjectClosure {
+public:
+ bool do_object_b(oop p) { return true; }
+};
+static AlwaysTrueClosure always_true;
void GenCollectedHeap::gen_process_weak_roots(OopClosure* root_closure) {
- SharedHeap::process_weak_roots(root_closure);
- // "Local" "weak" refs
+ JNIHandles::weak_oops_do(&always_true, root_closure);
_young_gen->ref_processor()->weak_oops_do(root_closure);
_old_gen->ref_processor()->weak_oops_do(root_closure);
}
@@ -1113,10 +1187,10 @@
void GenCollectedHeap::print_tracing_info() const {
if (TraceYoungGenTime) {
- get_gen(0)->print_summary_info();
+ _young_gen->print_summary_info();
}
if (TraceOldGenTime) {
- get_gen(1)->print_summary_info();
+ _old_gen->print_summary_info();
}
}
@@ -1263,7 +1337,7 @@
// back a time later than 'now'.
jlong retVal = now - tolgc_cl.time();
if (retVal < 0) {
- NOT_PRODUCT(warning("time warp: "INT64_FORMAT, (int64_t) retVal);)
+ NOT_PRODUCT(warning("time warp: " JLONG_FORMAT, retVal);)
return 0;
}
return retVal;
--- a/hotspot/src/share/vm/memory/genCollectedHeap.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/memory/genCollectedHeap.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -67,8 +67,6 @@
Generation* _young_gen;
Generation* _old_gen;
- GenerationSpec** _gen_specs;
-
// The singleton Gen Remembered Set.
GenRemSet* _rem_set;
@@ -85,8 +83,7 @@
// Data structure for claiming the (potentially) parallel tasks in
// (gen-specific) roots processing.
- SubTasksDone* _gen_process_roots_tasks;
- SubTasksDone* gen_process_roots_tasks() { return _gen_process_roots_tasks; }
+ SubTasksDone* _process_strong_tasks;
// Collects the given generation.
void collect_generation(Generation* gen, bool full, size_t size, bool is_tlab,
@@ -142,12 +139,12 @@
// Initialize ("weak") refs processing support
virtual void ref_processing_init();
- virtual CollectedHeap::Name kind() const {
+ virtual Name kind() const {
return CollectedHeap::GenCollectedHeap;
}
- Generation* young_gen() { return _young_gen; }
- Generation* old_gen() { return _old_gen; }
+ Generation* young_gen() const { return _young_gen; }
+ Generation* old_gen() const { return _old_gen; }
// The generational collector policy.
GenCollectorPolicy* gen_policy() const { return _gen_policy; }
@@ -218,7 +215,7 @@
bool is_in_young(oop p);
#ifdef ASSERT
- virtual bool is_in_partial_collection(const void* p);
+ bool is_in_partial_collection(const void* p);
#endif
virtual bool is_scavengable(const void* addr) {
@@ -373,27 +370,6 @@
// collection.
virtual bool is_maximal_no_gc() const;
- // Return the generation before "gen".
- Generation* prev_gen(Generation* gen) const {
- guarantee(gen->level() == 1, "Out of bounds");
- return _young_gen;
- }
-
- // Return the generation after "gen".
- Generation* next_gen(Generation* gen) const {
- guarantee(gen->level() == 0, "Out of bounds");
- return _old_gen;
- }
-
- Generation* get_gen(int i) const {
- guarantee(i == 0 || i == 1, "Out of bounds");
- if (i == 0) {
- return _young_gen;
- } else {
- return _old_gen;
- }
- }
-
int n_gens() const {
assert(_n_gens == gen_policy()->number_of_generations(), "Sanity");
return _n_gens;
@@ -408,6 +384,7 @@
static GenCollectedHeap* heap();
void set_par_threads(uint t);
+ void set_n_termination(uint t);
// Invoke the "do_oop" method of one of the closures "not_older_gens"
// or "older_gens" on root locations for the generation at
@@ -421,11 +398,25 @@
// The "so" argument determines which of the roots
// the closure is applied to:
// "SO_None" does none;
+ enum ScanningOption {
+ SO_None = 0x0,
+ SO_AllCodeCache = 0x8,
+ SO_ScavengeCodeCache = 0x10
+ };
+
private:
+ void process_roots(bool activate_scope,
+ ScanningOption so,
+ OopClosure* strong_roots,
+ OopClosure* weak_roots,
+ CLDClosure* strong_cld_closure,
+ CLDClosure* weak_cld_closure,
+ CodeBlobClosure* code_roots);
+
void gen_process_roots(int level,
bool younger_gens_as_roots,
bool activate_scope,
- SharedHeap::ScanningOption so,
+ ScanningOption so,
OopsInGenClosure* not_older_gens,
OopsInGenClosure* weak_roots,
OopsInGenClosure* older_gens,
@@ -440,7 +431,7 @@
void gen_process_roots(int level,
bool younger_gens_as_roots,
bool activate_scope,
- SharedHeap::ScanningOption so,
+ ScanningOption so,
bool only_strong_roots,
OopsInGenClosure* not_older_gens,
OopsInGenClosure* older_gens,
@@ -486,7 +477,7 @@
assert(heap()->collector_policy()->is_generation_policy(),
"the following definition may not be suitable for an n(>2)-generation system");
return incremental_collection_failed() ||
- (consult_young && !get_gen(0)->collection_attempt_is_safe());
+ (consult_young && !_young_gen->collection_attempt_is_safe());
}
// If a generation bails out of an incremental collection,
--- a/hotspot/src/share/vm/memory/genMarkSweep.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/memory/genMarkSweep.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -50,6 +50,7 @@
#include "runtime/vmThread.hpp"
#include "utilities/copy.hpp"
#include "utilities/events.hpp"
+#include "utilities/stack.inline.hpp"
void GenMarkSweep::invoke_at_safepoint(int level, ReferenceProcessor* rp, bool clear_all_softrefs) {
guarantee(level == 1, "We always collect both old and young.");
@@ -109,20 +110,16 @@
deallocate_stacks();
- // If compaction completely evacuated all generations younger than this
- // one, then we can clear the card table. Otherwise, we must invalidate
+ // If compaction completely evacuated the young generation then we
+ // can clear the card table. Otherwise, we must invalidate
// it (consider all cards dirty). In the future, we might consider doing
// compaction within generations only, and doing card-table sliding.
- bool all_empty = true;
- for (int i = 0; all_empty && i < level; i++) {
- Generation* g = gch->get_gen(i);
- all_empty = all_empty && gch->get_gen(i)->used() == 0;
- }
GenRemSet* rs = gch->rem_set();
- Generation* old_gen = gch->get_gen(level);
+ Generation* old_gen = gch->old_gen();
+
// Clear/invalidate below make use of the "prev_used_regions" saved earlier.
- if (all_empty) {
- // We've evacuated all generations below us.
+ if (gch->young_gen()->used() == 0) {
+ // We've evacuated the young generation.
rs->clear_into_younger(old_gen);
} else {
// Invalidate the cards corresponding to the currently used
@@ -157,9 +154,8 @@
void GenMarkSweep::allocate_stacks() {
GenCollectedHeap* gch = GenCollectedHeap::heap();
- // Scratch request on behalf of oldest generation; will do no
- // allocation.
- ScratchBlock* scratch = gch->gather_scratch(gch->get_gen(gch->_n_gens-1), 0);
+ // Scratch request on behalf of old generation; will do no allocation.
+ ScratchBlock* scratch = gch->gather_scratch(gch->old_gen(), 0);
// $$$ To cut a corner, we'll only use the first scratch block, and then
// revert to malloc.
@@ -188,7 +184,7 @@
}
void GenMarkSweep::mark_sweep_phase1(int level,
- bool clear_all_softrefs) {
+ bool clear_all_softrefs) {
// Recursively traverse all live objects and mark them
GCTraceTime tm("phase 1", PrintGC && Verbose, true, _gc_timer, _gc_tracer->gc_id());
trace(" 1");
@@ -199,7 +195,8 @@
// use OopsInGenClosure constructor which takes a generation,
// as the Universe has not been created when the static constructors
// are run.
- follow_root_closure.set_orig_generation(gch->get_gen(level));
+ assert(level == 1, "We don't use mark-sweep on young generations");
+ follow_root_closure.set_orig_generation(gch->old_gen());
// Need new claim bits before marking starts.
ClassLoaderDataGraph::clear_claimed_marks();
@@ -207,7 +204,7 @@
gch->gen_process_roots(level,
false, // Younger gens are not roots.
true, // activate StrongRootsScope
- SharedHeap::SO_None,
+ GenCollectedHeap::SO_None,
GenCollectedHeap::StrongRootsOnly,
&follow_root_closure,
&follow_root_closure,
@@ -287,12 +284,13 @@
// use OopsInGenClosure constructor which takes a generation,
// as the Universe has not been created when the static constructors
// are run.
- adjust_pointer_closure.set_orig_generation(gch->get_gen(level));
+ assert(level == 1, "We don't use mark-sweep on young generations.");
+ adjust_pointer_closure.set_orig_generation(gch->old_gen());
gch->gen_process_roots(level,
false, // Younger gens are not roots.
true, // activate StrongRootsScope
- SharedHeap::SO_AllCodeCache,
+ GenCollectedHeap::SO_AllCodeCache,
GenCollectedHeap::StrongAndWeakRoots,
&adjust_pointer_closure,
&adjust_pointer_closure,
--- a/hotspot/src/share/vm/memory/generation.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/memory/generation.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -42,8 +42,6 @@
#include "utilities/copy.hpp"
#include "utilities/events.hpp"
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
Generation::Generation(ReservedSpace rs, size_t initial_size, int level) :
_level(level),
_ref_processor(NULL) {
@@ -63,8 +61,8 @@
GenerationSpec* Generation::spec() {
GenCollectedHeap* gch = GenCollectedHeap::heap();
- assert(0 <= level() && level() < gch->_n_gens, "Bad gen level");
- return gch->_gen_specs[level()];
+ assert(level() == 0 || level() == 1, "Bad gen level");
+ return level() == 0 ? gch->gen_policy()->young_gen_spec() : gch->gen_policy()->old_gen_spec();
}
size_t Generation::max_capacity() const {
@@ -103,9 +101,9 @@
st->print(" total " SIZE_FORMAT "K, used " SIZE_FORMAT "K",
capacity()/K, used()/K);
st->print_cr(" [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " INTPTR_FORMAT ")",
- _virtual_space.low_boundary(),
- _virtual_space.high(),
- _virtual_space.high_boundary());
+ p2i(_virtual_space.low_boundary()),
+ p2i(_virtual_space.high()),
+ p2i(_virtual_space.high_boundary()));
}
void Generation::print_summary_info() { print_summary_info_on(tty); }
@@ -153,9 +151,8 @@
Generation* Generation::next_gen() const {
GenCollectedHeap* gch = GenCollectedHeap::heap();
- int next = level() + 1;
- if (next < gch->_n_gens) {
- return gch->get_gen(next);
+ if (level() == 0) {
+ return gch->old_gen();
} else {
return NULL;
}
--- a/hotspot/src/share/vm/memory/generation.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/memory/generation.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -399,7 +399,7 @@
// have to guard against non-monotonicity.
NOT_PRODUCT(
if (now < _time_of_last_gc) {
- warning("time warp: "INT64_FORMAT" to "INT64_FORMAT, (int64_t)_time_of_last_gc, (int64_t)now);
+ warning("time warp: " JLONG_FORMAT " to " JLONG_FORMAT, _time_of_last_gc, now);
}
)
return _time_of_last_gc;
--- a/hotspot/src/share/vm/memory/generationSpec.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/memory/generationSpec.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -39,11 +39,11 @@
size_t _max_size;
public:
- GenerationSpec(Generation::Name name, size_t init_size, size_t max_size) {
- _name = name;
- _init_size = init_size;
- _max_size = max_size;
- }
+ GenerationSpec(Generation::Name name, size_t init_size, size_t max_size, size_t alignment) :
+ _name(name),
+ _init_size(align_size_up(init_size, alignment)),
+ _max_size(align_size_up(max_size, alignment))
+ { }
Generation* init(ReservedSpace rs, int level, GenRemSet* remset);
@@ -53,12 +53,6 @@
void set_init_size(size_t size) { _init_size = size; }
size_t max_size() const { return _max_size; }
void set_max_size(size_t size) { _max_size = size; }
-
- // Alignment
- void align(size_t alignment) {
- set_init_size(align_size_up(init_size(), alignment));
- set_max_size(align_size_up(max_size(), alignment));
- }
};
typedef GenerationSpec* GenerationSpecPtr;
--- a/hotspot/src/share/vm/memory/heapInspection.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/memory/heapInspection.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -33,12 +33,11 @@
#include "runtime/os.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp"
+#include "utilities/stack.inline.hpp"
#if INCLUDE_ALL_GCS
#include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
#endif // INCLUDE_ALL_GCS
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
// HeapInspection
inline KlassInfoEntry::~KlassInfoEntry() {
@@ -99,8 +98,8 @@
// simplify the formatting (ILP32 vs LP64) - always cast the numbers to 64-bit
st->print_cr(INT64_FORMAT_W(13) " " UINT64_FORMAT_W(13) " %s",
- (jlong) _instance_count,
- (julong) _instance_words * HeapWordSize,
+ (int64_t)_instance_count,
+ (uint64_t)_instance_words * HeapWordSize,
name());
}
@@ -239,8 +238,8 @@
void KlassInfoHisto::print_elements(outputStream* st) const {
// simplify the formatting (ILP32 vs LP64) - store the sum in 64-bit
- jlong total = 0;
- julong totalw = 0;
+ int64_t total = 0;
+ uint64_t totalw = 0;
for(int i=0; i < elements()->length(); i++) {
st->print("%4d: ", i+1);
elements()->at(i)->print_on(st);
@@ -450,7 +449,7 @@
if (loader_oop == NULL) {
st->print("null");
} else {
- st->print(INTPTR_FORMAT, klass->class_loader_data());
+ st->print(INTPTR_FORMAT, p2i(klass->class_loader_data()));
}
}
@@ -556,13 +555,13 @@
}
if (csv_format) {
- st->print("%d,%d", e->index(), super_index);
+ st->print("%ld,%d", e->index(), super_index);
for (int c=0; c<KlassSizeStats::_num_columns; c++) {
if (selected[c]) {st->print("," JULONG_FORMAT, col_table[c]);}
}
st->print(",%s",e->name());
} else {
- st->print("%5d %5d", e->index(), super_index);
+ st->print("%5ld %5d", e->index(), super_index);
for (int c=0; c<KlassSizeStats::_num_columns; c++) {
if (selected[c]) {print_julong(st, width_table[c], col_table[c]);}
}
--- a/hotspot/src/share/vm/memory/metachunk.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/memory/metachunk.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -28,8 +28,6 @@
#include "utilities/copy.hpp"
#include "utilities/debug.hpp"
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
class VirtualSpaceNode;
const size_t metadata_chunk_initialize = 0xf7f7f7f7;
@@ -92,7 +90,7 @@
st->print_cr("Metachunk:"
" bottom " PTR_FORMAT " top " PTR_FORMAT
" end " PTR_FORMAT " size " SIZE_FORMAT,
- bottom(), _top, end(), word_size());
+ p2i(bottom()), p2i(_top), p2i(end()), word_size());
if (Verbose) {
st->print_cr(" used " SIZE_FORMAT " free " SIZE_FORMAT,
used_word_size(), free_word_size());
--- a/hotspot/src/share/vm/memory/metaspace.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/memory/metaspace.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -49,8 +49,6 @@
#include "utilities/debug.hpp"
#include "utilities/macros.hpp"
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
typedef BinaryTreeDictionary<Metablock, FreeList<Metablock> > BlockTreeDictionary;
typedef BinaryTreeDictionary<Metachunk, FreeList<Metachunk> > ChunkTreeDictionary;
@@ -346,7 +344,7 @@
void inc_container_count();
void dec_container_count();
#ifdef ASSERT
- uint container_count_slow();
+ uintx container_count_slow();
void verify_container_count();
#endif
@@ -388,7 +386,7 @@
#define assert_is_ptr_aligned(ptr, alignment) \
assert(is_ptr_aligned(ptr, alignment), \
err_msg(PTR_FORMAT " is not aligned to " \
- SIZE_FORMAT, ptr, alignment))
+ SIZE_FORMAT, p2i(ptr), alignment))
#define assert_is_size_aligned(size, alignment) \
assert(is_size_aligned(size, alignment), \
@@ -463,8 +461,8 @@
}
#ifdef ASSERT
-uint VirtualSpaceNode::container_count_slow() {
- uint count = 0;
+uintx VirtualSpaceNode::container_count_slow() {
+ uintx count = 0;
Metachunk* chunk = first_chunk();
Metachunk* invalid_chunk = (Metachunk*) top();
while (chunk < invalid_chunk ) {
@@ -798,10 +796,7 @@
void VirtualSpaceNode::inc_container_count() {
assert_lock_strong(SpaceManager::expand_lock());
_container_count++;
- assert(_container_count == container_count_slow(),
- err_msg("Inconsistency in container_count _container_count " SIZE_FORMAT
- " container_count_slow() " SIZE_FORMAT,
- _container_count, container_count_slow()));
+ DEBUG_ONLY(verify_container_count();)
}
void VirtualSpaceNode::dec_container_count() {
@@ -812,8 +807,8 @@
#ifdef ASSERT
void VirtualSpaceNode::verify_container_count() {
assert(_container_count == container_count_slow(),
- err_msg("Inconsistency in container_count _container_count " SIZE_FORMAT
- " container_count_slow() " SIZE_FORMAT, _container_count, container_count_slow()));
+ err_msg("Inconsistency in container_count _container_count " UINTX_FORMAT
+ " container_count_slow() " UINTX_FORMAT, _container_count, container_count_slow()));
}
#endif
@@ -916,7 +911,7 @@
if (!is_available(chunk_word_size)) {
if (TraceMetadataChunkAllocation) {
- gclog_or_tty->print("VirtualSpaceNode::take_from_committed() not available %d words ", chunk_word_size);
+ gclog_or_tty->print("VirtualSpaceNode::take_from_committed() not available " SIZE_FORMAT " words ", chunk_word_size);
// Dump some information about the virtual space that is nearly full
print_on(gclog_or_tty);
}
@@ -989,7 +984,7 @@
assert(reserved()->start() == (HeapWord*) _rs.base(),
err_msg("Reserved start was not set properly " PTR_FORMAT
- " != " PTR_FORMAT, reserved()->start(), _rs.base()));
+ " != " PTR_FORMAT, p2i(reserved()->start()), p2i(_rs.base())));
assert(reserved()->word_size() == _rs.size() / BytesPerWord,
err_msg("Reserved size was not set properly " SIZE_FORMAT
" != " SIZE_FORMAT, reserved()->word_size(),
@@ -1003,13 +998,13 @@
size_t used = used_words_in_vs();
size_t capacity = capacity_words_in_vs();
VirtualSpace* vs = virtual_space();
- st->print_cr(" space @ " PTR_FORMAT " " SIZE_FORMAT "K, %3d%% used "
+ st->print_cr(" space @ " PTR_FORMAT " " SIZE_FORMAT "K, " SIZE_FORMAT_W(3) "%% used "
"[" PTR_FORMAT ", " PTR_FORMAT ", "
PTR_FORMAT ", " PTR_FORMAT ")",
- vs, capacity / K,
+ p2i(vs), capacity / K,
capacity == 0 ? 0 : used * 100 / capacity,
- bottom(), top(), end(),
- vs->high_boundary());
+ p2i(bottom()), p2i(top()), p2i(end()),
+ p2i(vs->high_boundary()));
}
#ifdef ASSERT
@@ -1812,7 +1807,7 @@
if (TraceMetadataChunkAllocation && Verbose) {
gclog_or_tty->print_cr("ChunkManager::free_chunks_get: free_list "
PTR_FORMAT " head " PTR_FORMAT " size " SIZE_FORMAT,
- free_list, chunk, chunk->word_size());
+ p2i(free_list), p2i(chunk), chunk->word_size());
}
} else {
chunk = humongous_dictionary()->get_chunk(
@@ -1872,7 +1867,7 @@
}
gclog_or_tty->print("ChunkManager::chunk_freelist_allocate: " PTR_FORMAT " chunk "
PTR_FORMAT " size " SIZE_FORMAT " count " SIZE_FORMAT " ",
- this, chunk, chunk->word_size(), list_count);
+ p2i(this), p2i(chunk), chunk->word_size(), list_count);
locked_print_free_chunks(gclog_or_tty);
}
@@ -2019,7 +2014,7 @@
for (ChunkIndex i = ZeroIndex; i < NumberOfInUseLists; i = next_chunk_index(i)) {
Metachunk* chunk = chunks_in_use(i);
st->print("SpaceManager: %s " PTR_FORMAT,
- chunk_size_name(i), chunk);
+ chunk_size_name(i), p2i(chunk));
if (chunk != NULL) {
st->print_cr(" free " SIZE_FORMAT,
chunk->free_word_size());
@@ -2130,8 +2125,8 @@
for (ChunkIndex i = ZeroIndex;
i < NumberOfInUseLists ;
i = next_chunk_index(i) ) {
- st->print_cr(" chunks_in_use " PTR_FORMAT " chunk size " PTR_FORMAT,
- chunks_in_use(i),
+ st->print_cr(" chunks_in_use " PTR_FORMAT " chunk size " SIZE_FORMAT,
+ p2i(chunks_in_use(i)),
chunks_in_use(i) == NULL ? 0 : chunks_in_use(i)->word_size());
}
st->print_cr(" waste: Small " SIZE_FORMAT " Medium " SIZE_FORMAT
@@ -2194,7 +2189,7 @@
}
_current_chunk = NULL;
if (TraceMetadataChunkAllocation && Verbose) {
- gclog_or_tty->print_cr("SpaceManager(): " PTR_FORMAT, this);
+ gclog_or_tty->print_cr("SpaceManager(): " PTR_FORMAT, p2i(this));
}
}
@@ -2238,7 +2233,7 @@
dec_total_from_size_metrics();
if (TraceMetadataChunkAllocation && Verbose) {
- gclog_or_tty->print_cr("~SpaceManager(): " PTR_FORMAT, this);
+ gclog_or_tty->print_cr("~SpaceManager(): " PTR_FORMAT, p2i(this));
locked_print_chunks_in_use_on(gclog_or_tty);
}
@@ -2258,7 +2253,7 @@
for (ChunkIndex i = ZeroIndex; i < HumongousIndex; i = next_chunk_index(i)) {
if (TraceMetadataChunkAllocation && Verbose) {
- gclog_or_tty->print_cr("returned %d %s chunks to freelist",
+ gclog_or_tty->print_cr("returned " SIZE_FORMAT " %s chunks to freelist",
sum_count_in_chunks_in_use(i),
chunk_size_name(i));
}
@@ -2266,7 +2261,7 @@
chunk_manager()->return_chunks(i, chunks);
set_chunks_in_use(i, NULL);
if (TraceMetadataChunkAllocation && Verbose) {
- gclog_or_tty->print_cr("updated freelist count %d %s",
+ gclog_or_tty->print_cr("updated freelist count " SSIZE_FORMAT " %s",
chunk_manager()->free_chunks(i)->count(),
chunk_size_name(i));
}
@@ -2279,7 +2274,7 @@
// Humongous chunks
if (TraceMetadataChunkAllocation && Verbose) {
- gclog_or_tty->print_cr("returned %d %s humongous chunks to dictionary",
+ gclog_or_tty->print_cr("returned " SIZE_FORMAT " %s humongous chunks to dictionary",
sum_count_in_chunks_in_use(HumongousIndex),
chunk_size_name(HumongousIndex));
gclog_or_tty->print("Humongous chunk dictionary: ");
@@ -2293,14 +2288,14 @@
#endif
if (TraceMetadataChunkAllocation && Verbose) {
gclog_or_tty->print(PTR_FORMAT " (" SIZE_FORMAT ") ",
- humongous_chunks,
+ p2i(humongous_chunks),
humongous_chunks->word_size());
}
assert(humongous_chunks->word_size() == (size_t)
align_size_up(humongous_chunks->word_size(),
smallest_chunk_size()),
err_msg("Humongous chunk size is wrong: word size " SIZE_FORMAT
- " granularity %d",
+ " granularity " SIZE_FORMAT,
humongous_chunks->word_size(), smallest_chunk_size()));
Metachunk* next_humongous_chunks = humongous_chunks->next();
humongous_chunks->container()->dec_container_count();
@@ -2309,7 +2304,7 @@
}
if (TraceMetadataChunkAllocation && Verbose) {
gclog_or_tty->cr();
- gclog_or_tty->print_cr("updated dictionary count %d %s",
+ gclog_or_tty->print_cr("updated dictionary count " SIZE_FORMAT " %s",
chunk_manager()->humongous_dictionary()->total_count(),
chunk_size_name(HumongousIndex));
}
@@ -2399,7 +2394,7 @@
assert(new_chunk->is_empty(), "Not ready for reuse");
if (TraceMetadataChunkAllocation && Verbose) {
- gclog_or_tty->print("SpaceManager::add_chunk: %d) ",
+ gclog_or_tty->print("SpaceManager::add_chunk: " SIZE_FORMAT ") ",
sum_count_in_chunks_in_use());
new_chunk->print_on(gclog_or_tty);
chunk_manager()->locked_print_free_chunks(gclog_or_tty);
@@ -3097,7 +3092,7 @@
metaspace_rs = ReservedSpace(compressed_class_space_size(),
_reserve_alignment, large_pages);
if (!metaspace_rs.is_reserved()) {
- vm_exit_during_initialization(err_msg("Could not allocate metaspace: %d bytes",
+ vm_exit_during_initialization(err_msg("Could not allocate metaspace: " SIZE_FORMAT " bytes",
compressed_class_space_size()));
}
}
@@ -3119,10 +3114,10 @@
initialize_class_space(metaspace_rs);
if (PrintCompressedOopsMode || (PrintMiscellaneous && Verbose)) {
- gclog_or_tty->print_cr("Narrow klass base: " PTR_FORMAT ", Narrow klass shift: " SIZE_FORMAT,
- Universe::narrow_klass_base(), Universe::narrow_klass_shift());
+ gclog_or_tty->print_cr("Narrow klass base: " PTR_FORMAT ", Narrow klass shift: %d",
+ p2i(Universe::narrow_klass_base()), Universe::narrow_klass_shift());
gclog_or_tty->print_cr("Compressed class space size: " SIZE_FORMAT " Address: " PTR_FORMAT " Req Addr: " PTR_FORMAT,
- compressed_class_space_size(), metaspace_rs.base(), requested_addr);
+ compressed_class_space_size(), p2i(metaspace_rs.base()), p2i(requested_addr));
}
}
@@ -3131,7 +3126,7 @@
void Metaspace::initialize_class_space(ReservedSpace rs) {
// The reserved space size may be bigger because of alignment, esp with UseLargePages
assert(rs.size() >= CompressedClassSpaceSize,
- err_msg(SIZE_FORMAT " != " UINTX_FORMAT, rs.size(), CompressedClassSpaceSize));
+ err_msg(SIZE_FORMAT " != " SIZE_FORMAT, rs.size(), CompressedClassSpaceSize));
assert(using_class_space(), "Must be using class space");
_class_space_list = new VirtualSpaceList(rs);
_chunk_manager_class = new ChunkManager(SpecializedChunk, ClassSmallChunk, ClassMediumChunk);
@@ -3251,7 +3246,7 @@
vm_exit_during_initialization("Unable to dump shared archive.",
err_msg("Size of archive (" SIZE_FORMAT ") + compressed class space ("
SIZE_FORMAT ") == total (" SIZE_FORMAT ") is larger than compressed "
- "klass limit: " SIZE_FORMAT, cds_total, compressed_class_space_size(),
+ "klass limit: " UINT64_FORMAT, cds_total, compressed_class_space_size(),
cds_total + compressed_class_space_size(), UnscaledClassSpaceMax));
}
@@ -3262,7 +3257,7 @@
Universe::set_narrow_klass_base((address)_space_list->current_virtual_space()->bottom());
if (TraceMetavirtualspaceAllocation && Verbose) {
gclog_or_tty->print_cr("Setting_narrow_klass_base to Address: " PTR_FORMAT,
- _space_list->current_virtual_space()->bottom());
+ p2i(_space_list->current_virtual_space()->bottom()));
}
Universe::set_narrow_klass_shift(0);
@@ -3768,10 +3763,10 @@
}
void Metaspace::dump(outputStream* const out) const {
- out->print_cr("\nVirtual space manager: " INTPTR_FORMAT, vsm());
+ out->print_cr("\nVirtual space manager: " INTPTR_FORMAT, p2i(vsm()));
vsm()->dump(out);
if (using_class_space()) {
- out->print_cr("\nClass space manager: " INTPTR_FORMAT, class_vsm());
+ out->print_cr("\nClass space manager: " INTPTR_FORMAT, p2i(class_vsm()));
class_vsm()->dump(out);
}
}
@@ -3932,13 +3927,13 @@
assert(vsn.is_available(word_size), \
err_msg(#word_size ": " PTR_FORMAT " bytes were not available in " \
"VirtualSpaceNode [" PTR_FORMAT ", " PTR_FORMAT ")", \
- (uintptr_t)(word_size * BytesPerWord), vsn.bottom(), vsn.end()));
+ (uintptr_t)(word_size * BytesPerWord), p2i(vsn.bottom()), p2i(vsn.end())));
#define assert_is_available_negative(word_size) \
assert(!vsn.is_available(word_size), \
err_msg(#word_size ": " PTR_FORMAT " bytes should not be available in " \
"VirtualSpaceNode [" PTR_FORMAT ", " PTR_FORMAT ")", \
- (uintptr_t)(word_size * BytesPerWord), vsn.bottom(), vsn.end()));
+ (uintptr_t)(word_size * BytesPerWord), p2i(vsn.bottom()), p2i(vsn.end())));
static void test_is_available_positive() {
// Reserve some memory.
--- a/hotspot/src/share/vm/memory/metaspaceShared.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/memory/metaspaceShared.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -410,7 +410,7 @@
// Split up and initialize the misc code and data spaces
ReservedSpace* shared_rs = MetaspaceShared::shared_rs();
- int metadata_size = SharedReadOnlySize+SharedReadWriteSize;
+ size_t metadata_size = SharedReadOnlySize + SharedReadWriteSize;
ReservedSpace shared_ro_rw = shared_rs->first_part(metadata_size);
ReservedSpace misc_section = shared_rs->last_part(metadata_size);
--- a/hotspot/src/share/vm/memory/referenceProcessor.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/memory/referenceProcessor.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -35,8 +35,6 @@
#include "runtime/java.hpp"
#include "runtime/jniHandles.hpp"
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
ReferencePolicy* ReferenceProcessor::_always_clear_soft_ref_policy = NULL;
ReferencePolicy* ReferenceProcessor::_default_soft_ref_policy = NULL;
bool ReferenceProcessor::_pending_list_uses_discovered_field = false;
@@ -161,7 +159,7 @@
NOT_PRODUCT(
if (now < _soft_ref_timestamp_clock) {
- warning("time warp: "INT64_FORMAT" to "INT64_FORMAT,
+ warning("time warp: " JLONG_FORMAT " to " JLONG_FORMAT,
_soft_ref_timestamp_clock, now);
}
)
@@ -361,7 +359,7 @@
// field.
if (TraceReferenceGC && PrintGCDetails) {
gclog_or_tty->print_cr("ReferenceProcessor::enqueue_discovered_reflist list "
- INTPTR_FORMAT, (address)refs_list.head());
+ INTPTR_FORMAT, p2i(refs_list.head()));
}
oop obj = NULL;
@@ -375,7 +373,7 @@
next_d = java_lang_ref_Reference::discovered(obj);
if (TraceReferenceGC && PrintGCDetails) {
gclog_or_tty->print_cr(" obj " INTPTR_FORMAT "/next_d " INTPTR_FORMAT,
- (void *)obj, (void *)next_d);
+ p2i(obj), p2i(next_d));
}
assert(java_lang_ref_Reference::next(obj) == NULL,
"Reference not active; should not be discovered");
@@ -402,7 +400,7 @@
next_d = java_lang_ref_Reference::discovered(obj);
if (TraceReferenceGC && PrintGCDetails) {
gclog_or_tty->print_cr(" obj " INTPTR_FORMAT "/next_d " INTPTR_FORMAT,
- (void *)obj, (void *)next_d);
+ p2i(obj), p2i(next_d));
}
assert(java_lang_ref_Reference::next(obj) == NULL,
"The reference should not be enqueued");
@@ -565,7 +563,7 @@
!policy->should_clear_reference(iter.obj(), _soft_ref_timestamp_clock)) {
if (TraceReferenceGC) {
gclog_or_tty->print_cr("Dropping reference (" INTPTR_FORMAT ": %s" ") by policy",
- (void *)iter.obj(), iter.obj()->klass()->internal_name());
+ p2i(iter.obj()), iter.obj()->klass()->internal_name());
}
// Remove Reference object from list
iter.remove();
@@ -582,9 +580,9 @@
complete_gc->do_void();
NOT_PRODUCT(
if (PrintGCDetails && TraceReferenceGC) {
- gclog_or_tty->print_cr(" Dropped %d dead Refs out of %d "
- "discovered Refs by policy, from list " INTPTR_FORMAT,
- iter.removed(), iter.processed(), (address)refs_list.head());
+ gclog_or_tty->print_cr(" Dropped " SIZE_FORMAT " dead Refs out of " SIZE_FORMAT
+ " discovered Refs by policy, from list " INTPTR_FORMAT,
+ iter.removed(), iter.processed(), p2i(refs_list.head()));
}
)
}
@@ -604,7 +602,7 @@
if (iter.is_referent_alive()) {
if (TraceReferenceGC) {
gclog_or_tty->print_cr("Dropping strongly reachable reference (" INTPTR_FORMAT ": %s)",
- (void *)iter.obj(), iter.obj()->klass()->internal_name());
+ p2i(iter.obj()), iter.obj()->klass()->internal_name());
}
// The referent is reachable after all.
// Remove Reference object from list.
@@ -620,9 +618,9 @@
}
NOT_PRODUCT(
if (PrintGCDetails && TraceReferenceGC && (iter.processed() > 0)) {
- gclog_or_tty->print_cr(" Dropped %d active Refs out of %d "
- "Refs in discovered list " INTPTR_FORMAT,
- iter.removed(), iter.processed(), (address)refs_list.head());
+ gclog_or_tty->print_cr(" Dropped " SIZE_FORMAT " active Refs out of " SIZE_FORMAT
+ " Refs in discovered list " INTPTR_FORMAT,
+ iter.removed(), iter.processed(), p2i(refs_list.head()));
}
)
}
@@ -659,9 +657,9 @@
complete_gc->do_void();
NOT_PRODUCT(
if (PrintGCDetails && TraceReferenceGC && (iter.processed() > 0)) {
- gclog_or_tty->print_cr(" Dropped %d active Refs out of %d "
- "Refs in discovered list " INTPTR_FORMAT,
- iter.removed(), iter.processed(), (address)refs_list.head());
+ gclog_or_tty->print_cr(" Dropped " SIZE_FORMAT " active Refs out of " SIZE_FORMAT
+ " Refs in discovered list " INTPTR_FORMAT,
+ iter.removed(), iter.processed(), p2i(refs_list.head()));
}
)
}
@@ -678,7 +676,6 @@
ResourceMark rm;
DiscoveredListIterator iter(refs_list, keep_alive, is_alive);
while (iter.has_next()) {
- iter.update_discovered();
iter.load_ptrs(DEBUG_ONLY(false /* allow_null_referent */));
if (clear_referent) {
// NULL out referent pointer
@@ -690,13 +687,11 @@
if (TraceReferenceGC) {
gclog_or_tty->print_cr("Adding %sreference (" INTPTR_FORMAT ": %s) as pending",
clear_referent ? "cleared " : "",
- (void *)iter.obj(), iter.obj()->klass()->internal_name());
+ p2i(iter.obj()), iter.obj()->klass()->internal_name());
}
assert(iter.obj()->is_oop(UseConcMarkSweepGC), "Adding a bad reference");
iter.next();
}
- // Remember to update the next pointer of the last ref.
- iter.update_discovered();
// Close the reachable set
complete_gc->do_void();
}
@@ -807,11 +802,11 @@
for (uint i = 0; i < _max_num_q; ++i) {
total_refs += ref_lists[i].length();
if (TraceReferenceGC && PrintGCDetails) {
- gclog_or_tty->print("%d ", ref_lists[i].length());
+ gclog_or_tty->print(SIZE_FORMAT " ", ref_lists[i].length());
}
}
if (TraceReferenceGC && PrintGCDetails) {
- gclog_or_tty->print_cr(" = %d", total_refs);
+ gclog_or_tty->print_cr(" = " SIZE_FORMAT, total_refs);
}
size_t avg_refs = total_refs / _num_q + 1;
uint to_idx = 0;
@@ -877,11 +872,11 @@
for (uint i = 0; i < _max_num_q; ++i) {
balanced_total_refs += ref_lists[i].length();
if (TraceReferenceGC && PrintGCDetails) {
- gclog_or_tty->print("%d ", ref_lists[i].length());
+ gclog_or_tty->print(SIZE_FORMAT " ", ref_lists[i].length());
}
}
if (TraceReferenceGC && PrintGCDetails) {
- gclog_or_tty->print_cr(" = %d", balanced_total_refs);
+ gclog_or_tty->print_cr(" = " SIZE_FORMAT, balanced_total_refs);
gclog_or_tty->flush();
}
assert(total_refs == balanced_total_refs, "Balancing was incomplete");
@@ -923,7 +918,7 @@
size_t total_list_count = total_count(refs_lists);
if (PrintReferenceGC && PrintGCDetails) {
- gclog_or_tty->print(", %u refs", total_list_count);
+ gclog_or_tty->print(", " SIZE_FORMAT " refs", total_list_count);
}
// Phase 1 (soft refs only):
@@ -1016,7 +1011,7 @@
ShouldNotReachHere();
}
if (TraceReferenceGC && PrintGCDetails) {
- gclog_or_tty->print_cr("Thread %d gets list " INTPTR_FORMAT, id, list);
+ gclog_or_tty->print_cr("Thread %d gets list " INTPTR_FORMAT, id, p2i(list));
}
return list;
}
@@ -1043,14 +1038,14 @@
if (TraceReferenceGC) {
gclog_or_tty->print_cr("Discovered reference (mt) (" INTPTR_FORMAT ": %s)",
- (void *)obj, obj->klass()->internal_name());
+ p2i(obj), obj->klass()->internal_name());
}
} else {
// If retest was non NULL, another thread beat us to it:
// The reference has already been discovered...
if (TraceReferenceGC) {
gclog_or_tty->print_cr("Already discovered reference (" INTPTR_FORMAT ": %s)",
- (void *)obj, obj->klass()->internal_name());
+ p2i(obj), obj->klass()->internal_name());
}
}
}
@@ -1065,7 +1060,7 @@
assert(da ? referent->is_oop() : referent->is_oop_or_null(),
err_msg("Bad referent " INTPTR_FORMAT " found in Reference "
INTPTR_FORMAT " during %satomic discovery ",
- (void *)referent, (void *)obj, da ? "" : "non-"));
+ p2i(referent), p2i(obj), da ? "" : "non-"));
}
#endif
@@ -1145,7 +1140,7 @@
// The reference has already been discovered...
if (TraceReferenceGC) {
gclog_or_tty->print_cr("Already discovered reference (" INTPTR_FORMAT ": %s)",
- (void *)obj, obj->klass()->internal_name());
+ p2i(obj), obj->klass()->internal_name());
}
if (RefDiscoveryPolicy == ReferentBasedDiscovery) {
// assumes that an object is not processed twice;
@@ -1203,7 +1198,7 @@
if (TraceReferenceGC) {
gclog_or_tty->print_cr("Discovered reference (" INTPTR_FORMAT ": %s)",
- (void *)obj, obj->klass()->internal_name());
+ p2i(obj), obj->klass()->internal_name());
}
}
assert(obj->is_oop(), "Discovered a bad reference");
@@ -1314,7 +1309,7 @@
// active; we need to trace and mark its cohort.
if (TraceReferenceGC) {
gclog_or_tty->print_cr("Precleaning Reference (" INTPTR_FORMAT ": %s)",
- (void *)iter.obj(), iter.obj()->klass()->internal_name());
+ p2i(iter.obj()), iter.obj()->klass()->internal_name());
}
// Remove Reference object from list
iter.remove();
@@ -1337,9 +1332,9 @@
NOT_PRODUCT(
if (PrintGCDetails && PrintReferenceGC && (iter.processed() > 0)) {
- gclog_or_tty->print_cr(" Dropped %d Refs out of %d "
- "Refs in discovered list " INTPTR_FORMAT,
- iter.removed(), iter.processed(), (address)refs_list.head());
+ gclog_or_tty->print_cr(" Dropped " SIZE_FORMAT " Refs out of " SIZE_FORMAT
+ " Refs in discovered list " INTPTR_FORMAT,
+ iter.removed(), iter.processed(), p2i(refs_list.head()));
}
)
}
--- a/hotspot/src/share/vm/memory/referenceProcessor.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/memory/referenceProcessor.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -173,20 +173,6 @@
}
}
- // Update the discovered field.
- inline void update_discovered() {
- // First _prev_next ref actually points into DiscoveredList (gross).
- if (UseCompressedOops) {
- if (!oopDesc::is_null(*(narrowOop*)_prev_next)) {
- _keep_alive->do_oop((narrowOop*)_prev_next);
- }
- } else {
- if (!oopDesc::is_null(*(oop*)_prev_next)) {
- _keep_alive->do_oop((oop*)_prev_next);
- }
- }
- }
-
// NULL out referent pointer.
void clear_referent();
--- a/hotspot/src/share/vm/memory/sharedHeap.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/memory/sharedHeap.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -32,40 +32,15 @@
#include "runtime/atomic.inline.hpp"
#include "runtime/fprofiler.hpp"
#include "runtime/java.hpp"
-#include "services/management.hpp"
#include "utilities/copy.hpp"
#include "utilities/workgroup.hpp"
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
SharedHeap* SharedHeap::_sh;
-// The set of potentially parallel tasks in root scanning.
-enum SH_process_roots_tasks {
- SH_PS_Universe_oops_do,
- SH_PS_JNIHandles_oops_do,
- SH_PS_ObjectSynchronizer_oops_do,
- SH_PS_FlatProfiler_oops_do,
- SH_PS_Management_oops_do,
- SH_PS_SystemDictionary_oops_do,
- SH_PS_ClassLoaderDataGraph_oops_do,
- SH_PS_jvmti_oops_do,
- SH_PS_CodeCache_oops_do,
- // Leave this one last.
- SH_PS_NumElements
-};
-
-SharedHeap::SharedHeap(CollectorPolicy* policy_) :
+SharedHeap::SharedHeap() :
CollectedHeap(),
- _collector_policy(policy_),
- _strong_roots_scope(NULL),
- _strong_roots_parity(0),
- _process_strong_tasks(new SubTasksDone(SH_PS_NumElements)),
_workers(NULL)
{
- if (_process_strong_tasks == NULL || !_process_strong_tasks->valid()) {
- vm_exit_during_initialization("Failed necessary allocation.");
- }
_sh = this; // ch is static, should be set only once.
if (UseConcMarkSweepGC || UseG1GC) {
_workers = new FlexibleWorkGang("GC Thread", ParallelGCThreads,
@@ -79,14 +54,6 @@
}
}
-int SharedHeap::n_termination() {
- return _process_strong_tasks->n_threads();
-}
-
-void SharedHeap::set_n_termination(int t) {
- _process_strong_tasks->set_n_threads(t);
-}
-
bool SharedHeap::heap_lock_held_for_gc() {
Thread* t = Thread::current();
return Heap_lock->owned_by_self()
@@ -97,210 +64,20 @@
void SharedHeap::set_par_threads(uint t) {
assert(t == 0 || !UseSerialGC, "Cannot have parallel threads");
_n_par_threads = t;
- _process_strong_tasks->set_n_threads(t);
-}
-
-#ifdef ASSERT
-class AssertNonScavengableClosure: public OopClosure {
-public:
- virtual void do_oop(oop* p) {
- assert(!Universe::heap()->is_in_partial_collection(*p),
- "Referent should not be scavengable."); }
- virtual void do_oop(narrowOop* p) { ShouldNotReachHere(); }
-};
-static AssertNonScavengableClosure assert_is_non_scavengable_closure;
-#endif
-
-SharedHeap::StrongRootsScope* SharedHeap::active_strong_roots_scope() const {
- return _strong_roots_scope;
-}
-void SharedHeap::register_strong_roots_scope(SharedHeap::StrongRootsScope* scope) {
- assert(_strong_roots_scope == NULL, "Should only have one StrongRootsScope active");
- assert(scope != NULL, "Illegal argument");
- _strong_roots_scope = scope;
-}
-void SharedHeap::unregister_strong_roots_scope(SharedHeap::StrongRootsScope* scope) {
- assert(_strong_roots_scope == scope, "Wrong scope unregistered");
- _strong_roots_scope = NULL;
-}
-
-void SharedHeap::change_strong_roots_parity() {
- // Also set the new collection parity.
- assert(_strong_roots_parity >= 0 && _strong_roots_parity <= 2,
- "Not in range.");
- _strong_roots_parity++;
- if (_strong_roots_parity == 3) _strong_roots_parity = 1;
- assert(_strong_roots_parity >= 1 && _strong_roots_parity <= 2,
- "Not in range.");
}
SharedHeap::StrongRootsScope::StrongRootsScope(SharedHeap* heap, bool activate)
- : MarkScope(activate), _sh(heap), _n_workers_done_with_threads(0)
+ : MarkScope(activate), _sh(heap)
{
if (_active) {
- _sh->register_strong_roots_scope(this);
- _sh->change_strong_roots_parity();
+ Threads::change_thread_claim_parity();
// Zero the claimed high water mark in the StringTable
StringTable::clear_parallel_claimed_index();
}
}
SharedHeap::StrongRootsScope::~StrongRootsScope() {
- if (_active) {
- _sh->unregister_strong_roots_scope(this);
- }
-}
-
-Monitor* SharedHeap::StrongRootsScope::_lock = new Monitor(Mutex::leaf, "StrongRootsScope lock", false, Monitor::_safepoint_check_never);
-
-void SharedHeap::StrongRootsScope::mark_worker_done_with_threads(uint n_workers) {
- // The Thread work barrier is only needed by G1 Class Unloading.
- // No need to use the barrier if this is single-threaded code.
- if (UseG1GC && ClassUnloadingWithConcurrentMark && n_workers > 0) {
- uint new_value = (uint)Atomic::add(1, &_n_workers_done_with_threads);
- if (new_value == n_workers) {
- // This thread is last. Notify the others.
- MonitorLockerEx ml(_lock, Mutex::_no_safepoint_check_flag);
- _lock->notify_all();
- }
- }
-}
-
-void SharedHeap::StrongRootsScope::wait_until_all_workers_done_with_threads(uint n_workers) {
- assert(UseG1GC, "Currently only used by G1");
- assert(ClassUnloadingWithConcurrentMark, "Currently only needed when doing G1 Class Unloading");
-
- // No need to use the barrier if this is single-threaded code.
- if (n_workers > 0 && (uint)_n_workers_done_with_threads != n_workers) {
- MonitorLockerEx ml(_lock, Mutex::_no_safepoint_check_flag);
- while ((uint)_n_workers_done_with_threads != n_workers) {
- _lock->wait(Mutex::_no_safepoint_check_flag, 0, false);
- }
- }
-}
-
-void SharedHeap::process_roots(bool activate_scope,
- ScanningOption so,
- OopClosure* strong_roots,
- OopClosure* weak_roots,
- CLDClosure* strong_cld_closure,
- CLDClosure* weak_cld_closure,
- CodeBlobClosure* code_roots) {
- StrongRootsScope srs(this, activate_scope);
-
- // General roots.
- assert(_strong_roots_parity != 0, "must have called prologue code");
- assert(code_roots != NULL, "code root closure should always be set");
- // _n_termination for _process_strong_tasks should be set up stream
- // in a method not running in a GC worker. Otherwise the GC worker
- // could be trying to change the termination condition while the task
- // is executing in another GC worker.
-
- // Iterating over the CLDG and the Threads are done early to allow G1 to
- // first process the strong CLDs and nmethods and then, after a barrier,
- // let the thread process the weak CLDs and nmethods.
-
- if (!_process_strong_tasks->is_task_claimed(SH_PS_ClassLoaderDataGraph_oops_do)) {
- ClassLoaderDataGraph::roots_cld_do(strong_cld_closure, weak_cld_closure);
- }
-
- // Some CLDs contained in the thread frames should be considered strong.
- // Don't process them if they will be processed during the ClassLoaderDataGraph phase.
- CLDClosure* roots_from_clds_p = (strong_cld_closure != weak_cld_closure) ? strong_cld_closure : NULL;
- // Only process code roots from thread stacks if we aren't visiting the entire CodeCache anyway
- CodeBlobClosure* roots_from_code_p = (so & SO_AllCodeCache) ? NULL : code_roots;
-
- Threads::possibly_parallel_oops_do(strong_roots, roots_from_clds_p, roots_from_code_p);
-
- // This is the point where this worker thread will not find more strong CLDs/nmethods.
- // Report this so G1 can synchronize the strong and weak CLDs/nmethods processing.
- active_strong_roots_scope()->mark_worker_done_with_threads(n_par_threads());
-
- if (!_process_strong_tasks->is_task_claimed(SH_PS_Universe_oops_do)) {
- Universe::oops_do(strong_roots);
- }
- // Global (strong) JNI handles
- if (!_process_strong_tasks->is_task_claimed(SH_PS_JNIHandles_oops_do))
- JNIHandles::oops_do(strong_roots);
-
- if (!_process_strong_tasks-> is_task_claimed(SH_PS_ObjectSynchronizer_oops_do))
- ObjectSynchronizer::oops_do(strong_roots);
- if (!_process_strong_tasks->is_task_claimed(SH_PS_FlatProfiler_oops_do))
- FlatProfiler::oops_do(strong_roots);
- if (!_process_strong_tasks->is_task_claimed(SH_PS_Management_oops_do))
- Management::oops_do(strong_roots);
- if (!_process_strong_tasks->is_task_claimed(SH_PS_jvmti_oops_do))
- JvmtiExport::oops_do(strong_roots);
-
- if (!_process_strong_tasks->is_task_claimed(SH_PS_SystemDictionary_oops_do)) {
- SystemDictionary::roots_oops_do(strong_roots, weak_roots);
- }
-
- // All threads execute the following. A specific chunk of buckets
- // from the StringTable are the individual tasks.
- if (weak_roots != NULL) {
- if (CollectedHeap::use_parallel_gc_threads()) {
- StringTable::possibly_parallel_oops_do(weak_roots);
- } else {
- StringTable::oops_do(weak_roots);
- }
- }
-
- if (!_process_strong_tasks->is_task_claimed(SH_PS_CodeCache_oops_do)) {
- if (so & SO_ScavengeCodeCache) {
- assert(code_roots != NULL, "must supply closure for code cache");
-
- // We only visit parts of the CodeCache when scavenging.
- CodeCache::scavenge_root_nmethods_do(code_roots);
- }
- if (so & SO_AllCodeCache) {
- assert(code_roots != NULL, "must supply closure for code cache");
-
- // CMSCollector uses this to do intermediate-strength collections.
- // We scan the entire code cache, since CodeCache::do_unloading is not called.
- CodeCache::blobs_do(code_roots);
- }
- // Verify that the code cache contents are not subject to
- // movement by a scavenging collection.
- DEBUG_ONLY(CodeBlobToOopClosure assert_code_is_non_scavengable(&assert_is_non_scavengable_closure, !CodeBlobToOopClosure::FixRelocations));
- DEBUG_ONLY(CodeCache::asserted_non_scavengable_nmethods_do(&assert_code_is_non_scavengable));
- }
-
- _process_strong_tasks->all_tasks_completed();
-}
-
-void SharedHeap::process_all_roots(bool activate_scope,
- ScanningOption so,
- OopClosure* roots,
- CLDClosure* cld_closure,
- CodeBlobClosure* code_closure) {
- process_roots(activate_scope, so,
- roots, roots,
- cld_closure, cld_closure,
- code_closure);
-}
-
-void SharedHeap::process_strong_roots(bool activate_scope,
- ScanningOption so,
- OopClosure* roots,
- CLDClosure* cld_closure,
- CodeBlobClosure* code_closure) {
- process_roots(activate_scope, so,
- roots, NULL,
- cld_closure, NULL,
- code_closure);
-}
-
-
-class AlwaysTrueClosure: public BoolObjectClosure {
-public:
- bool do_object_b(oop p) { return true; }
-};
-static AlwaysTrueClosure always_true;
-
-void SharedHeap::process_weak_roots(OopClosure* root_closure) {
- // Global (weak) JNI handles
- JNIHandles::weak_oops_do(&always_true, root_closure);
+ Threads::assert_all_threads_claimed();
}
void SharedHeap::set_barrier_set(BarrierSet* bs) {
@@ -315,17 +92,3 @@
}
void SharedHeap::ref_processing_init() {}
-
-// Some utilities.
-void SharedHeap::print_size_transition(outputStream* out,
- size_t bytes_before,
- size_t bytes_after,
- size_t capacity) {
- out->print(" " SIZE_FORMAT "%s->" SIZE_FORMAT "%s(" SIZE_FORMAT "%s)",
- byte_size_in_proper_unit(bytes_before),
- proper_unit_for_byte_size(bytes_before),
- byte_size_in_proper_unit(bytes_after),
- proper_unit_for_byte_size(bytes_after),
- byte_size_in_proper_unit(capacity),
- proper_unit_for_byte_size(capacity));
-}
--- a/hotspot/src/share/vm/memory/sharedHeap.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/memory/sharedHeap.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -61,18 +61,18 @@
// counts the number of tasks that have been done and then reset
// the SubTasksDone so that it can be used again. When the number of
// tasks is set to the number of GC workers, then _n_threads must
-// be set to the number of active GC workers. G1CollectedHeap,
-// HRInto_G1RemSet, GenCollectedHeap and SharedHeap have SubTasksDone.
-// This seems too many.
+// be set to the number of active GC workers. G1RootProcessor and
+// GenCollectedHeap have SubTasksDone.
// 3) SequentialSubTasksDone has an _n_threads that is used in
// a way similar to SubTasksDone and has the same dependency on the
// number of active GC workers. CompactibleFreeListSpace and Space
// have SequentialSubTasksDone's.
-// Example of using SubTasksDone and SequentialSubTasksDone
-// G1CollectedHeap::g1_process_roots()
-// to SharedHeap::process_roots() and uses
-// SubTasksDone* _process_strong_tasks to claim tasks.
-// process_roots() calls
+//
+// Examples of using SubTasksDone and SequentialSubTasksDone:
+// G1RootProcessor and GenCollectedHeap::process_roots() use
+// SubTasksDone* _process_strong_tasks to claim tasks for workers
+//
+// GenCollectedHeap::gen_process_roots() calls
// rem_set()->younger_refs_iterate()
// to scan the card table and which eventually calls down into
// CardTableModRefBS::par_non_clean_card_iterate_work(). This method
@@ -104,29 +104,18 @@
friend class VM_GC_Operation;
friend class VM_CGC_Operation;
-private:
- // For claiming strong_roots tasks.
- SubTasksDone* _process_strong_tasks;
-
protected:
// There should be only a single instance of "SharedHeap" in a program.
// This is enforced with the protected constructor below, which will also
// set the static pointer "_sh" to that instance.
static SharedHeap* _sh;
- // A gc policy, controls global gc resource issues
- CollectorPolicy *_collector_policy;
-
- // See the discussion below, in the specification of the reader function
- // for this variable.
- int _strong_roots_parity;
-
// If we're doing parallel GC, use this gang of threads.
FlexibleWorkGang* _workers;
// Full initialization is done in a concrete subtype's "initialize"
// function.
- SharedHeap(CollectorPolicy* policy_);
+ SharedHeap();
// Returns true if the calling thread holds the heap lock,
// or the calling thread is a par gc thread and the heap_lock is held
@@ -140,7 +129,6 @@
static SharedHeap* heap() { return _sh; }
void set_barrier_set(BarrierSet* bs);
- SubTasksDone* process_strong_tasks() { return _process_strong_tasks; }
// Does operations required after initialization has been done.
virtual void post_initialize();
@@ -161,7 +149,10 @@
bool no_gc_in_progress() { return !is_gc_active(); }
- // Some collectors will perform "process_strong_roots" in parallel.
+ // Note, the below comment needs to be updated to reflect the changes
+ // introduced by JDK-8076225. This should be done as part of JDK-8076289.
+ //
+ //Some collectors will perform "process_strong_roots" in parallel.
// Such a call will involve claiming some fine-grained tasks, such as
// scanning of threads. To make this process simpler, we provide the
// "strong_roots_parity()" method. Collectors that start parallel tasks
@@ -187,74 +178,22 @@
// task-claiming variables may be initialized, to indicate "never
// claimed".
public:
- int strong_roots_parity() { return _strong_roots_parity; }
// Call these in sequential code around process_roots.
// strong_roots_prologue calls change_strong_roots_parity, if
// parallel tasks are enabled.
class StrongRootsScope : public MarkingCodeBlobClosure::MarkScope {
- // Used to implement the Thread work barrier.
- static Monitor* _lock;
-
SharedHeap* _sh;
- volatile jint _n_workers_done_with_threads;
public:
StrongRootsScope(SharedHeap* heap, bool activate = true);
~StrongRootsScope();
-
- // Mark that this thread is done with the Threads work.
- void mark_worker_done_with_threads(uint n_workers);
- // Wait until all n_workers are done with the Threads work.
- void wait_until_all_workers_done_with_threads(uint n_workers);
- };
- friend class StrongRootsScope;
-
- // The current active StrongRootScope
- StrongRootsScope* _strong_roots_scope;
-
- StrongRootsScope* active_strong_roots_scope() const;
-
- private:
- void register_strong_roots_scope(StrongRootsScope* scope);
- void unregister_strong_roots_scope(StrongRootsScope* scope);
- void change_strong_roots_parity();
-
- public:
- enum ScanningOption {
- SO_None = 0x0,
- SO_AllCodeCache = 0x8,
- SO_ScavengeCodeCache = 0x10
};
- FlexibleWorkGang* workers() const { return _workers; }
+ private:
- // Invoke the "do_oop" method the closure "roots" on all root locations.
- // The "so" argument determines which roots the closure is applied to:
- // "SO_None" does none;
- // "SO_AllCodeCache" applies the closure to all elements of the CodeCache.
- // "SO_ScavengeCodeCache" applies the closure to elements on the scavenge root list in the CodeCache.
- void process_roots(bool activate_scope,
- ScanningOption so,
- OopClosure* strong_roots,
- OopClosure* weak_roots,
- CLDClosure* strong_cld_closure,
- CLDClosure* weak_cld_closure,
- CodeBlobClosure* code_roots);
- void process_all_roots(bool activate_scope,
- ScanningOption so,
- OopClosure* roots,
- CLDClosure* cld_closure,
- CodeBlobClosure* code_roots);
- void process_strong_roots(bool activate_scope,
- ScanningOption so,
- OopClosure* roots,
- CLDClosure* cld_closure,
- CodeBlobClosure* code_roots);
-
-
- // Apply "root_closure" to the JNI weak roots..
- void process_weak_roots(OopClosure* root_closure);
+ public:
+ FlexibleWorkGang* workers() const { return _workers; }
// The functions below are helper functions that a subclass of
// "SharedHeap" can use in the implementation of its virtual
@@ -269,23 +208,6 @@
// Sets the number of parallel threads that will be doing tasks
// (such as process roots) subsequently.
virtual void set_par_threads(uint t);
-
- int n_termination();
- void set_n_termination(int t);
-
- //
- // New methods from CollectedHeap
- //
-
- // Some utilities.
- void print_size_transition(outputStream* out,
- size_t bytes_before,
- size_t bytes_after,
- size_t capacity);
};
-inline SharedHeap::ScanningOption operator|(SharedHeap::ScanningOption so0, SharedHeap::ScanningOption so1) {
- return static_cast<SharedHeap::ScanningOption>(static_cast<int>(so0) | static_cast<int>(so1));
-}
-
#endif // SHARE_VM_MEMORY_SHAREDHEAP_HPP
--- a/hotspot/src/share/vm/memory/space.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/memory/space.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -26,7 +26,6 @@
#include "classfile/systemDictionary.hpp"
#include "classfile/vmSymbols.hpp"
#include "gc_implementation/shared/liveRange.hpp"
-#include "gc_implementation/shared/markSweep.hpp"
#include "gc_implementation/shared/spaceDecorator.hpp"
#include "gc_interface/collectedHeap.inline.hpp"
#include "memory/blockOffsetTable.inline.hpp"
@@ -45,8 +44,6 @@
#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp"
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
HeapWord* DirtyCardToOopClosure::get_actual_top(HeapWord* top,
HeapWord* top_obj) {
if (top_obj != NULL) {
@@ -353,15 +350,6 @@
void ContiguousSpace::mangle_unused_area_complete() {
mangler()->mangle_unused_area_complete();
}
-void ContiguousSpace::mangle_region(MemRegion mr) {
- // Although this method uses SpaceMangler::mangle_region() which
- // is not specific to a space, the when the ContiguousSpace version
- // is called, it is always with regard to a space and this
- // bounds checking is appropriate.
- MemRegion space_mr(bottom(), end());
- assert(space_mr.contains(mr), "Mangling outside space");
- SpaceMangler::mangle_region(mr);
-}
#endif // NOT_PRODUCT
void CompactibleSpace::initialize(MemRegion mr,
@@ -388,7 +376,7 @@
cp->space->set_compaction_top(compact_top);
cp->space = cp->space->next_compaction_space();
if (cp->space == NULL) {
- cp->gen = GenCollectedHeap::heap()->prev_gen(cp->gen);
+ cp->gen = GenCollectedHeap::heap()->young_gen();
assert(cp->gen != NULL, "compaction must succeed");
cp->space = cp->gen->first_compaction_space();
assert(cp->space != NULL, "generation must have a first compaction space");
@@ -466,20 +454,20 @@
void Space::print_on(outputStream* st) const {
print_short_on(st);
st->print_cr(" [" INTPTR_FORMAT ", " INTPTR_FORMAT ")",
- bottom(), end());
+ p2i(bottom()), p2i(end()));
}
void ContiguousSpace::print_on(outputStream* st) const {
print_short_on(st);
st->print_cr(" [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " INTPTR_FORMAT ")",
- bottom(), top(), end());
+ p2i(bottom()), p2i(top()), p2i(end()));
}
void OffsetTableContigSpace::print_on(outputStream* st) const {
print_short_on(st);
st->print_cr(" [" INTPTR_FORMAT ", " INTPTR_FORMAT ", "
INTPTR_FORMAT ", " INTPTR_FORMAT ")",
- bottom(), top(), _offsets.threshold(), end());
+ p2i(bottom()), p2i(top()), p2i(_offsets.threshold()), p2i(end()));
}
void ContiguousSpace::verify() const {
@@ -602,7 +590,7 @@
HeapWord* ContiguousSpace::block_start_const(const void* p) const {
assert(MemRegion(bottom(), end()).contains(p),
err_msg("p (" PTR_FORMAT ") not in space [" PTR_FORMAT ", " PTR_FORMAT ")",
- p, bottom(), end()));
+ p2i(p), p2i(bottom()), p2i(end())));
if (p >= top()) {
return top();
} else {
@@ -613,7 +601,7 @@
cur += oop(cur)->size();
}
assert(oop(last)->is_oop(),
- err_msg(PTR_FORMAT " should be an object start", last));
+ err_msg(PTR_FORMAT " should be an object start", p2i(last)));
return last;
}
}
@@ -621,15 +609,15 @@
size_t ContiguousSpace::block_size(const HeapWord* p) const {
assert(MemRegion(bottom(), end()).contains(p),
err_msg("p (" PTR_FORMAT ") not in space [" PTR_FORMAT ", " PTR_FORMAT ")",
- p, bottom(), end()));
+ p2i(p), p2i(bottom()), p2i(end())));
HeapWord* current_top = top();
assert(p <= current_top,
err_msg("p > current top - p: " PTR_FORMAT ", current top: " PTR_FORMAT,
- p, current_top));
+ p2i(p), p2i(current_top)));
assert(p == current_top || oop(p)->is_oop(),
err_msg("p (" PTR_FORMAT ") is not a block start - "
"current_top: " PTR_FORMAT ", is_oop: %s",
- p, current_top, BOOL_TO_STR(oop(p)->is_oop())));
+ p2i(p), p2i(current_top), BOOL_TO_STR(oop(p)->is_oop())));
if (p < current_top) {
return oop(p)->size();
} else {
--- a/hotspot/src/share/vm/memory/space.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/memory/space.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -128,11 +128,10 @@
// For detecting GC bugs. Should only be called at GC boundaries, since
// some unused space may be used as scratch space during GC's.
- // Default implementation does nothing. We also call this when expanding
- // a space to satisfy an allocation request. See bug #4668531
- virtual void mangle_unused_area() {}
- virtual void mangle_unused_area_complete() {}
- virtual void mangle_region(MemRegion mr) {}
+ // We also call this when expanding a space to satisfy an allocation
+ // request. See bug #4668531
+ virtual void mangle_unused_area() = 0;
+ virtual void mangle_unused_area_complete() = 0;
// Testers
bool is_empty() const { return used() == 0; }
@@ -196,7 +195,7 @@
// structure supporting these calls, possibly speeding up future calls.
// The default implementation, however, is simply to call the const
// version.
- inline virtual HeapWord* block_start(const void* p);
+ virtual HeapWord* block_start(const void* p);
// Requires "addr" to be the start of a chunk, and returns its size.
// "addr + size" is required to be the start of a new chunk, or the end
@@ -559,8 +558,6 @@
void mangle_unused_area() PRODUCT_RETURN;
// Mangle [top, end)
void mangle_unused_area_complete() PRODUCT_RETURN;
- // Mangle the given MemRegion.
- void mangle_region(MemRegion mr) PRODUCT_RETURN;
// Do some sparse checking on the area that should have been mangled.
void check_mangled_unused_area(HeapWord* limit) PRODUCT_RETURN;
--- a/hotspot/src/share/vm/memory/space.inline.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/memory/space.inline.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -214,7 +214,7 @@
assert(space->block_is_obj(q), "should be at block boundaries, and should be looking at objs");
// point all the oops to the new location
- size_t size = oop(q)->adjust_pointers();
+ size_t size = MarkSweep::adjust_pointers(oop(q));
size = space->adjust_obj_size(size);
q += size;
@@ -238,7 +238,7 @@
if (oop(q)->is_gc_marked()) {
// q is alive
// point all the oops to the new location
- size_t size = oop(q)->adjust_pointers();
+ size_t size = MarkSweep::adjust_pointers(oop(q));
size = space->adjust_obj_size(size);
debug_only(prev_q = q);
q += size;
--- a/hotspot/src/share/vm/memory/specialized_oop_closures.cpp Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,115 +0,0 @@
-/*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include "precompiled.hpp"
-#include "memory/specialized_oop_closures.hpp"
-#include "utilities/ostream.hpp"
-
-// For keeping stats on effectiveness.
-#ifndef PRODUCT
-#if ENABLE_SPECIALIZATION_STATS
-
-int SpecializationStats::_numCallsAll;
-
-int SpecializationStats::_numCallsTotal[NUM_Kinds];
-int SpecializationStats::_numCalls_nv[NUM_Kinds];
-
-int SpecializationStats::_numDoOopCallsTotal[NUM_Kinds];
-int SpecializationStats::_numDoOopCalls_nv[NUM_Kinds];
-
-void SpecializationStats::clear() {
- _numCallsAll = 0;
- for (int k = ik; k < NUM_Kinds; k++) {
- _numCallsTotal[k] = 0;
- _numCalls_nv[k] = 0;
-
- _numDoOopCallsTotal[k] = 0;
- _numDoOopCalls_nv[k] = 0;
- }
-}
-
-void SpecializationStats::print() {
- const char* header_format = " %20s %10s %11s %10s";
- const char* line_format = " %20s %10d %11d %9.2f%%";
- int all_numCallsTotal =
- _numCallsTotal[ik] + _numCallsTotal[irk] + _numCallsTotal[oa];
- int all_numCalls_nv =
- _numCalls_nv[ik] + _numCalls_nv[irk] + _numCalls_nv[oa];
- gclog_or_tty->print_cr("\nOf %d oop_oop_iterate calls %d (%6.3f%%) are in (ik, irk, oa).",
- _numCallsAll, all_numCallsTotal,
- 100.0 * (float)all_numCallsTotal / (float)_numCallsAll);
- // irk calls are double-counted.
- int real_ik_numCallsTotal = _numCallsTotal[ik] - _numCallsTotal[irk];
- int real_ik_numCalls_nv = _numCalls_nv[ik] - _numCalls_nv[irk];
- gclog_or_tty->print_cr("");
- gclog_or_tty->print_cr(header_format, "oop_oop_iterate:", "calls", "non-virtual", "pct");
- gclog_or_tty->print_cr(header_format,
- "----------",
- "----------",
- "-----------",
- "----------");
- gclog_or_tty->print_cr(line_format, "all",
- all_numCallsTotal,
- all_numCalls_nv,
- 100.0 * (float)all_numCalls_nv / (float)all_numCallsTotal);
- gclog_or_tty->print_cr(line_format, "ik",
- real_ik_numCallsTotal, real_ik_numCalls_nv,
- 100.0 * (float)real_ik_numCalls_nv /
- (float)real_ik_numCallsTotal);
- gclog_or_tty->print_cr(line_format, "irk",
- _numCallsTotal[irk], _numCalls_nv[irk],
- 100.0 * (float)_numCalls_nv[irk] / (float)_numCallsTotal[irk]);
- gclog_or_tty->print_cr(line_format, "oa",
- _numCallsTotal[oa], _numCalls_nv[oa],
- 100.0 * (float)_numCalls_nv[oa] / (float)_numCallsTotal[oa]);
-
-
- gclog_or_tty->print_cr("");
- gclog_or_tty->print_cr(header_format, "do_oop:", "calls", "non-virtual", "pct");
- gclog_or_tty->print_cr(header_format,
- "----------",
- "----------",
- "-----------",
- "----------");
- int all_numDoOopCallsTotal =
- _numDoOopCallsTotal[ik] + _numDoOopCallsTotal[irk] + _numDoOopCallsTotal[oa];
- int all_numDoOopCalls_nv =
- _numDoOopCalls_nv[ik] + _numDoOopCalls_nv[irk] + _numDoOopCalls_nv[oa];
- gclog_or_tty->print_cr(line_format, "all",
- all_numDoOopCallsTotal, all_numDoOopCalls_nv,
- 100.0 * (float)all_numDoOopCalls_nv /
- (float)all_numDoOopCallsTotal);
- const char* kind_names[] = { "ik", "irk", "oa" };
- for (int k = ik; k < NUM_Kinds; k++) {
- gclog_or_tty->print_cr(line_format, kind_names[k],
- _numDoOopCallsTotal[k], _numDoOopCalls_nv[k],
- (_numDoOopCallsTotal[k] > 0 ?
- 100.0 * (float)_numDoOopCalls_nv[k] /
- (float)_numDoOopCallsTotal[k]
- : 0.0));
- }
-}
-
-#endif // ENABLE_SPECIALIZATION_STATS
-#endif // !PRODUCT
--- a/hotspot/src/share/vm/memory/specialized_oop_closures.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/memory/specialized_oop_closures.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -60,21 +60,15 @@
// This macro applies an argument macro to all OopClosures for which we
// want specialized bodies of "oop_oop_iterate". The arguments to "f" are:
// "f(closureType, non_virtual)"
-// where "closureType" is the name of the particular subclass of OopClosure,
+// where "closureType" is the name of the particular subclass of ExtendedOopClosure,
// and "non_virtual" will be the string "_nv" if the closure type should
// have its "do_oop" method invoked non-virtually, or else the
-// string "_v". ("OopClosure" itself will be the only class in the latter
+// string "_v". ("ExtendedOopClosure" itself will be the only class in the latter
// category.)
// This is split into several because of a Visual C++ 6.0 compiler bug
// where very long macros cause the compiler to crash
-// Some other heap might define further specialized closures.
-#ifndef FURTHER_SPECIALIZED_OOP_OOP_ITERATE_CLOSURES
-#define FURTHER_SPECIALIZED_OOP_OOP_ITERATE_CLOSURES(f) \
- /* None */
-#endif
-
#define SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_S(f) \
f(ScanClosure,_nv) \
f(FastScanClosure,_nv) \
@@ -94,7 +88,7 @@
SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_P(f)
#if INCLUDE_ALL_GCS
-#define SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_2(f) \
+#define SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_CMS(f) \
f(MarkRefsIntoAndScanClosure,_nv) \
f(Par_MarkRefsIntoAndScanClosure,_nv) \
f(PushAndMarkClosure,_nv) \
@@ -102,8 +96,13 @@
f(PushOrMarkClosure,_nv) \
f(Par_PushOrMarkClosure,_nv) \
f(CMSKeepAliveClosure,_nv) \
- f(CMSInnerParMarkAndPushClosure,_nv) \
- FURTHER_SPECIALIZED_OOP_OOP_ITERATE_CLOSURES(f)
+ f(CMSInnerParMarkAndPushClosure,_nv)
+#endif
+
+#if INCLUDE_ALL_GCS
+#define SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_2(f) \
+ SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_CMS(f) \
+ SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_G1(f)
#else // INCLUDE_ALL_GCS
#define SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_2(f)
#endif // INCLUDE_ALL_GCS
@@ -144,13 +143,6 @@
// The "root_class" is the most general class to define; this may be
// "OopClosure" in some applications and "OopsInGenClosure" in others.
-
-// Some other heap might define further specialized closures.
-#ifndef FURTHER_SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES
-#define FURTHER_SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES(f) \
- /* None */
-#endif
-
#define SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG_S(f) \
f(ScanClosure,_nv) \
f(FastScanClosure,_nv)
@@ -158,8 +150,7 @@
#if INCLUDE_ALL_GCS
#define SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG_P(f) \
f(ParScanWithBarrierClosure,_nv) \
- f(ParScanWithoutBarrierClosure,_nv) \
- FURTHER_SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES(f)
+ f(ParScanWithoutBarrierClosure,_nv)
#else // INCLUDE_ALL_GCS
#define SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG_P(f)
#endif // INCLUDE_ALL_GCS
@@ -174,93 +165,9 @@
// We separate these out, because sometime the general one has
// a different definition from the specialized ones, and sometimes it
// doesn't.
-// NOTE: One of the valid criticisms of this
-// specialize-oop_oop_iterate-for-specific-closures idiom is that it is
-// easy to have a silent performance bug: if you fail to de-virtualize,
-// things still work, just slower. The "SpecializationStats" mode is
-// intended to at least make such a failure easy to detect.
-// *Not* using the ALL_SINCE_SAVE_MARKS_CLOSURES(f) macro defined
-// below means that *only* closures for which oop_oop_iterate specializations
-// exist above may be applied to "oops_since_save_marks". That is,
-// this form of the performance bug is caught statically. When you add
-// a definition for the general type, this property goes away.
-// Make sure you test with SpecializationStats to find such bugs
-// when introducing a new closure where you don't want virtual dispatch.
#define ALL_SINCE_SAVE_MARKS_CLOSURES(f) \
f(OopsInGenClosure,_v) \
SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES(f)
-// For keeping stats on effectiveness.
-#define ENABLE_SPECIALIZATION_STATS 0
-
-
-class SpecializationStats {
-public:
- enum Kind {
- ik, // InstanceKlass
- irk, // InstanceRefKlass
- oa, // ObjArrayKlass
- NUM_Kinds
- };
-
-#if ENABLE_SPECIALIZATION_STATS
-private:
- static bool _init;
- static bool _wrapped;
- static jint _numCallsAll;
-
- static jint _numCallsTotal[NUM_Kinds];
- static jint _numCalls_nv[NUM_Kinds];
-
- static jint _numDoOopCallsTotal[NUM_Kinds];
- static jint _numDoOopCalls_nv[NUM_Kinds];
-public:
-#endif
- static void clear() PRODUCT_RETURN;
-
- static inline void record_call() PRODUCT_RETURN;
- static inline void record_iterate_call_v(Kind k) PRODUCT_RETURN;
- static inline void record_iterate_call_nv(Kind k) PRODUCT_RETURN;
- static inline void record_do_oop_call_v(Kind k) PRODUCT_RETURN;
- static inline void record_do_oop_call_nv(Kind k) PRODUCT_RETURN;
-
- static void print() PRODUCT_RETURN;
-};
-
-#ifndef PRODUCT
-#if ENABLE_SPECIALIZATION_STATS
-
-inline void SpecializationStats::record_call() {
- Atomic::inc(&_numCallsAll);
-}
-inline void SpecializationStats::record_iterate_call_v(Kind k) {
- Atomic::inc(&_numCallsTotal[k]);
-}
-inline void SpecializationStats::record_iterate_call_nv(Kind k) {
- Atomic::inc(&_numCallsTotal[k]);
- Atomic::inc(&_numCalls_nv[k]);
-}
-
-inline void SpecializationStats::record_do_oop_call_v(Kind k) {
- Atomic::inc(&_numDoOopCallsTotal[k]);
-}
-inline void SpecializationStats::record_do_oop_call_nv(Kind k) {
- Atomic::inc(&_numDoOopCallsTotal[k]);
- Atomic::inc(&_numDoOopCalls_nv[k]);
-}
-
-#else // !ENABLE_SPECIALIZATION_STATS
-
-inline void SpecializationStats::record_call() {}
-inline void SpecializationStats::record_iterate_call_v(Kind k) {}
-inline void SpecializationStats::record_iterate_call_nv(Kind k) {}
-inline void SpecializationStats::record_do_oop_call_v(Kind k) {}
-inline void SpecializationStats::record_do_oop_call_nv(Kind k) {}
-inline void SpecializationStats::clear() {}
-inline void SpecializationStats::print() {}
-
-#endif // ENABLE_SPECIALIZATION_STATS
-#endif // !PRODUCT
-
#endif // SHARE_VM_MEMORY_SPECIALIZED_OOP_CLOSURES_HPP
--- a/hotspot/src/share/vm/memory/tenuredGeneration.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/memory/tenuredGeneration.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -178,7 +178,6 @@
bool is_tlab) {
GenCollectedHeap* gch = GenCollectedHeap::heap();
- SpecializationStats::clear();
// Temporarily expand the span of our ref processor, so
// refs discovery is over the entire heap, not just this generation
ReferenceProcessorSpanMutator
@@ -195,8 +194,6 @@
gc_timer->register_gc_end();
gc_tracer->report_gc_end(gc_timer->gc_end(), gc_timer->time_partitions());
-
- SpecializationStats::print();
}
HeapWord*
--- a/hotspot/src/share/vm/memory/threadLocalAllocBuffer.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/memory/threadLocalAllocBuffer.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -31,8 +31,6 @@
#include "runtime/thread.inline.hpp"
#include "utilities/copy.hpp"
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
// Thread-Local Edens support
// static member initialization
@@ -154,7 +152,7 @@
if (PrintTLAB && Verbose) {
gclog_or_tty->print("TLAB new size: thread: " INTPTR_FORMAT " [id: %2d]"
" refills %d alloc: %8.6f desired_size: " SIZE_FORMAT " -> " SIZE_FORMAT "\n",
- myThread(), myThread()->osthread()->thread_id(),
+ p2i(myThread()), myThread()->osthread()->thread_id(),
_target_refills, _allocation_fraction.average(), desired_size(), aligned_new_size);
}
set_desired_size(aligned_new_size);
@@ -263,7 +261,7 @@
" slow allocs: %d refill waste: " SIZE_FORMAT "B"
" alloc:%8.5f %8.0fKB refills: %d waste %4.1f%% gc: %dB"
" slow: %dB fast: %dB\n",
- tag, thrd, thrd->osthread()->thread_id(),
+ tag, p2i(thrd), thrd->osthread()->thread_id(),
_desired_size / (K / HeapWordSize),
_slow_allocations, _refill_waste_limit * HeapWordSize,
_allocation_fraction.average(),
--- a/hotspot/src/share/vm/memory/universe.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/memory/universe.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -84,8 +84,6 @@
#include "classfile/sharedClassUtil.hpp"
#endif
-PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
-
// Known objects
Klass* Universe::_boolArrayKlassObj = NULL;
Klass* Universe::_byteArrayKlassObj = NULL;
@@ -792,12 +790,12 @@
void Universe::print_compressed_oops_mode() {
tty->cr();
tty->print("heap address: " PTR_FORMAT ", size: " SIZE_FORMAT " MB",
- Universe::heap()->base(), Universe::heap()->reserved_region().byte_size()/M);
+ p2i(Universe::heap()->base()), Universe::heap()->reserved_region().byte_size()/M);
tty->print(", Compressed Oops mode: %s", narrow_oop_mode_to_string(narrow_oop_mode()));
if (Universe::narrow_oop_base() != 0) {
- tty->print(": " PTR_FORMAT, Universe::narrow_oop_base());
+ tty->print(": " PTR_FORMAT, p2i(Universe::narrow_oop_base()));
}
if (Universe::narrow_oop_shift() != 0) {
--- a/hotspot/src/share/vm/oops/cpCache.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/oops/cpCache.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -35,9 +35,6 @@
#include "runtime/handles.inline.hpp"
#include "runtime/orderAccess.inline.hpp"
#include "utilities/macros.hpp"
-#if INCLUDE_ALL_GCS
-# include "gc_implementation/parallelScavenge/psPromotionManager.hpp"
-#endif // INCLUDE_ALL_GCS
PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
--- a/hotspot/src/share/vm/oops/instanceClassLoaderKlass.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/oops/instanceClassLoaderKlass.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,7 @@
#include "memory/genOopClosures.inline.hpp"
#include "memory/iterator.inline.hpp"
#include "memory/oopFactory.hpp"
+#include "memory/specialized_oop_closures.hpp"
#include "oops/instanceKlass.hpp"
#include "oops/instanceClassLoaderKlass.hpp"
#include "oops/instanceMirrorKlass.hpp"
@@ -41,7 +42,6 @@
#if INCLUDE_ALL_GCS
#include "gc_implementation/parNew/parOopClosures.inline.hpp"
#include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
-#include "oops/oop.pcgc.inline.hpp"
#endif // INCLUDE_ALL_GCS
// Macro to define InstanceClassLoaderKlass::oop_oop_iterate for virtual/nonvirtual for
@@ -54,7 +54,6 @@
int InstanceClassLoaderKlass:: \
oop_oop_iterate##nv_suffix(oop obj, OopClosureType* closure) { \
/* Get size before changing pointers */ \
- SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk);\
int size = InstanceKlass::oop_oop_iterate##nv_suffix(obj, closure); \
\
if_do_metadata_checked(closure, nv_suffix) { \
@@ -74,7 +73,6 @@
int InstanceClassLoaderKlass:: \
oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* closure) { \
/* Get size before changing pointers */ \
- SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk);\
int size = InstanceKlass::oop_oop_iterate_backwards##nv_suffix(obj, closure); \
return size; \
}
@@ -87,8 +85,6 @@
oop_oop_iterate##nv_suffix##_m(oop obj, \
OopClosureType* closure, \
MemRegion mr) { \
- SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk);\
- \
int size = InstanceKlass::oop_oop_iterate##nv_suffix##_m(obj, closure, mr); \
\
if_do_metadata_checked(closure, nv_suffix) { \
--- a/hotspot/src/share/vm/oops/instanceClassLoaderKlass.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/oops/instanceClassLoaderKlass.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -25,6 +25,7 @@
#ifndef SHARE_VM_OOPS_INSTANCECLASSLOADERKLASS_HPP
#define SHARE_VM_OOPS_INSTANCECLASSLOADERKLASS_HPP
+#include "memory/specialized_oop_closures.hpp"
#include "oops/instanceKlass.hpp"
#include "utilities/macros.hpp"
--- a/hotspot/src/share/vm/oops/instanceKlass.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/oops/instanceKlass.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -38,6 +38,7 @@
#include "memory/iterator.inline.hpp"
#include "memory/metadataFactory.hpp"
#include "memory/oopFactory.hpp"
+#include "memory/specialized_oop_closures.hpp"
#include "oops/fieldStreams.hpp"
#include "oops/instanceClassLoaderKlass.hpp"
#include "oops/instanceKlass.hpp"
@@ -73,7 +74,6 @@
#include "gc_implementation/parallelScavenge/parallelScavengeHeap.inline.hpp"
#include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
#include "gc_implementation/parallelScavenge/psScavenge.inline.hpp"
-#include "oops/oop.pcgc.inline.hpp"
#endif // INCLUDE_ALL_GCS
#ifdef COMPILER1
#include "c1/c1_Compiler.hpp"
@@ -2209,15 +2209,12 @@
#define InstanceKlass_OOP_OOP_ITERATE_DEFN(OopClosureType, nv_suffix) \
\
int InstanceKlass::oop_oop_iterate##nv_suffix(oop obj, OopClosureType* closure) { \
- SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::ik);\
/* header */ \
if_do_metadata_checked(closure, nv_suffix) { \
closure->do_klass##nv_suffix(obj->klass()); \
} \
InstanceKlass_OOP_MAP_ITERATE( \
obj, \
- SpecializationStats:: \
- record_do_oop_call##nv_suffix(SpecializationStats::ik); \
(closure)->do_oop##nv_suffix(p), \
assert_is_in_closed_subset) \
return size_helper(); \
@@ -2228,14 +2225,11 @@
\
int InstanceKlass::oop_oop_iterate_backwards##nv_suffix(oop obj, \
OopClosureType* closure) { \
- SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::ik); \
- \
assert_should_ignore_metadata(closure, nv_suffix); \
\
/* instance variables */ \
InstanceKlass_OOP_MAP_REVERSE_ITERATE( \
obj, \
- SpecializationStats::record_do_oop_call##nv_suffix(SpecializationStats::ik);\
(closure)->do_oop##nv_suffix(p), \
assert_is_in_closed_subset) \
return size_helper(); \
@@ -2247,7 +2241,6 @@
int InstanceKlass::oop_oop_iterate##nv_suffix##_m(oop obj, \
OopClosureType* closure, \
MemRegion mr) { \
- SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::ik);\
if_do_metadata_checked(closure, nv_suffix) { \
if (mr.contains(obj)) { \
closure->do_klass##nv_suffix(obj->klass()); \
--- a/hotspot/src/share/vm/oops/instanceKlass.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/oops/instanceKlass.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -27,6 +27,7 @@
#include "classfile/classLoaderData.hpp"
#include "memory/referenceType.hpp"
+#include "memory/specialized_oop_closures.hpp"
#include "oops/annotations.hpp"
#include "oops/constMethod.hpp"
#include "oops/fieldInfo.hpp"
--- a/hotspot/src/share/vm/oops/instanceMirrorKlass.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/oops/instanceMirrorKlass.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,7 @@
#include "memory/genOopClosures.inline.hpp"
#include "memory/iterator.inline.hpp"
#include "memory/oopFactory.hpp"
+#include "memory/specialized_oop_closures.hpp"
#include "oops/instanceKlass.hpp"
#include "oops/instanceMirrorKlass.hpp"
#include "oops/instanceOop.hpp"
@@ -46,7 +47,6 @@
#include "gc_implementation/parNew/parOopClosures.inline.hpp"
#include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
#include "gc_implementation/parallelScavenge/psScavenge.inline.hpp"
-#include "oops/oop.pcgc.inline.hpp"
#endif // INCLUDE_ALL_GCS
int InstanceMirrorKlass::_offset_of_static_fields = 0;
@@ -250,8 +250,6 @@
int InstanceMirrorKlass:: \
oop_oop_iterate##nv_suffix(oop obj, OopClosureType* closure) { \
/* Get size before changing pointers */ \
- SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk); \
- \
InstanceKlass::oop_oop_iterate##nv_suffix(obj, closure); \
\
if_do_metadata_checked(closure, nv_suffix) { \
@@ -275,8 +273,6 @@
int InstanceMirrorKlass:: \
oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* closure) { \
/* Get size before changing pointers */ \
- SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk); \
- \
InstanceKlass::oop_oop_iterate_backwards##nv_suffix(obj, closure); \
\
if (UseCompressedOops) { \
@@ -294,8 +290,6 @@
oop_oop_iterate##nv_suffix##_m(oop obj, \
OopClosureType* closure, \
MemRegion mr) { \
- SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk); \
- \
InstanceKlass::oop_oop_iterate##nv_suffix##_m(obj, closure, mr); \
\
if_do_metadata_checked(closure, nv_suffix) { \
--- a/hotspot/src/share/vm/oops/instanceMirrorKlass.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/oops/instanceMirrorKlass.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -26,6 +26,7 @@
#define SHARE_VM_OOPS_INSTANCEMIRRORKLASS_HPP
#include "classfile/systemDictionary.hpp"
+#include "memory/specialized_oop_closures.hpp"
#include "oops/instanceKlass.hpp"
#include "runtime/handles.hpp"
#include "utilities/macros.hpp"
--- a/hotspot/src/share/vm/oops/instanceRefKlass.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/oops/instanceRefKlass.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,7 @@
#include "gc_interface/collectedHeap.inline.hpp"
#include "memory/genCollectedHeap.hpp"
#include "memory/genOopClosures.inline.hpp"
+#include "memory/specialized_oop_closures.hpp"
#include "oops/instanceRefKlass.hpp"
#include "oops/oop.inline.hpp"
#include "utilities/preserveException.hpp"
@@ -42,7 +43,6 @@
#include "gc_implementation/parNew/parOopClosures.inline.hpp"
#include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
#include "gc_implementation/parallelScavenge/psScavenge.inline.hpp"
-#include "oops/oop.pcgc.inline.hpp"
#endif // INCLUDE_ALL_GCS
PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
@@ -260,7 +260,6 @@
return size; \
} else if (contains(referent_addr)) { \
/* treat referent as normal oop */ \
- SpecializationStats::record_do_oop_call##nv_suffix(SpecializationStats::irk);\
closure->do_oop##nv_suffix(referent_addr); \
} \
} \
@@ -276,7 +275,6 @@
INTPTR_FORMAT, disc_addr); \
} \
) \
- SpecializationStats::record_do_oop_call##nv_suffix(SpecializationStats::irk);\
closure->do_oop##nv_suffix(disc_addr); \
} \
} else { \
@@ -293,7 +291,6 @@
} \
/* treat next as normal oop */ \
if (contains(next_addr)) { \
- SpecializationStats::record_do_oop_call##nv_suffix(SpecializationStats::irk); \
closure->do_oop##nv_suffix(next_addr); \
} \
return size; \
@@ -309,8 +306,6 @@
int InstanceRefKlass:: \
oop_oop_iterate##nv_suffix(oop obj, OopClosureType* closure) { \
/* Get size before changing pointers */ \
- SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk);\
- \
int size = InstanceKlass::oop_oop_iterate##nv_suffix(obj, closure); \
\
if (UseCompressedOops) { \
@@ -326,8 +321,6 @@
int InstanceRefKlass:: \
oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* closure) { \
/* Get size before changing pointers */ \
- SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk);\
- \
int size = InstanceKlass::oop_oop_iterate_backwards##nv_suffix(obj, closure); \
\
if (UseCompressedOops) { \
@@ -345,8 +338,6 @@
oop_oop_iterate##nv_suffix##_m(oop obj, \
OopClosureType* closure, \
MemRegion mr) { \
- SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk);\
- \
int size = InstanceKlass::oop_oop_iterate##nv_suffix##_m(obj, closure, mr); \
if (UseCompressedOops) { \
InstanceRefKlass_SPECIALIZED_OOP_ITERATE(narrowOop, nv_suffix, mr.contains); \
--- a/hotspot/src/share/vm/oops/instanceRefKlass.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/oops/instanceRefKlass.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -25,6 +25,7 @@
#ifndef SHARE_VM_OOPS_INSTANCEREFKLASS_HPP
#define SHARE_VM_OOPS_INSTANCEREFKLASS_HPP
+#include "memory/specialized_oop_closures.hpp"
#include "oops/instanceKlass.hpp"
#include "utilities/macros.hpp"
--- a/hotspot/src/share/vm/oops/klass.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/oops/klass.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -39,8 +39,8 @@
#include "runtime/atomic.inline.hpp"
#include "runtime/orderAccess.inline.hpp"
#include "trace/traceMacros.hpp"
-#include "utilities/stack.hpp"
#include "utilities/macros.hpp"
+#include "utilities/stack.inline.hpp"
#if INCLUDE_ALL_GCS
#include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
#include "gc_implementation/parallelScavenge/psParallelCompact.hpp"
--- a/hotspot/src/share/vm/oops/objArrayKlass.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/oops/objArrayKlass.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -32,6 +32,7 @@
#include "memory/iterator.inline.hpp"
#include "memory/metadataFactory.hpp"
#include "memory/resourceArea.hpp"
+#include "memory/specialized_oop_closures.hpp"
#include "memory/universe.inline.hpp"
#include "oops/instanceKlass.hpp"
#include "oops/klass.inline.hpp"
@@ -54,7 +55,6 @@
#include "gc_implementation/parallelScavenge/psCompactionManager.hpp"
#include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
#include "gc_implementation/parallelScavenge/psScavenge.inline.hpp"
-#include "oops/oop.pcgc.inline.hpp"
#endif // INCLUDE_ALL_GCS
ObjArrayKlass* ObjArrayKlass::allocate(ClassLoaderData* loader_data, int n, KlassHandle klass_handle, Symbol* name, TRAPS) {
@@ -479,7 +479,6 @@
\
int ObjArrayKlass::oop_oop_iterate##nv_suffix(oop obj, \
OopClosureType* closure) { \
- SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::oa); \
assert (obj->is_array(), "obj must be array"); \
objArrayOop a = objArrayOop(obj); \
/* Get size before changing pointers. */ \
@@ -497,7 +496,6 @@
int ObjArrayKlass::oop_oop_iterate##nv_suffix##_m(oop obj, \
OopClosureType* closure, \
MemRegion mr) { \
- SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::oa); \
assert(obj->is_array(), "obj must be array"); \
objArrayOop a = objArrayOop(obj); \
/* Get size before changing pointers. */ \
@@ -519,7 +517,6 @@
int ObjArrayKlass::oop_oop_iterate_range##nv_suffix(oop obj, \
OopClosureType* closure, \
int start, int end) { \
- SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::oa); \
assert(obj->is_array(), "obj must be array"); \
objArrayOop a = objArrayOop(obj); \
/* Get size before changing pointers. */ \
--- a/hotspot/src/share/vm/oops/objArrayOop.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/oops/objArrayOop.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -23,6 +23,7 @@
*/
#include "precompiled.hpp"
+#include "memory/specialized_oop_closures.hpp"
#include "oops/objArrayKlass.hpp"
#include "oops/objArrayOop.hpp"
#include "oops/oop.inline.hpp"
@@ -46,7 +47,6 @@
#define ObjArrayOop_OOP_ITERATE_DEFN(OopClosureType, nv_suffix) \
\
int objArrayOopDesc::oop_iterate_range(OopClosureType* blk, int start, int end) { \
- SpecializationStats::record_call(); \
return ((ObjArrayKlass*)klass())->oop_oop_iterate_range##nv_suffix(this, blk, start, end); \
}
--- a/hotspot/src/share/vm/oops/objArrayOop.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/oops/objArrayOop.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -25,6 +25,7 @@
#ifndef SHARE_VM_OOPS_OBJARRAYOOP_HPP
#define SHARE_VM_OOPS_OBJARRAYOOP_HPP
+#include "memory/specialized_oop_closures.hpp"
#include "oops/arrayOop.hpp"
// An objArrayOop is an array containing oops.
--- a/hotspot/src/share/vm/oops/oop.inline.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/oops/oop.inline.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -630,6 +630,30 @@
return cas_set_mark(m, compare) == compare;
}
+#if INCLUDE_ALL_GCS
+inline oop oopDesc::forward_to_atomic(oop p) {
+ markOop oldMark = mark();
+ markOop forwardPtrMark = markOopDesc::encode_pointer_as_mark(p);
+ markOop curMark;
+
+ assert(forwardPtrMark->decode_pointer() == p, "encoding must be reversable");
+ assert(sizeof(markOop) == sizeof(intptr_t), "CAS below requires this.");
+
+ while (!oldMark->is_marked()) {
+ curMark = (markOop)Atomic::cmpxchg_ptr(forwardPtrMark, &_mark, oldMark);
+ assert(is_forwarded(), "object should have been forwarded");
+ if (curMark == oldMark) {
+ return NULL;
+ }
+ // If the CAS was unsuccessful then curMark->is_marked()
+ // should return true as another thread has CAS'd in another
+ // forwarding pointer.
+ oldMark = curMark;
+ }
+ return forwardee();
+}
+#endif
+
// Note that the forwardee is not the same thing as the displaced_mark.
// The forwardee is used when copying during scavenge and mark-sweep.
// It does need to clear the low two locking- and GC-related bits.
@@ -692,12 +716,10 @@
#define OOP_ITERATE_DEFN(OopClosureType, nv_suffix) \
\
inline int oopDesc::oop_iterate(OopClosureType* blk) { \
- SpecializationStats::record_call(); \
return klass()->oop_oop_iterate##nv_suffix(this, blk); \
} \
\
inline int oopDesc::oop_iterate(OopClosureType* blk, MemRegion mr) { \
- SpecializationStats::record_call(); \
return klass()->oop_oop_iterate##nv_suffix##_m(this, blk, mr); \
}
@@ -721,7 +743,6 @@
#define OOP_ITERATE_BACKWARDS_DEFN(OopClosureType, nv_suffix) \
\
inline int oopDesc::oop_iterate_backwards(OopClosureType* blk) { \
- SpecializationStats::record_call(); \
return klass()->oop_oop_iterate_backwards##nv_suffix(this, blk); \
}
--- a/hotspot/src/share/vm/oops/oop.pcgc.inline.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/oops/oop.pcgc.inline.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -54,28 +54,4 @@
klass()->oop_follow_contents(cm, this);
}
-inline oop oopDesc::forward_to_atomic(oop p) {
- assert(ParNewGeneration::is_legal_forward_ptr(p),
- "illegal forwarding pointer value.");
- markOop oldMark = mark();
- markOop forwardPtrMark = markOopDesc::encode_pointer_as_mark(p);
- markOop curMark;
-
- assert(forwardPtrMark->decode_pointer() == p, "encoding must be reversable");
- assert(sizeof(markOop) == sizeof(intptr_t), "CAS below requires this.");
-
- while (!oldMark->is_marked()) {
- curMark = (markOop)Atomic::cmpxchg_ptr(forwardPtrMark, &_mark, oldMark);
- assert(is_forwarded(), "object should have been forwarded");
- if (curMark == oldMark) {
- return NULL;
- }
- // If the CAS was unsuccessful then curMark->is_marked()
- // should return true as another thread has CAS'd in another
- // forwarding pointer.
- oldMark = curMark;
- }
- return forwardee();
-}
-
#endif // SHARE_VM_OOPS_OOP_PCGC_INLINE_HPP
--- a/hotspot/src/share/vm/opto/graphKit.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/opto/graphKit.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -1518,7 +1518,6 @@
BarrierSet* bs = Universe::heap()->barrier_set();
set_control(ctl);
switch (bs->kind()) {
- case BarrierSet::G1SATBCT:
case BarrierSet::G1SATBCTLogging:
g1_write_barrier_pre(do_load, obj, adr, adr_idx, val, val_type, pre_val, bt);
break;
@@ -1537,7 +1536,6 @@
bool GraphKit::can_move_pre_barrier() const {
BarrierSet* bs = Universe::heap()->barrier_set();
switch (bs->kind()) {
- case BarrierSet::G1SATBCT:
case BarrierSet::G1SATBCTLogging:
return true; // Can move it if no safepoint
@@ -1563,7 +1561,6 @@
BarrierSet* bs = Universe::heap()->barrier_set();
set_control(ctl);
switch (bs->kind()) {
- case BarrierSet::G1SATBCT:
case BarrierSet::G1SATBCTLogging:
g1_write_barrier_post(store, obj, adr, adr_idx, val, bt, use_precise);
break;
--- a/hotspot/src/share/vm/precompiled/precompiled.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/precompiled/precompiled.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -135,8 +135,6 @@
# include "memory/resourceArea.hpp"
# include "memory/sharedHeap.hpp"
# include "memory/space.hpp"
-# include "memory/space.inline.hpp"
-# include "memory/specialized_oop_closures.hpp"
# include "memory/threadLocalAllocBuffer.hpp"
# include "memory/threadLocalAllocBuffer.inline.hpp"
# include "memory/universe.hpp"
@@ -310,7 +308,6 @@
# include "gc_implementation/g1/g1BlockOffsetTable.inline.hpp"
# include "gc_implementation/g1/g1OopClosures.hpp"
# include "gc_implementation/g1/g1_globals.hpp"
-# include "gc_implementation/g1/g1_specialized_oop_closures.hpp"
# include "gc_implementation/g1/ptrQueue.hpp"
# include "gc_implementation/g1/satbQueue.hpp"
# include "gc_implementation/parNew/parOopClosures.hpp"
--- a/hotspot/src/share/vm/prims/jvm.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/prims/jvm.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -402,7 +402,7 @@
PUTPROP(props, "sun.nio.MaxDirectMemorySize", "-1");
} else {
char as_chars[256];
- jio_snprintf(as_chars, sizeof(as_chars), UINTX_FORMAT, MaxDirectMemorySize);
+ jio_snprintf(as_chars, sizeof(as_chars), SIZE_FORMAT, MaxDirectMemorySize);
PUTPROP(props, "sun.nio.MaxDirectMemorySize", as_chars);
}
}
--- a/hotspot/src/share/vm/prims/whitebox.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/prims/whitebox.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -295,6 +295,12 @@
return hr->is_humongous();
WB_END
+WB_ENTRY(jlong, WB_G1NumMaxRegions(JNIEnv* env, jobject o))
+ G1CollectedHeap* g1 = G1CollectedHeap::heap();
+ size_t nr = g1->max_regions();
+ return (jlong)nr;
+WB_END
+
WB_ENTRY(jlong, WB_G1NumFreeRegions(JNIEnv* env, jobject o))
G1CollectedHeap* g1 = G1CollectedHeap::heap();
size_t nr = g1->num_free_regions();
@@ -318,6 +324,14 @@
WB_ENTRY(jint, WB_G1RegionSize(JNIEnv* env, jobject o))
return (jint)HeapRegion::GrainBytes;
WB_END
+
+WB_ENTRY(jobject, WB_G1AuxiliaryMemoryUsage(JNIEnv* env))
+ ResourceMark rm(THREAD);
+ G1CollectedHeap* g1h = G1CollectedHeap::heap();
+ MemoryUsage usage = g1h->get_auxiliary_data_memory_usage();
+ Handle h = MemoryService::create_MemoryUsage_obj(usage, CHECK_NULL);
+ return JNIHandles::make_local(env, h());
+WB_END
#endif // INCLUDE_ALL_GCS
#if INCLUDE_NMT
@@ -1305,9 +1319,12 @@
#if INCLUDE_ALL_GCS
{CC"g1InConcurrentMark", CC"()Z", (void*)&WB_G1InConcurrentMark},
{CC"g1IsHumongous", CC"(Ljava/lang/Object;)Z", (void*)&WB_G1IsHumongous },
+ {CC"g1NumMaxRegions", CC"()J", (void*)&WB_G1NumMaxRegions },
{CC"g1NumFreeRegions", CC"()J", (void*)&WB_G1NumFreeRegions },
{CC"g1RegionSize", CC"()I", (void*)&WB_G1RegionSize },
{CC"g1StartConcMarkCycle", CC"()Z", (void*)&WB_G1StartMarkCycle },
+ {CC"g1AuxiliaryMemoryUsage", CC"()Ljava/lang/management/MemoryUsage;",
+ (void*)&WB_G1AuxiliaryMemoryUsage },
#endif // INCLUDE_ALL_GCS
#if INCLUDE_NMT
{CC"NMTMalloc", CC"(J)J", (void*)&WB_NMTMalloc },
--- a/hotspot/src/share/vm/runtime/arguments.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/runtime/arguments.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -67,16 +67,16 @@
} \
} while(0)
-char** Arguments::_jvm_flags_array = NULL;
-int Arguments::_num_jvm_flags = 0;
-char** Arguments::_jvm_args_array = NULL;
-int Arguments::_num_jvm_args = 0;
+char** Arguments::_jvm_flags_array = NULL;
+int Arguments::_num_jvm_flags = 0;
+char** Arguments::_jvm_args_array = NULL;
+int Arguments::_num_jvm_args = 0;
char* Arguments::_java_command = NULL;
SystemProperty* Arguments::_system_properties = NULL;
const char* Arguments::_gc_log_filename = NULL;
bool Arguments::_has_profile = false;
size_t Arguments::_conservative_max_heap_alignment = 0;
-uintx Arguments::_min_heap_size = 0;
+size_t Arguments::_min_heap_size = 0;
uintx Arguments::_min_heap_free_ratio = 0;
uintx Arguments::_max_heap_free_ratio = 0;
Arguments::Mode Arguments::_mode = _mixed;
@@ -1343,9 +1343,9 @@
// NewSize was set on the command line and it is larger than
// preferred_max_new_size.
if (!FLAG_IS_DEFAULT(NewSize)) { // NewSize explicitly set at command-line
- FLAG_SET_ERGO(uintx, MaxNewSize, MAX2(NewSize, preferred_max_new_size));
+ FLAG_SET_ERGO(size_t, MaxNewSize, MAX2(NewSize, preferred_max_new_size));
} else {
- FLAG_SET_ERGO(uintx, MaxNewSize, preferred_max_new_size);
+ FLAG_SET_ERGO(size_t, MaxNewSize, preferred_max_new_size);
}
if (PrintGCDetails && Verbose) {
// Too early to use gclog_or_tty
@@ -1368,8 +1368,8 @@
// Unless explicitly requested otherwise, make young gen
// at least min_new, and at most preferred_max_new_size.
if (FLAG_IS_DEFAULT(NewSize)) {
- FLAG_SET_ERGO(uintx, NewSize, MAX2(NewSize, min_new));
- FLAG_SET_ERGO(uintx, NewSize, MIN2(preferred_max_new_size, NewSize));
+ FLAG_SET_ERGO(size_t, NewSize, MAX2(NewSize, min_new));
+ FLAG_SET_ERGO(size_t, NewSize, MIN2(preferred_max_new_size, NewSize));
if (PrintGCDetails && Verbose) {
// Too early to use gclog_or_tty
tty->print_cr("CMS ergo set NewSize: " SIZE_FORMAT, NewSize);
@@ -1379,7 +1379,7 @@
// so it's NewRatio x of NewSize.
if (FLAG_IS_DEFAULT(OldSize)) {
if (max_heap > NewSize) {
- FLAG_SET_ERGO(uintx, OldSize, MIN2(NewRatio*NewSize, max_heap - NewSize));
+ FLAG_SET_ERGO(size_t, OldSize, MIN2(NewRatio*NewSize, max_heap - NewSize));
if (PrintGCDetails && Verbose) {
// Too early to use gclog_or_tty
tty->print_cr("CMS ergo set OldSize: " SIZE_FORMAT, OldSize);
@@ -1410,7 +1410,7 @@
// OldPLAB sizing manually turned off: Use a larger default setting,
// unless it was manually specified. This is because a too-low value
// will slow down scavenges.
- FLAG_SET_ERGO(uintx, OldPLABSize, CFLS_LAB::_default_static_old_plab_size); // default value before 6631166
+ FLAG_SET_ERGO(size_t, OldPLABSize, CFLS_LAB::_default_static_old_plab_size); // default value before 6631166
} else {
FLAG_SET_DEFAULT(OldPLABSize, CFLS_LAB::_default_dynamic_old_plab_size); // old CMSParPromoteBlocksToClaim default
}
@@ -1612,7 +1612,7 @@
void Arguments::select_gc() {
if (!gc_selected()) {
- ArgumentsExt::select_gc_ergonomically();
+ select_gc_ergonomically();
}
}
@@ -1790,7 +1790,7 @@
}
// Use static initialization to get the default before parsing
-static const uintx DefaultHeapBaseMinAddress = HeapBaseMinAddress;
+static const size_t DefaultHeapBaseMinAddress = HeapBaseMinAddress;
void Arguments::set_heap_size() {
if (!FLAG_IS_DEFAULT(DefaultMaxRAMFraction)) {
@@ -1830,14 +1830,14 @@
// matches compressed oops printing flags
if (PrintCompressedOopsMode || (PrintMiscellaneous && Verbose)) {
jio_fprintf(defaultStream::error_stream(),
- "HeapBaseMinAddress must be at least " UINTX_FORMAT
- " (" UINTX_FORMAT "G) which is greater than value given "
- UINTX_FORMAT "\n",
+ "HeapBaseMinAddress must be at least " SIZE_FORMAT
+ " (" SIZE_FORMAT "G) which is greater than value given "
+ SIZE_FORMAT "\n",
DefaultHeapBaseMinAddress,
DefaultHeapBaseMinAddress/G,
HeapBaseMinAddress);
}
- FLAG_SET_ERGO(uintx, HeapBaseMinAddress, DefaultHeapBaseMinAddress);
+ FLAG_SET_ERGO(size_t, HeapBaseMinAddress, DefaultHeapBaseMinAddress);
}
}
@@ -1862,7 +1862,7 @@
// Cannot use gclog_or_tty yet.
tty->print_cr(" Maximum heap size " SIZE_FORMAT, (size_t) reasonable_max);
}
- FLAG_SET_ERGO(uintx, MaxHeapSize, (uintx)reasonable_max);
+ FLAG_SET_ERGO(size_t, MaxHeapSize, (size_t)reasonable_max);
}
// If the minimum or initial heap_size have not been set or requested to be set
@@ -1884,14 +1884,14 @@
if (PrintGCDetails && Verbose) {
// Cannot use gclog_or_tty yet.
- tty->print_cr(" Initial heap size " SIZE_FORMAT, (uintx)reasonable_initial);
+ tty->print_cr(" Initial heap size " SIZE_FORMAT, (size_t)reasonable_initial);
}
- FLAG_SET_ERGO(uintx, InitialHeapSize, (uintx)reasonable_initial);
+ FLAG_SET_ERGO(size_t, InitialHeapSize, (size_t)reasonable_initial);
}
// If the minimum heap size has not been set (via -Xms),
// synchronize with InitialHeapSize to avoid errors with the default value.
if (min_heap_size() == 0) {
- set_min_heap_size(MIN2((uintx)reasonable_minimum, InitialHeapSize));
+ set_min_heap_size(MIN2((size_t)reasonable_minimum, InitialHeapSize));
if (PrintGCDetails && Verbose) {
// Cannot use gclog_or_tty yet.
tty->print_cr(" Minimum heap size " SIZE_FORMAT, min_heap_size());
@@ -2037,7 +2037,7 @@
}
if (UseGCLogFileRotation && (GCLogFileSize != 0) && (GCLogFileSize < 8*K)) {
- FLAG_SET_CMDLINE(uintx, GCLogFileSize, 8*K);
+ FLAG_SET_CMDLINE(size_t, GCLogFileSize, 8*K);
jio_fprintf(defaultStream::output_stream(),
"GCLogFileSize changed to minimum 8K\n");
}
@@ -2121,7 +2121,7 @@
}
// Check consistency of GC selection
-bool Arguments::check_gc_consistency_user() {
+bool Arguments::check_gc_consistency() {
check_gclog_consistency();
// Ensure that the user has not selected conflicting sets
// of collectors.
@@ -2265,7 +2265,7 @@
FLAG_SET_DEFAULT(UseGCOverheadLimit, false);
}
- status = status && check_gc_consistency_user();
+ status = status && check_gc_consistency();
status = status && check_stack_pages();
status = status && verify_percentage(CMSIncrementalSafetyFactor,
@@ -2394,7 +2394,7 @@
status = status && verify_min_value(LogEventsBufferEntries, 1, "LogEventsBufferEntries");
- status = status && verify_min_value(HeapSizePerGCThread, (uintx) os::vm_page_size(), "HeapSizePerGCThread");
+ status = status && verify_min_value(HeapSizePerGCThread, (size_t) os::vm_page_size(), "HeapSizePerGCThread");
status = status && verify_min_value(GCTaskTimeStampEntries, 1, "GCTaskTimeStampEntries");
@@ -2809,8 +2809,8 @@
describe_range_error(errcode);
return JNI_EINVAL;
}
- FLAG_SET_CMDLINE(uintx, MaxNewSize, (uintx)long_initial_young_size);
- FLAG_SET_CMDLINE(uintx, NewSize, (uintx)long_initial_young_size);
+ FLAG_SET_CMDLINE(size_t, MaxNewSize, (size_t)long_initial_young_size);
+ FLAG_SET_CMDLINE(size_t, NewSize, (size_t)long_initial_young_size);
// -Xms
} else if (match_option(option, "-Xms", &tail)) {
julong long_initial_heap_size = 0;
@@ -2822,10 +2822,10 @@
describe_range_error(errcode);
return JNI_EINVAL;
}
- set_min_heap_size((uintx)long_initial_heap_size);
+ set_min_heap_size((size_t)long_initial_heap_size);
// Currently the minimum size and the initial heap sizes are the same.
// Can be overridden with -XX:InitialHeapSize.
- FLAG_SET_CMDLINE(uintx, InitialHeapSize, (uintx)long_initial_heap_size);
+ FLAG_SET_CMDLINE(size_t, InitialHeapSize, (size_t)long_initial_heap_size);
// -Xmx
} else if (match_option(option, "-Xmx", &tail) || match_option(option, "-XX:MaxHeapSize=", &tail)) {
julong long_max_heap_size = 0;
@@ -2836,7 +2836,7 @@
describe_range_error(errcode);
return JNI_EINVAL;
}
- FLAG_SET_CMDLINE(uintx, MaxHeapSize, (uintx)long_max_heap_size);
+ FLAG_SET_CMDLINE(size_t, MaxHeapSize, (size_t)long_max_heap_size);
// Xmaxf
} else if (match_option(option, "-Xmaxf", &tail)) {
char* err;
@@ -2977,7 +2977,7 @@
FLAG_SET_CMDLINE(bool, BackgroundCompilation, false);
FLAG_SET_CMDLINE(intx, DeferThrSuspendLoopCount, 1);
FLAG_SET_CMDLINE(bool, UseTLAB, false);
- FLAG_SET_CMDLINE(uintx, NewSizeThreadIncrease, 16 * K); // 20Kb per thread added to new generation
+ FLAG_SET_CMDLINE(size_t, NewSizeThreadIncrease, 16 * K); // 20Kb per thread added to new generation
// -Xinternalversion
} else if (match_option(option, "-Xinternalversion")) {
@@ -3138,16 +3138,16 @@
initHeapSize = limit_by_allocatable_memory(initHeapSize);
if (FLAG_IS_DEFAULT(MaxHeapSize)) {
- FLAG_SET_CMDLINE(uintx, MaxHeapSize, initHeapSize);
- FLAG_SET_CMDLINE(uintx, InitialHeapSize, initHeapSize);
+ FLAG_SET_CMDLINE(size_t, MaxHeapSize, initHeapSize);
+ FLAG_SET_CMDLINE(size_t, InitialHeapSize, initHeapSize);
// Currently the minimum size and the initial heap sizes are the same.
set_min_heap_size(initHeapSize);
}
if (FLAG_IS_DEFAULT(NewSize)) {
// Make the young generation 3/8ths of the total heap.
- FLAG_SET_CMDLINE(uintx, NewSize,
+ FLAG_SET_CMDLINE(size_t, NewSize,
((julong)MaxHeapSize / (julong)8) * (julong)3);
- FLAG_SET_CMDLINE(uintx, MaxNewSize, NewSize);
+ FLAG_SET_CMDLINE(size_t, MaxNewSize, NewSize);
}
#ifndef _ALLBSD_SOURCE // UseLargePages is not yet supported on BSD.
@@ -3155,14 +3155,14 @@
#endif
// Increase some data structure sizes for efficiency
- FLAG_SET_CMDLINE(uintx, BaseFootPrintEstimate, MaxHeapSize);
+ FLAG_SET_CMDLINE(size_t, BaseFootPrintEstimate, MaxHeapSize);
FLAG_SET_CMDLINE(bool, ResizeTLAB, false);
- FLAG_SET_CMDLINE(uintx, TLABSize, 256*K);
+ FLAG_SET_CMDLINE(size_t, TLABSize, 256*K);
// See the OldPLABSize comment below, but replace 'after promotion'
// with 'after copying'. YoungPLABSize is the size of the survivor
// space per-gc-thread buffers. The default is 4kw.
- FLAG_SET_CMDLINE(uintx, YoungPLABSize, 256*K); // Note: this is in words
+ FLAG_SET_CMDLINE(size_t, YoungPLABSize, 256*K); // Note: this is in words
// OldPLABSize is the size of the buffers in the old gen that
// UseParallelGC uses to promote live data that doesn't fit in the
@@ -3177,7 +3177,7 @@
// locality. A minor effect may be that larger PLABs reduce the
// number of PLAB allocation events during gc. The value of 8kw
// was arrived at by experimenting with specjbb.
- FLAG_SET_CMDLINE(uintx, OldPLABSize, 8*K); // Note: this is in words
+ FLAG_SET_CMDLINE(size_t, OldPLABSize, 8*K); // Note: this is in words
// Enable parallel GC and adaptive generation sizing
FLAG_SET_CMDLINE(bool, UseParallelGC, true);
@@ -3256,7 +3256,7 @@
jio_fprintf(defaultStream::error_stream(),
"Please use -XX:MarkStackSize in place of "
"-XX:CMSMarkStackSize or -XX:G1MarkStackSize in the future\n");
- FLAG_SET_CMDLINE(uintx, MarkStackSize, stack_size);
+ FLAG_SET_CMDLINE(size_t, MarkStackSize, stack_size);
} else if (match_option(option, "-XX:CMSMarkStackSizeMax=", &tail)) {
julong max_stack_size = 0;
ArgsRange errcode = parse_memory_size(tail, &max_stack_size, 1);
@@ -3270,7 +3270,7 @@
jio_fprintf(defaultStream::error_stream(),
"Please use -XX:MarkStackSizeMax in place of "
"-XX:CMSMarkStackSizeMax in the future\n");
- FLAG_SET_CMDLINE(uintx, MarkStackSizeMax, max_stack_size);
+ FLAG_SET_CMDLINE(size_t, MarkStackSizeMax, max_stack_size);
} else if (match_option(option, "-XX:ParallelMarkingThreads=", &tail) ||
match_option(option, "-XX:ParallelCMSThreads=", &tail)) {
uintx conc_threads = 0;
@@ -3293,7 +3293,7 @@
describe_range_error(errcode);
return JNI_EINVAL;
}
- FLAG_SET_CMDLINE(uintx, MaxDirectMemorySize, max_direct_memory_size);
+ FLAG_SET_CMDLINE(size_t, MaxDirectMemorySize, max_direct_memory_size);
#if !INCLUDE_MANAGEMENT
} else if (match_option(option, "-XX:+ManagementServer")) {
jio_fprintf(defaultStream::error_stream(),
@@ -3900,7 +3900,7 @@
set_shared_spaces_flags();
// Check the GC selections again.
- if (!ArgumentsExt::check_gc_consistency_ergo()) {
+ if (!check_gc_consistency()) {
return JNI_EINVAL;
}
--- a/hotspot/src/share/vm/runtime/arguments.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/runtime/arguments.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -477,8 +477,7 @@
static bool verify_MaxHeapFreeRatio(FormatBuffer<80>& err_msg, uintx max_heap_free_ratio);
// Check for consistency in the selection of the garbage collector.
- static bool check_gc_consistency_user(); // Check user-selected gc
- static inline bool check_gc_consistency_ergo(); // Check ergonomic-selected gc
+ static bool check_gc_consistency(); // Check user-selected gc
static void check_deprecated_gc_flags();
// Check consistency or otherwise of VM argument settings
static bool check_vm_args_consistency();
@@ -531,8 +530,8 @@
static bool has_profile() { return _has_profile; }
// -Xms
- static uintx min_heap_size() { return _min_heap_size; }
- static void set_min_heap_size(uintx v) { _min_heap_size = v; }
+ static size_t min_heap_size() { return _min_heap_size; }
+ static void set_min_heap_size(size_t v) { _min_heap_size = v; }
// Returns the original values of -XX:MinHeapFreeRatio and -XX:MaxHeapFreeRatio
static uintx min_heap_free_ratio() { return _min_heap_free_ratio; }
@@ -618,10 +617,6 @@
return UseConcMarkSweepGC || UseG1GC || UseParallelGC || UseParallelOldGC || UseSerialGC;
}
-bool Arguments::check_gc_consistency_ergo() {
- return check_gc_consistency_user();
-}
-
// Disable options not supported in this release, with a warning if they
// were explicitly requested on the command-line
#define UNSUPPORTED_OPTION(opt, description) \
--- a/hotspot/src/share/vm/runtime/arguments_ext.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/runtime/arguments_ext.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -30,9 +30,7 @@
class ArgumentsExt: AllStatic {
public:
- static inline void select_gc_ergonomically();
static inline void set_gc_specific_flags();
- static inline bool check_gc_consistency_ergo();
// The argument processing extension. Returns true if there is
// no additional parsing needed in Arguments::parse() for the option.
// Otherwise returns false.
@@ -40,16 +38,8 @@
static inline void report_unsupported_options() { }
};
-void ArgumentsExt::select_gc_ergonomically() {
- Arguments::select_gc_ergonomically();
-}
-
void ArgumentsExt::set_gc_specific_flags() {
Arguments::set_gc_specific_flags();
}
-bool ArgumentsExt::check_gc_consistency_ergo() {
- return Arguments::check_gc_consistency_ergo();
-}
-
#endif // SHARE_VM_RUNTIME_ARGUMENTS_EXT_HPP
--- a/hotspot/src/share/vm/runtime/globals.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/runtime/globals.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -193,19 +193,19 @@
define_pd_global(intx, OnStackReplacePercentage, 0);
define_pd_global(bool, ResizeTLAB, false);
define_pd_global(intx, FreqInlineSize, 0);
-define_pd_global(intx, NewSizeThreadIncrease, 4*K);
+define_pd_global(size_t, NewSizeThreadIncrease, 4*K);
define_pd_global(intx, InlineClassNatives, true);
define_pd_global(intx, InlineUnsafeOps, true);
define_pd_global(intx, InitialCodeCacheSize, 160*K);
define_pd_global(intx, ReservedCodeCacheSize, 32*M);
define_pd_global(intx, NonProfiledCodeHeapSize, 0);
define_pd_global(intx, ProfiledCodeHeapSize, 0);
-define_pd_global(intx, NonNMethodCodeHeapSize, 32*M);
+define_pd_global(intx, NonNMethodCodeHeapSize, 32*M);
define_pd_global(intx, CodeCacheExpansionSize, 32*K);
define_pd_global(intx, CodeCacheMinBlockLength, 1);
define_pd_global(intx, CodeCacheMinimumUseSpace, 200*K);
-define_pd_global(uintx,MetaspaceSize, ScaleForWordSize(4*M));
+define_pd_global(size_t, MetaspaceSize, ScaleForWordSize(4*M));
define_pd_global(bool, NeverActAsServerClassMachine, true);
define_pd_global(uint64_t,MaxRAM, 1ULL*G);
#define CI_COMPILER_COUNT 0
@@ -468,7 +468,7 @@
// notproduct flags are settable / visible only during development and are not declared in the PRODUCT version
// A flag must be declared with one of the following types:
-// bool, intx, uintx, ccstr, double, or uint64_t.
+// bool, intx, uintx, size_t, ccstr, double, or uint64_t.
// The type "ccstr" is an alias for "const char*" and is used
// only in this file, because the macrology requires single-token type names.
@@ -540,7 +540,7 @@
notproduct(bool, CheckCompressedOops, true, \
"Generate checks in encoding/decoding code in debug VM") \
\
- product_pd(uintx, HeapBaseMinAddress, \
+ product_pd(size_t, HeapBaseMinAddress, \
"OS specific low limit for heap base address") \
\
product(uintx, HeapSearchSteps, 3 PPC64_ONLY(+17), \
@@ -606,7 +606,7 @@
product(bool, UseNUMAInterleaving, false, \
"Interleave memory across NUMA nodes if available") \
\
- product(uintx, NUMAInterleaveGranularity, 2*M, \
+ product(size_t, NUMAInterleaveGranularity, 2*M, \
"Granularity to use for NUMA interleaving on Windows OS") \
\
product(bool, ForceNUMA, false, \
@@ -617,7 +617,7 @@
"computing exponentially decaying average for " \
"AdaptiveNUMAChunkSizing") \
\
- product(uintx, NUMASpaceResizeRate, 1*G, \
+ product(size_t, NUMASpaceResizeRate, 1*G, \
"Do not reallocate more than this amount per collection") \
\
product(bool, UseAdaptiveNUMAChunkSizing, true, \
@@ -641,10 +641,10 @@
product(bool, UseSHA, false, \
"Control whether SHA instructions can be used on SPARC") \
\
- product(uintx, LargePageSizeInBytes, 0, \
+ product(size_t, LargePageSizeInBytes, 0, \
"Large page size (0 to let VM choose the page size)") \
\
- product(uintx, LargePageHeapSizeThreshold, 128*M, \
+ product(size_t, LargePageHeapSizeThreshold, 128*M, \
"Use large pages if maximum heap is at least this big") \
\
product(bool, ForceTimeHighResolution, false, \
@@ -966,11 +966,11 @@
"directory) of the dump file (defaults to java_pid<pid>.hprof " \
"in the working directory)") \
\
- develop(uintx, SegmentedHeapDumpThreshold, 2*G, \
+ develop(size_t, SegmentedHeapDumpThreshold, 2*G, \
"Generate a segmented heap dump (JAVA PROFILE 1.0.2 format) " \
"when the heap usage is larger than this") \
\
- develop(uintx, HeapDumpSegmentSize, 1*G, \
+ develop(size_t, HeapDumpSegmentSize, 1*G, \
"Approximate segment size when generating a segmented heap dump") \
\
develop(bool, BreakAtWarning, false, \
@@ -1468,7 +1468,7 @@
"Force dynamic selection of the number of " \
"parallel threads parallel gc will use to aid debugging") \
\
- product(uintx, HeapSizePerGCThread, ScaleForWordSize(64*M), \
+ product(size_t, HeapSizePerGCThread, ScaleForWordSize(64*M), \
"Size of heap (bytes) per GC thread used in calculating the " \
"number of GC threads") \
\
@@ -1485,10 +1485,10 @@
product(uintx, ConcGCThreads, 0, \
"Number of threads concurrent gc will use") \
\
- product(uintx, YoungPLABSize, 4096, \
+ product(size_t, YoungPLABSize, 4096, \
"Size of young gen promotion LAB's (in HeapWords)") \
\
- product(uintx, OldPLABSize, 1024, \
+ product(size_t, OldPLABSize, 1024, \
"Size of old gen promotion LAB's (in HeapWords), or Number \
of blocks to attempt to claim when refilling CMS LAB's") \
\
@@ -1607,11 +1607,11 @@
product(bool, PrintOldPLAB, false, \
"Print (old gen) promotion LAB's sizing decisions") \
\
- product(uintx, CMSOldPLABMin, 16, \
+ product(size_t, CMSOldPLABMin, 16, \
"Minimum size of CMS gen promotion LAB caches per worker " \
"per block size") \
\
- product(uintx, CMSOldPLABMax, 1024, \
+ product(size_t, CMSOldPLABMax, 1024, \
"Maximum size of CMS gen promotion LAB caches per worker " \
"per block size") \
\
@@ -1634,7 +1634,7 @@
product(bool, AlwaysPreTouch, false, \
"Force all freshly committed pages to be pre-touched") \
\
- product_pd(uintx, CMSYoungGenPerWorker, \
+ product_pd(size_t, CMSYoungGenPerWorker, \
"The maximum size of young gen chosen by default per GC worker " \
"thread available") \
\
@@ -1726,10 +1726,10 @@
develop(bool, CMSOverflowEarlyRestoration, false, \
"Restore preserved marks early") \
\
- product(uintx, MarkStackSize, NOT_LP64(32*K) LP64_ONLY(4*M), \
+ product(size_t, MarkStackSize, NOT_LP64(32*K) LP64_ONLY(4*M), \
"Size of marking stack") \
\
- product(uintx, MarkStackSizeMax, NOT_LP64(4*M) LP64_ONLY(512*M), \
+ product(size_t, MarkStackSizeMax, NOT_LP64(4*M) LP64_ONLY(512*M), \
"Maximum size of marking stack") \
\
notproduct(bool, CMSMarkStackOverflowALot, false, \
@@ -1752,10 +1752,10 @@
"Time that we sleep between iterations when not given " \
"enough work per iteration") \
\
- product(uintx, CMSRescanMultiple, 32, \
+ product(size_t, CMSRescanMultiple, 32, \
"Size (in cards) of CMS parallel rescan task") \
\
- product(uintx, CMSConcMarkMultiple, 32, \
+ product(size_t, CMSConcMarkMultiple, 32, \
"Size (in cards) of CMS concurrent MT marking task") \
\
product(bool, CMSAbortSemantics, false, \
@@ -1822,7 +1822,7 @@
product(uintx, CMSRemarkVerifyVariant, 1, \
"Choose variant (1,2) of verification following remark") \
\
- product(uintx, CMSScheduleRemarkEdenSizeThreshold, 2*M, \
+ product(size_t, CMSScheduleRemarkEdenSizeThreshold, 2*M, \
"If Eden size is below this, do not try to schedule remark") \
\
product(uintx, CMSScheduleRemarkEdenPenetration, 50, \
@@ -1856,7 +1856,7 @@
product(bool, CMSYield, true, \
"Yield between steps of CMS") \
\
- product(uintx, CMSBitMapYieldQuantum, 10*M, \
+ product(size_t, CMSBitMapYieldQuantum, 10*M, \
"Bitmap operations should process at most this many bits " \
"between yields") \
\
@@ -2036,7 +2036,7 @@
product_pd(uint64_t, MaxRAM, \
"Real memory size (in bytes) used to set maximum heap size") \
\
- product(uintx, ErgoHeapSizeLimit, 0, \
+ product(size_t, ErgoHeapSizeLimit, 0, \
"Maximum ergonomically set heap size (in bytes); zero means use " \
"MaxRAM / MaxRAMFraction") \
\
@@ -2179,7 +2179,7 @@
product(uintx, InitialSurvivorRatio, 8, \
"Initial ratio of young generation/survivor space size") \
\
- product(uintx, BaseFootPrintEstimate, 256*M, \
+ product(size_t, BaseFootPrintEstimate, 256*M, \
"Estimate of footprint other than Java Heap") \
\
product(bool, UseGCOverheadLimit, true, \
@@ -2330,7 +2330,7 @@
develop(bool, TraceClassLoaderData, false, \
"Trace class loader loader_data lifetime") \
\
- product(uintx, InitialBootClassLoaderMetaspaceSize, \
+ product(size_t, InitialBootClassLoaderMetaspaceSize, \
NOT_LP64(2200*K) LP64_ONLY(4*M), \
"Initial size of the boot class loader data metaspace") \
\
@@ -2420,7 +2420,7 @@
"Number of gclog files in rotation " \
"(default: 0, no rotation)") \
\
- product(uintx, GCLogFileSize, 8*K, \
+ product(size_t, GCLogFileSize, 8*K, \
"GC log file size, requires UseGCLogFileRotation. " \
"Set to 0 to only trigger rotation via jcmd") \
\
@@ -2958,11 +2958,11 @@
notproduct(ccstrlist, SuppressErrorAt, "", \
"List of assertions (file:line) to muzzle") \
\
- notproduct(uintx, HandleAllocationLimit, 1024, \
+ notproduct(size_t, HandleAllocationLimit, 1024, \
"Threshold for HandleMark allocation when +TraceHandleAllocation "\
"is used") \
\
- develop(uintx, TotalHandleAllocationLimit, 1024, \
+ develop(size_t, TotalHandleAllocationLimit, 1024, \
"Threshold for total handle allocation when " \
"+TraceHandleAllocation is used") \
\
@@ -3106,30 +3106,30 @@
"Number of times to spin wait before inflation") \
\
/* gc parameters */ \
- product(uintx, InitialHeapSize, 0, \
+ product(size_t, InitialHeapSize, 0, \
"Initial heap size (in bytes); zero means use ergonomics") \
\
- product(uintx, MaxHeapSize, ScaleForWordSize(96*M), \
+ product(size_t, MaxHeapSize, ScaleForWordSize(96*M), \
"Maximum heap size (in bytes)") \
\
- product(uintx, OldSize, ScaleForWordSize(4*M), \
+ product(size_t, OldSize, ScaleForWordSize(4*M), \
"Initial tenured generation size (in bytes)") \
\
- product(uintx, NewSize, ScaleForWordSize(1*M), \
+ product(size_t, NewSize, ScaleForWordSize(1*M), \
"Initial new generation size (in bytes)") \
\
- product(uintx, MaxNewSize, max_uintx, \
+ product(size_t, MaxNewSize, max_uintx, \
"Maximum new generation size (in bytes), max_uintx means set " \
"ergonomically") \
\
- product(uintx, PretenureSizeThreshold, 0, \
+ product(size_t, PretenureSizeThreshold, 0, \
"Maximum size in bytes of objects allocated in DefNew " \
"generation; zero means no maximum") \
\
- product(uintx, TLABSize, 0, \
+ product(size_t, TLABSize, 0, \
"Starting TLAB size (in bytes); zero means set ergonomically") \
\
- product(uintx, MinTLABSize, 2*K, \
+ product(size_t, MinTLABSize, 2*K, \
"Minimum allowed TLAB size (in bytes)") \
\
product(uintx, TLABAllocationWeight, 35, \
@@ -3150,17 +3150,17 @@
product(uintx, NewRatio, 2, \
"Ratio of old/new generation sizes") \
\
- product_pd(uintx, NewSizeThreadIncrease, \
+ product_pd(size_t, NewSizeThreadIncrease, \
"Additional size added to desired new generation size per " \
"non-daemon thread (in bytes)") \
\
- product_pd(uintx, MetaspaceSize, \
+ product_pd(size_t, MetaspaceSize, \
"Initial size of Metaspaces (in bytes)") \
\
- product(uintx, MaxMetaspaceSize, max_uintx, \
+ product(size_t, MaxMetaspaceSize, max_uintx, \
"Maximum size of Metaspaces (in bytes)") \
\
- product(uintx, CompressedClassSpaceSize, 1*G, \
+ product(size_t, CompressedClassSpaceSize, 1*G, \
"Maximum size of class area in Metaspace when compressed " \
"class pointers are used") \
\
@@ -3177,10 +3177,10 @@
product(intx, SoftRefLRUPolicyMSPerMB, 1000, \
"Number of milliseconds per MB of free space in the heap") \
\
- product(uintx, MinHeapDeltaBytes, ScaleForWordSize(128*K), \
+ product(size_t, MinHeapDeltaBytes, ScaleForWordSize(128*K), \
"The minimum change in heap space due to GC (in bytes)") \
\
- product(uintx, MinMetaspaceExpansion, ScaleForWordSize(256*K), \
+ product(size_t, MinMetaspaceExpansion, ScaleForWordSize(256*K), \
"The minimum expansion of Metaspace (in bytes)") \
\
product(uintx, MinMetaspaceFreeRatio, 40, \
@@ -3191,7 +3191,7 @@
"The maximum percentage of Metaspace free after GC to avoid " \
"shrinking") \
\
- product(uintx, MaxMetaspaceExpansion, ScaleForWordSize(4*M), \
+ product(size_t, MaxMetaspaceExpansion, ScaleForWordSize(4*M), \
"The maximum expansion of Metaspace without full GC (in bytes)") \
\
product(uintx, QueuedAllocationWarningCount, 0, \
@@ -3282,10 +3282,10 @@
product_pd(intx, CompilerThreadStackSize, \
"Compiler Thread Stack Size (in Kbytes)") \
\
- develop_pd(uintx, JVMInvokeMethodSlack, \
+ develop_pd(size_t, JVMInvokeMethodSlack, \
"Stack space (bytes) required for JVM_InvokeMethod to complete") \
\
- product(uintx, ThreadSafetyMargin, 50*M, \
+ product(size_t, ThreadSafetyMargin, 50*M, \
"Thread safety margin is used on fixed-stack LinuxThreads (on " \
"Linux/x86 only) to prevent heap-stack collision. Set to 0 to " \
"disable this feature") \
@@ -3673,7 +3673,7 @@
\
/* Properties for Java libraries */ \
\
- product(uintx, MaxDirectMemorySize, 0, \
+ product(size_t, MaxDirectMemorySize, 0, \
"Maximum total size of NIO direct-buffer allocations") \
\
/* Flags used for temporary code during development */ \
@@ -3777,10 +3777,10 @@
"If PrintSharedArchiveAndExit is true, also print the shared " \
"dictionary") \
\
- product(uintx, SharedReadWriteSize, NOT_LP64(12*M) LP64_ONLY(16*M), \
+ product(size_t, SharedReadWriteSize, NOT_LP64(12*M) LP64_ONLY(16*M), \
"Size of read-write space for metadata (in bytes)") \
\
- product(uintx, SharedReadOnlySize, NOT_LP64(12*M) LP64_ONLY(16*M), \
+ product(size_t, SharedReadOnlySize, NOT_LP64(12*M) LP64_ONLY(16*M), \
"Size of read-only space for metadata (in bytes)") \
\
product(uintx, SharedMiscDataSize, NOT_LP64(2*M) LP64_ONLY(4*M), \
--- a/hotspot/src/share/vm/runtime/handles.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/runtime/handles.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -83,7 +83,7 @@
}
// The thread local handle areas should not get very large
- if (TraceHandleAllocation && handles_visited > TotalHandleAllocationLimit) {
+ if (TraceHandleAllocation && (size_t)handles_visited > TotalHandleAllocationLimit) {
#ifdef ASSERT
warning("%d: Visited in HandleMark : %d",
_nof_handlemarks, handles_visited);
--- a/hotspot/src/share/vm/runtime/thread.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/runtime/thread.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -87,8 +87,9 @@
#include "utilities/defaultStream.hpp"
#include "utilities/dtrace.hpp"
#include "utilities/events.hpp"
+#include "utilities/macros.hpp"
#include "utilities/preserveException.hpp"
-#include "utilities/macros.hpp"
+#include "utilities/workgroup.hpp"
#if INCLUDE_ALL_GCS
#include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp"
#include "gc_implementation/g1/concurrentMarkThread.inline.hpp"
@@ -3182,6 +3183,7 @@
int Threads::_number_of_threads = 0;
int Threads::_number_of_non_daemon_threads = 0;
int Threads::_return_code = 0;
+int Threads::_thread_claim_parity = 0;
size_t JavaThread::_stack_size_at_create = 0;
#ifdef ASSERT
bool Threads::_vm_complete = false;
@@ -3216,7 +3218,6 @@
// If CompilerThreads ever become non-JavaThreads, add them here
}
-
void Threads::initialize_java_lang_classes(JavaThread* main_thread, TRAPS) {
TraceTime timer("Initialize java.lang classes", TraceStartupTime);
@@ -4045,6 +4046,26 @@
VMThread::vm_thread()->oops_do(f, cld_f, cf);
}
+void Threads::change_thread_claim_parity() {
+ // Set the new claim parity.
+ assert(_thread_claim_parity >= 0 && _thread_claim_parity <= 2,
+ "Not in range.");
+ _thread_claim_parity++;
+ if (_thread_claim_parity == 3) _thread_claim_parity = 1;
+ assert(_thread_claim_parity >= 1 && _thread_claim_parity <= 2,
+ "Not in range.");
+}
+
+#ifndef PRODUCT
+void Threads::assert_all_threads_claimed() {
+ ALL_JAVA_THREADS(p) {
+ const int thread_parity = p->oops_do_parity();
+ assert((thread_parity == _thread_claim_parity),
+ err_msg("Thread " PTR_FORMAT " has incorrect parity %d != %d", p2i(p), thread_parity, _thread_claim_parity));
+ }
+}
+#endif // PRODUCT
+
void Threads::possibly_parallel_oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) {
// Introduce a mechanism allowing parallel threads to claim threads as
// root groups. Overhead should be small enough to use all the time,
@@ -4059,7 +4080,7 @@
assert(!is_par ||
(SharedHeap::heap()->n_par_threads() ==
SharedHeap::heap()->workers()->active_workers()), "Mismatch");
- int cp = SharedHeap::heap()->strong_roots_parity();
+ int cp = Threads::thread_claim_parity();
ALL_JAVA_THREADS(p) {
if (p->claim_oops_do(is_par, cp)) {
p->oops_do(f, cld_f, cf);
--- a/hotspot/src/share/vm/runtime/thread.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/runtime/thread.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -551,6 +551,7 @@
Monitor* owned_locks() const { return _owned_locks; }
bool owns_locks() const { return owned_locks() != NULL; }
bool owns_locks_but_compiled_lock() const;
+ int oops_do_parity() const { return _oops_do_parity; }
// Deadlock detection
bool allow_allocation() { return _allow_allocation_count == 0; }
@@ -1855,6 +1856,7 @@
static int _number_of_threads;
static int _number_of_non_daemon_threads;
static int _return_code;
+ static int _thread_claim_parity;
#ifdef ASSERT
static bool _vm_complete;
#endif
@@ -1884,9 +1886,10 @@
// Does not include JNI_VERSION_1_1
static jboolean is_supported_jni_version(jint version);
- // Garbage collection
- static void follow_other_roots(void f(oop*));
+ static int thread_claim_parity() { return _thread_claim_parity; }
+ static void change_thread_claim_parity();
+ static void assert_all_threads_claimed() PRODUCT_RETURN;
// Apply "f->do_oop" to all root oops in all threads.
// This version may only be called by sequential code.
static void oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf);
--- a/hotspot/src/share/vm/runtime/vmStructs.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/runtime/vmStructs.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -527,16 +527,16 @@
nonstatic_field(CollectedHeap, _defer_initial_card_mark, bool) \
nonstatic_field(CollectedHeap, _is_gc_active, bool) \
nonstatic_field(CollectedHeap, _total_collections, unsigned int) \
+ \
nonstatic_field(CompactibleSpace, _compaction_top, HeapWord*) \
nonstatic_field(CompactibleSpace, _first_dead, HeapWord*) \
nonstatic_field(CompactibleSpace, _end_of_live, HeapWord*) \
\
- \
nonstatic_field(ContiguousSpace, _top, HeapWord*) \
nonstatic_field(ContiguousSpace, _concurrent_iteration_safe_limit, HeapWord*) \
nonstatic_field(ContiguousSpace, _saved_mark_word, HeapWord*) \
\
- nonstatic_field(DefNewGeneration, _next_gen, Generation*) \
+ nonstatic_field(DefNewGeneration, _old_gen, Generation*) \
nonstatic_field(DefNewGeneration, _tenuring_threshold, uint) \
nonstatic_field(DefNewGeneration, _age_table, ageTable) \
nonstatic_field(DefNewGeneration, _eden_space, ContiguousSpace*) \
@@ -559,7 +559,9 @@
nonstatic_field(GenCollectedHeap, _young_gen, Generation*) \
nonstatic_field(GenCollectedHeap, _old_gen, Generation*) \
nonstatic_field(GenCollectedHeap, _n_gens, int) \
- nonstatic_field(GenCollectedHeap, _gen_specs, GenerationSpec**) \
+ \
+ nonstatic_field(GenCollectorPolicy, _young_gen_spec, GenerationSpec*) \
+ nonstatic_field(GenCollectorPolicy, _old_gen_spec, GenerationSpec*) \
\
nonstatic_field(HeapWord, i, char*) \
\
@@ -1505,6 +1507,7 @@
declare_type(DefNewGeneration, Generation) \
declare_type(CardGeneration, Generation) \
declare_type(TenuredGeneration, CardGeneration) \
+ declare_toplevel_type(GenCollectorPolicy) \
declare_toplevel_type(Space) \
declare_toplevel_type(BitMap) \
declare_type(CompactibleSpace, Space) \
@@ -2250,9 +2253,9 @@
\
declare_constant(CardTableRS::youngergen_card) \
\
- declare_constant(CollectedHeap::Abstract) \
- declare_constant(CollectedHeap::SharedHeap) \
declare_constant(CollectedHeap::GenCollectedHeap) \
+ declare_constant(CollectedHeap::ParallelScavengeHeap) \
+ declare_constant(CollectedHeap::G1CollectedHeap) \
\
declare_constant(GenCollectedHeap::max_gens) \
\
--- a/hotspot/src/share/vm/services/heapDumper.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/services/heapDumper.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -1721,7 +1721,7 @@
// Write the file header - use 1.0.2 for large heaps, otherwise 1.0.1
size_t used = ch->used();
const char* header;
- if (used > (size_t)SegmentedHeapDumpThreshold) {
+ if (used > SegmentedHeapDumpThreshold) {
set_segmented_dump();
header = "JAVA PROFILE 1.0.2";
} else {
--- a/hotspot/src/share/vm/services/lowMemoryDetector.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/services/lowMemoryDetector.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -28,6 +28,7 @@
#include "memory/allocation.hpp"
#include "services/memoryPool.hpp"
#include "services/memoryService.hpp"
+#include "services/memoryUsage.hpp"
// Low Memory Detection Support
// Two memory alarms in the JDK (we called them sensors).
--- a/hotspot/src/share/vm/services/memoryPool.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/services/memoryPool.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -25,7 +25,9 @@
#include "precompiled.hpp"
#include "classfile/systemDictionary.hpp"
#include "classfile/vmSymbols.hpp"
+#include "memory/defNewGeneration.hpp"
#include "memory/metaspace.hpp"
+#include "memory/space.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/javaCalls.hpp"
@@ -34,8 +36,11 @@
#include "services/management.hpp"
#include "services/memoryManager.hpp"
#include "services/memoryPool.hpp"
+#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp"
-#include "utilities/globalDefinitions.hpp"
+#if INCLUDE_ALL_GCS
+#include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp"
+#endif
MemoryPool::MemoryPool(const char* name,
PoolType type,
@@ -187,6 +192,10 @@
support_usage_threshold), _space(space) {
}
+size_t ContiguousSpacePool::used_in_bytes() {
+ return space()->used();
+}
+
MemoryUsage ContiguousSpacePool::get_memory_usage() {
size_t maxSize = (available_for_allocation() ? max_size() : 0);
size_t used = used_in_bytes();
@@ -204,6 +213,14 @@
support_usage_threshold), _gen(gen) {
}
+size_t SurvivorContiguousSpacePool::used_in_bytes() {
+ return _gen->from()->used();
+}
+
+size_t SurvivorContiguousSpacePool::committed_in_bytes() {
+ return _gen->from()->capacity();
+}
+
MemoryUsage SurvivorContiguousSpacePool::get_memory_usage() {
size_t maxSize = (available_for_allocation() ? max_size() : 0);
size_t used = used_in_bytes();
@@ -222,6 +239,10 @@
support_usage_threshold), _space(space) {
}
+size_t CompactibleFreeListSpacePool::used_in_bytes() {
+ return _space->used();
+}
+
MemoryUsage CompactibleFreeListSpacePool::get_memory_usage() {
size_t maxSize = (available_for_allocation() ? max_size() : 0);
size_t used = used_in_bytes();
@@ -239,6 +260,10 @@
support_usage_threshold), _gen(gen) {
}
+size_t GenerationPool::used_in_bytes() {
+ return _gen->used();
+}
+
MemoryUsage GenerationPool::get_memory_usage() {
size_t used = used_in_bytes();
size_t committed = _gen->capacity();
--- a/hotspot/src/share/vm/services/memoryPool.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/services/memoryPool.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -25,15 +25,9 @@
#ifndef SHARE_VM_SERVICES_MEMORYPOOL_HPP
#define SHARE_VM_SERVICES_MEMORYPOOL_HPP
-#include "gc_implementation/shared/mutableSpace.hpp"
-#include "memory/defNewGeneration.hpp"
#include "memory/heap.hpp"
-#include "memory/space.hpp"
#include "services/memoryUsage.hpp"
#include "utilities/macros.hpp"
-#if INCLUDE_ALL_GCS
-#include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp"
-#endif // INCLUDE_ALL_GCS
// A memory pool represents the memory area that the VM manages.
// The Java virtual machine has at least one memory pool
@@ -43,6 +37,8 @@
// both heap and non-heap memory.
// Forward declaration
+class CompactibleFreeListSpace;
+class ContiguousSpace;
class MemoryManager;
class SensorInfo;
class Generation;
@@ -162,7 +158,7 @@
ContiguousSpace* space() { return _space; }
MemoryUsage get_memory_usage();
- size_t used_in_bytes() { return space()->used(); }
+ size_t used_in_bytes();
};
class SurvivorContiguousSpacePool : public CollectedMemoryPool {
@@ -178,12 +174,8 @@
MemoryUsage get_memory_usage();
- size_t used_in_bytes() {
- return _gen->from()->used();
- }
- size_t committed_in_bytes() {
- return _gen->from()->capacity();
- }
+ size_t used_in_bytes();
+ size_t committed_in_bytes();
};
#if INCLUDE_ALL_GCS
@@ -198,7 +190,7 @@
bool support_usage_threshold);
MemoryUsage get_memory_usage();
- size_t used_in_bytes() { return _space->used(); }
+ size_t used_in_bytes();
};
#endif // INCLUDE_ALL_GCS
@@ -210,7 +202,7 @@
GenerationPool(Generation* gen, const char* name, PoolType type, bool support_usage_threshold);
MemoryUsage get_memory_usage();
- size_t used_in_bytes() { return _gen->used(); }
+ size_t used_in_bytes();
};
class CodeHeapPool: public MemoryPool {
--- a/hotspot/src/share/vm/services/memoryService.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/services/memoryService.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -130,8 +130,7 @@
GenCollectorPolicy* gen_policy = policy->as_generation_policy();
if (gen_policy != NULL) {
- GenerationSpec** specs = gen_policy->generations();
- Generation::Name kind = specs[0]->name();
+ Generation::Name kind = gen_policy->young_gen_spec()->name();
switch (kind) {
case Generation::DefNew:
_minor_gc_manager = MemoryManager::get_copy_memory_manager();
@@ -160,8 +159,8 @@
_managers_list->append(_minor_gc_manager);
_managers_list->append(_major_gc_manager);
- add_generation_memory_pool(heap->get_gen(minor), _major_gc_manager, _minor_gc_manager);
- add_generation_memory_pool(heap->get_gen(major), _major_gc_manager);
+ add_generation_memory_pool(heap->young_gen(), _major_gc_manager, _minor_gc_manager);
+ add_generation_memory_pool(heap->old_gen(), _major_gc_manager);
}
#if INCLUDE_ALL_GCS
--- a/hotspot/src/share/vm/services/memoryService.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/services/memoryService.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -57,13 +57,6 @@
init_code_heap_pools_size = 9
};
- // index for minor and major generations
- enum {
- minor = 0,
- major = 1,
- n_gens = 2
- };
-
static GrowableArray<MemoryPool*>* _pools_list;
static GrowableArray<MemoryManager*>* _managers_list;
--- a/hotspot/src/share/vm/utilities/debug.cpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/utilities/debug.cpp Tue Apr 14 12:10:00 2015 -0700
@@ -273,7 +273,7 @@
}
void report_insufficient_metaspace(size_t required_size) {
- warning("\nThe MaxMetaspaceSize of " UINTX_FORMAT " bytes is not large enough.\n"
+ warning("\nThe MaxMetaspaceSize of " SIZE_FORMAT " bytes is not large enough.\n"
"Either don't specify the -XX:MaxMetaspaceSize=<size>\n"
"or increase the size to at least " SIZE_FORMAT ".\n",
MaxMetaspaceSize, required_size);
--- a/hotspot/src/share/vm/utilities/debug.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/utilities/debug.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -222,9 +222,8 @@
template<bool x> struct STATIC_ASSERT_FAILURE;
template<> struct STATIC_ASSERT_FAILURE<true> { enum { value = 1 }; };
-#define STATIC_ASSERT(Cond) \
- typedef char STATIC_ASSERT_FAILURE_ ## __LINE__ [ \
- STATIC_ASSERT_FAILURE< (Cond) >::value ]
+#define STATIC_ASSERT(Cond) \
+ typedef char STATIC_ASSERT_DUMMY_TYPE[ STATIC_ASSERT_FAILURE< (Cond) >::value ]
// out of shared space reporting
enum SharedSpaceType {
--- a/hotspot/src/share/vm/utilities/ostream.hpp Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/src/share/vm/utilities/ostream.hpp Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -250,7 +250,7 @@
/* If "force" sets true, force log file rotation from outside JVM */
bool should_rotate(bool force) {
return force ||
- ((GCLogFileSize != 0) && ((uintx)_bytes_written >= GCLogFileSize));
+ ((GCLogFileSize != 0) && (_bytes_written >= (jlong)GCLogFileSize));
}
};
--- a/hotspot/test/TEST.ROOT Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/TEST.ROOT Tue Apr 14 12:10:00 2015 -0700
@@ -32,5 +32,5 @@
groups=TEST.groups [closed/TEST.groups]
requires.properties=sun.arch.data.model
-# Tests using jtreg 4.1 b10 features
-requiredVersion=4.1 b10
+# Tests using jtreg 4.1 b11 features
+requiredVersion=4.1 b11
--- a/hotspot/test/compiler/arguments/CheckCompileThresholdScaling.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/arguments/CheckCompileThresholdScaling.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @bug 8059604
* @summary "Add CompileThresholdScaling flag to control when methods are first compiled (with +/-TieredCompilation)"
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main CheckCompileThresholdScaling
*/
--- a/hotspot/test/compiler/arguments/TestUseBMI1InstructionsOnSupportedCPU.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/arguments/TestUseBMI1InstructionsOnSupportedCPU.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @summary Verify processing of UseBMI1Instructions option on CPU with
* BMI1 feature support.
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build TestUseBMI1InstructionsOnSupportedCPU
* BMISupportedCPUTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/compiler/arguments/TestUseBMI1InstructionsOnUnsupportedCPU.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/arguments/TestUseBMI1InstructionsOnUnsupportedCPU.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @summary Verify processing of UseBMI1Instructions option on CPU without
* BMI1 feature support.
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build TestUseBMI1InstructionsOnUnsupportedCPU
* BMIUnsupportedCPUTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/compiler/arguments/TestUseCountLeadingZerosInstructionOnSupportedCPU.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/arguments/TestUseCountLeadingZerosInstructionOnSupportedCPU.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @summary Verify processing of UseCountLeadingZerosInstruction option
* on CPU with LZCNT support.
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build TestUseCountLeadingZerosInstructionOnSupportedCPU
* BMISupportedCPUTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/compiler/arguments/TestUseCountLeadingZerosInstructionOnUnsupportedCPU.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/arguments/TestUseCountLeadingZerosInstructionOnUnsupportedCPU.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @summary Verify processing of UseCountLeadingZerosInstruction option
* on CPU without LZCNT support.
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build TestUseCountLeadingZerosInstructionOnUnsupportedCPU
* BMIUnsupportedCPUTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/compiler/arguments/TestUseCountTrailingZerosInstructionOnSupportedCPU.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/arguments/TestUseCountTrailingZerosInstructionOnSupportedCPU.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @summary Verify processing of UseCountTrailingZerosInstruction option
* on CPU with TZCNT (BMI1 feature) support.
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build TestUseCountTrailingZerosInstructionOnSupportedCPU
* BMISupportedCPUTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/compiler/arguments/TestUseCountTrailingZerosInstructionOnUnsupportedCPU.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/arguments/TestUseCountTrailingZerosInstructionOnUnsupportedCPU.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @summary Verify processing of UseCountTrailingZerosInstruction option
* on CPU without TZCNT instruction (BMI1 feature) support.
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build TestUseCountTrailingZerosInstructionOnUnsupportedCPU
* BMIUnsupportedCPUTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/compiler/arraycopy/TestArrayCopyNoInitDeopt.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/arraycopy/TestArrayCopyNoInitDeopt.java Tue Apr 14 12:10:00 2015 -0700
@@ -26,6 +26,8 @@
* @bug 8072016
* @summary Infinite deoptimization/recompilation cycles in case of arraycopy with tightly coupled allocation
* @library /testlibrary /../../test/lib /compiler/whitebox
+ * @modules java.base/sun.misc
+ * java.management
* @build TestArrayCopyNoInitDeopt
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* @run main ClassFileInstaller com.oracle.java.testlibrary.Platform
--- a/hotspot/test/compiler/c1/6932496/Test6932496.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/c1/6932496/Test6932496.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
* @test
* @bug 6932496
* @summary incorrect deopt of jsr subroutine on 64 bit c1
+ * @modules java.base/jdk.internal.org.objectweb.asm
* @run main/othervm -Xcomp -XX:CompileOnly=Test.test Test6932496
*/
import java.lang.reflect.Method;
--- a/hotspot/test/compiler/c2/6589834/Test_ia32.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/c2/6589834/Test_ia32.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,10 @@
* @summary Safepoint placed between stack pointer increment and decrement leads
* to interpreter's stack corruption after deoptimization.
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.compiler
+ * java.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @build ClassFileInstaller sun.hotspot.WhiteBox com.oracle.java.testlibrary.*
* Test_ia32 InlinedArrayCloneTestCase
* @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/compiler/c2/6852078/Test6852078.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/c2/6852078/Test6852078.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 6852078
* @summary Disable SuperWord optimization for unsafe read/write
*
+ * @modules java.corba/com.sun.corba.se.impl.encoding
+ * java.corba/com.sun.jndi.toolkit.corba
* @run main Test6852078
*/
--- a/hotspot/test/compiler/c2/6857159/Test6857159.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/c2/6857159/Test6857159.java Tue Apr 14 12:10:00 2015 -0700
@@ -27,6 +27,8 @@
* @bug 6857159
* @summary local schedule failed with checkcast of Thread.currentThread()
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.*;
--- a/hotspot/test/compiler/c2/6968348/Test6968348.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/c2/6968348/Test6968348.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
* @bug 6968348
* @summary Byteswapped memory access can point to wrong location after JIT
*
+ * @modules java.base/sun.misc
* @run main Test6968348
*/
--- a/hotspot/test/compiler/c2/7047069/Test7047069.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/c2/7047069/Test7047069.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
* @bug 7047069
* @summary Array can dynamically change size when assigned to an object field
*
+ * @modules java.desktop
* @run main/othervm -Xbatch Test7047069
*/
--- a/hotspot/test/compiler/c2/7068051/Test7068051.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/c2/7068051/Test7068051.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary SIGSEGV in PhaseIdealLoop::build_loop_late_post on T5440
* @library /testlibrary
*
+ * @modules java.base/sun.misc
+ * java.management
* @run main/othervm -showversion -Xbatch Test7068051
*/
--- a/hotspot/test/compiler/c2/7190310/Test7190310_unsafe.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/c2/7190310/Test7190310_unsafe.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
* @test
* @bug 7190310
* @summary Inlining WeakReference.get(), and hoisting $referent may lead to non-terminating loops
+ * @modules java.base/sun.misc
* @run main/othervm -Xbatch Test7190310_unsafe
*/
--- a/hotspot/test/compiler/c2/8004867/TestIntUnsafeCAS.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/c2/8004867/TestIntUnsafeCAS.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
* @bug 8004867
* @summary VM crashing with assert "share/vm/opto/node.hpp:357 - assert(i < _max) failed: oob"
*
+ * @modules java.base/sun.misc
* @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:-OptimizeFill TestIntUnsafeCAS
* @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:+OptimizeFill TestIntUnsafeCAS
*/
--- a/hotspot/test/compiler/c2/8004867/TestIntUnsafeOrdered.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/c2/8004867/TestIntUnsafeOrdered.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
* @bug 8004867
* @summary VM crashing with assert "share/vm/opto/node.hpp:357 - assert(i < _max) failed: oob"
*
+ * @modules java.base/sun.misc
* @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:-OptimizeFill TestIntUnsafeOrdered
* @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:+OptimizeFill TestIntUnsafeOrdered
*/
--- a/hotspot/test/compiler/c2/8004867/TestIntUnsafeVolatile.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/c2/8004867/TestIntUnsafeVolatile.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
* @bug 8004867
* @summary VM crashing with assert "share/vm/opto/node.hpp:357 - assert(i < _max) failed: oob"
*
+ * @modules java.base/sun.misc
* @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:-OptimizeFill TestIntUnsafeVolatile
* @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:+OptimizeFill TestIntUnsafeVolatile
*/
--- a/hotspot/test/compiler/c2/8005956/PolynomialRoot.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/c2/8005956/PolynomialRoot.java Tue Apr 14 12:10:00 2015 -0700
@@ -14,6 +14,8 @@
* @bug 8005956
* @summary C2: assert(!def_outside->member(r)) failed: Use of external LRG overlaps the same LRG defined in this block
* @library /testlibrary
+* @modules java.base/sun.misc
+* java.management
* @run main/timeout=300 PolynomialRoot
*/
--- a/hotspot/test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -34,6 +34,7 @@
* @bug 8054402
* @summary "Tests unloading of anonymous classes."
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
* @compile TestAnonymousClassUnloading.java
* @run main ClassFileInstaller TestAnonymousClassUnloading
* sun.hotspot.WhiteBox
--- a/hotspot/test/compiler/codecache/CheckReservedInitialCodeCacheSizeArgOrder.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/codecache/CheckReservedInitialCodeCacheSizeArgOrder.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* InitialCodeCacheSize are passed to the VM is irrelevant.
* @library /testlibrary
*
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.*;
--- a/hotspot/test/compiler/codecache/CheckSegmentedCodeCache.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/codecache/CheckSegmentedCodeCache.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,8 @@
* @bug 8015774
* @library /testlibrary /../../test/lib
* @summary "Checks VM options related to the segmented code cache"
+ * @modules java.base/sun.misc
+ * java.management
* @build CheckSegmentedCodeCache
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/codecache/CheckUpperLimit.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/codecache/CheckUpperLimit.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @summary Test ensures that the ReservedCodeCacheSize is at most MAXINT
* @library /testlibrary
*
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.*;
--- a/hotspot/test/compiler/codecache/OverflowCodeCacheTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/codecache/OverflowCodeCacheTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -35,6 +35,7 @@
* @test OverflowCodeCacheTest
* @bug 8059550
* @library /testlibrary /../../test/lib
+ * @modules java.management
* @build OverflowCodeCacheTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/codecache/cli/TestSegmentedCodeCacheOption.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/codecache/cli/TestSegmentedCodeCacheOption.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,10 @@
* @bug 8015774
* @summary Verify SegmentedCodeCache option's processing
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.compiler
+ * java.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @build TestSegmentedCodeCacheOption com.oracle.java.testlibrary.*
* @run main TestSegmentedCodeCacheOption
*/
--- a/hotspot/test/compiler/codecache/cli/codeheapsize/TestCodeHeapSizeOptions.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/codecache/cli/codeheapsize/TestCodeHeapSizeOptions.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,10 @@
* @bug 8015774
* @summary Verify processing of options related to code heaps sizing.
* @library /testlibrary .. /../../test/lib
+ * @modules java.base/sun.misc
+ * java.compiler
+ * java.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @build TestCodeHeapSizeOptions com.oracle.java.testlibrary.* codeheapsize.*
* common.*
* @run main/timeout=240 codeheapsize.TestCodeHeapSizeOptions
--- a/hotspot/test/compiler/codecache/cli/printcodecache/TestPrintCodeCacheOption.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/codecache/cli/printcodecache/TestPrintCodeCacheOption.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,10 @@
* @bug 8015774
* @summary Verify that PrintCodeCache option print correct information.
* @library /testlibrary .. /../../test/lib
+ * @modules java.base/sun.misc
+ * java.compiler
+ * java.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @build TestPrintCodeCacheOption com.oracle.java.testlibrary.*
* printcodecache.* common.*
* @run main/timeout=240 printcodecache.TestPrintCodeCacheOption
--- a/hotspot/test/compiler/codecache/jmx/BeanTypeTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/codecache/jmx/BeanTypeTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,7 @@
/**
* @test BeanTypeTest
* @library /testlibrary /../../test/lib
+ * @modules java.management
* @build BeanTypeTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/codecache/jmx/CodeHeapBeanPresenceTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/codecache/jmx/CodeHeapBeanPresenceTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,7 @@
/**
* @test CodeHeapBeanPresenceTest
* @library /testlibrary /../../test/lib
+ * @modules java.management
* @build CodeHeapBeanPresenceTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/codecache/jmx/GetUsageTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/codecache/jmx/GetUsageTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,8 @@
/*
* @test GetUsageTest
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build GetUsageTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/codecache/jmx/InitialAndMaxUsageTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/codecache/jmx/InitialAndMaxUsageTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,8 @@
/*
* @test InitialAndMaxUsageTest
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build InitialAndMaxUsageTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/codecache/jmx/ManagerNamesTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/codecache/jmx/ManagerNamesTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,7 @@
/**
* @test ManagerNamesTest
* @library /testlibrary /../../test/lib
+ * @modules java.management
* @build ManagerNamesTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/codecache/jmx/MemoryPoolsPresenceTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/codecache/jmx/MemoryPoolsPresenceTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -33,6 +33,7 @@
/**
* @test MemoryPoolsPresenceTest
* @library /testlibrary /../../test/lib
+ * @modules java.management
* @build MemoryPoolsPresenceTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/codecache/jmx/PeakUsageTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/codecache/jmx/PeakUsageTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
/*
* @test PeakUsageTest
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build PeakUsageTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/codecache/jmx/ThresholdNotificationsTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/codecache/jmx/ThresholdNotificationsTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -35,6 +35,8 @@
/*
* @test ThresholdNotificationsTest
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build ThresholdNotificationsTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/codecache/jmx/UsageThresholdExceededSeveralTimesTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/codecache/jmx/UsageThresholdExceededSeveralTimesTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,8 @@
/*
* @test UsageThresholdExceededSeveralTimesTest
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build UsageThresholdExceededTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/codecache/jmx/UsageThresholdExceededTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/codecache/jmx/UsageThresholdExceededTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
/*
* @test UsageThresholdExceededTest
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build UsageThresholdExceededTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/codecache/jmx/UsageThresholdIncreasedTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/codecache/jmx/UsageThresholdIncreasedTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
/*
* @test UsageThresholdIncreasedTest
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build UsageThresholdIncreasedTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/codecache/jmx/UsageThresholdNotExceededTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/codecache/jmx/UsageThresholdNotExceededTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
/*
* @test UsageThresholdNotExceededTest
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build UsageThresholdNotExceededTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/codecache/stress/OverloadCompileQueueTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/codecache/stress/OverloadCompileQueueTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,8 @@
/*
* @test OverloadCompileQueueTest
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @ignore 8071905
* @build OverloadCompileQueueTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/compiler/codecache/stress/RandomAllocationTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/codecache/stress/RandomAllocationTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,8 @@
/*
* @test RandomAllocationTest
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build RandomAllocationTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/codecache/stress/UnexpectedDeoptimizationTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/codecache/stress/UnexpectedDeoptimizationTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
/*
* @test UnexpectedDeoptimizationTest
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build UnexpectedDeoptimizationTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/codegen/6896617/Test6896617.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/codegen/6896617/Test6896617.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,9 @@
* @bug 6896617
* @summary Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() with SSE instructions on x86
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.base/sun.nio.cs
+ * java.management
* @run main/othervm/timeout=1200 -Xbatch -Xmx256m Test6896617
*
*/
--- a/hotspot/test/compiler/codegen/7100757/Test7100757.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/codegen/7100757/Test7100757.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 7100757
* @summary The BitSet.nextSetBit() produces incorrect result in 32bit VM on Sparc
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main/timeout=300 Test7100757
*/
--- a/hotspot/test/compiler/codegen/7184394/TestAESMain.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/codegen/7184394/TestAESMain.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary add intrinsics to use AES instructions
* @library /testlibrary
*
+ * @modules java.base/sun.misc
+ * java.management
* @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC TestAESMain
* @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC -DencInputOffset=1 TestAESMain
* @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC -DencOutputOffset=1 TestAESMain
--- a/hotspot/test/compiler/codegen/8011901/Test8011901.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/codegen/8011901/Test8011901.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
* @test
* @bug 8011901
* @summary instruct xaddL_no_res shouldn't allow 64 bit constants.
+ * @modules java.base/sun.misc
* @run main/othervm -XX:-BackgroundCompilation Test8011901
*
*/
--- a/hotspot/test/compiler/cpuflags/RestoreMXCSR.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/cpuflags/RestoreMXCSR.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,8 @@
* @bug 8020433
* @summary Crash when using -XX:+RestoreMXCSROnJNICalls
* @library /testlibrary
- *
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.*;
--- a/hotspot/test/compiler/debug/VerifyAdapterSharing.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/debug/VerifyAdapterSharing.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,8 @@
* @bug 8030783
* @summary Regression test for 8026478
* @library /testlibrary
- *
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.*;
--- a/hotspot/test/compiler/dependencies/MonomorphicObjectCall/TestMonomorphicObjectCall.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/dependencies/MonomorphicObjectCall/TestMonomorphicObjectCall.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,8 @@
* @bug 8050079
* @summary Compiles a monomorphic call to finalizeObject() on a modified java.lang.Object to test C1 CHA.
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @compile -XDignore.symbol.file java/lang/Object.java TestMonomorphicObjectCall.java
* @run main TestMonomorphicObjectCall
*/
--- a/hotspot/test/compiler/escapeAnalysis/TestUnsafePutAddressNullObjMustNotEscape.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/escapeAnalysis/TestUnsafePutAddressNullObjMustNotEscape.java Tue Apr 14 12:10:00 2015 -0700
@@ -25,6 +25,7 @@
* @test
* @bug 8038048
* @summary assert(null_obj->escape_state() == PointsToNode::NoEscape,etc)
+ * @modules java.base/sun.misc
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+DoEscapeAnalysis -XX:-TieredCompilation -Xbatch TestUnsafePutAddressNullObjMustNotEscape
* @author Richard Reingruber richard DOT reingruber AT sap DOT com
*/
--- a/hotspot/test/compiler/floatingpoint/TestPow2.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/floatingpoint/TestPow2.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
* @bug 8063086
* @summary X^2 special case for C2 yields different result than interpreter
* @library /testlibrary /../../test/lib /compiler/whitebox
+ * @modules java.management
* @build TestPow2
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
--- a/hotspot/test/compiler/intrinsics/bmi/TestAndnI.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/bmi/TestAndnI.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Verify that results of computations are the same w/
* and w/o usage of ANDN instruction
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build TestAndnI BMITestRunner Expr
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/TestAndnL.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/bmi/TestAndnL.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Verify that results of computations are the same w/
* and w/o usage of ANDN instruction
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build TestAndnL BMITestRunner Expr
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/TestBlsiI.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/bmi/TestBlsiI.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Verify that results of computations are the same w/
* and w/o usage of BLSI instruction
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build TestBlsiI BMITestRunner Expr
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/TestBlsiL.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/bmi/TestBlsiL.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Verify that results of computations are the same w/
* and w/o usage of BLSI instruction
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build TestBlsiL BMITestRunner Expr
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/TestBlsmskI.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/bmi/TestBlsmskI.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Verify that results of computations are the same w/
* and w/o usage of BLSMSK instruction
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build TestBlsmskI BMITestRunner Expr
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/TestBlsmskL.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/bmi/TestBlsmskL.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Verify that results of computations are the same w/
* and w/o usage of BLSMSK instruction
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build TestBlsmskL BMITestRunner Expr
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/TestBlsrI.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/bmi/TestBlsrI.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Verify that results of computations are the same w/
* and w/o usage of BLSR instruction
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build TestBlsrI BMITestRunner Expr
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/TestBlsrL.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/bmi/TestBlsrL.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Verify that results of computations are the same w/
* and w/o usage of BLSR instruction
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build TestBlsrL BMITestRunner Expr
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/TestLzcntI.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/bmi/TestLzcntI.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Verify that results of computations are the same w/
* and w/o usage of intrinsic
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build TestLzcntI BMITestRunner Expr
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/TestLzcntL.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/bmi/TestLzcntL.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Verify that results of computations are the same w/
* and w/o usage of intrinsic
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build TestLzcntL BMITestRunner Expr
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/TestTzcntI.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/bmi/TestTzcntI.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Verify that results of computations are the same w/
* and w/o usage of intrinsic
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build TestTzcntI BMITestRunner Expr
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/TestTzcntL.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/bmi/TestTzcntL.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Verify that results of computations are the same w/
* and w/o usage of intrinsic
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build TestTzcntL BMITestRunner Expr
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/verifycode/AddnTestI.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/AddnTestI.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test
* @bug 8031321
* @library /testlibrary /../../test/lib /compiler/whitebox ..
+ * @modules java.base/sun.misc
+ * java.management
* @build AddnTestI
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/verifycode/AddnTestL.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/AddnTestL.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test
* @bug 8031321
* @library /testlibrary /../../test/lib /compiler/whitebox ..
+ * @modules java.base/sun.misc
+ * java.management
* @build AddnTestL
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/verifycode/BlsiTestI.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/BlsiTestI.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test
* @bug 8031321
* @library /testlibrary /../../test/lib /compiler/whitebox ..
+ * @modules java.base/sun.misc
+ * java.management
* @build BlsiTestI
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/verifycode/BlsiTestL.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/BlsiTestL.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test
* @bug 8031321
* @library /testlibrary /../../test/lib /compiler/whitebox ..
+ * @modules java.base/sun.misc
+ * java.management
* @build BlsiTestL
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/verifycode/BlsmskTestI.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/BlsmskTestI.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test
* @bug 8031321
* @library /testlibrary /../../test/lib /compiler/whitebox ..
+ * @modules java.base/sun.misc
+ * java.management
* @build BlsmskTestI
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/verifycode/BlsmskTestL.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/BlsmskTestL.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test
* @bug 8031321
* @library /testlibrary /../../test/lib /compiler/whitebox ..
+ * @modules java.base/sun.misc
+ * java.management
* @build BlsmskTestL
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/verifycode/BlsrTestI.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/BlsrTestI.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test
* @bug 8031321
* @library /testlibrary /../../test/lib /compiler/whitebox ..
+ * @modules java.base/sun.misc
+ * java.management
* @build BlsrTestI
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/verifycode/BlsrTestL.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/BlsrTestL.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test
* @bug 8031321
* @library /testlibrary /../../test/lib /compiler/whitebox ..
+ * @modules java.base/sun.misc
+ * java.management
* @build BlsrTestL
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/verifycode/LZcntTestI.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/LZcntTestI.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test
* @bug 8031321
* @library /testlibrary /../../test/lib /compiler/whitebox ..
+ * @modules java.base/sun.misc
+ * java.management
* @build LZcntTestI
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/verifycode/LZcntTestL.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/LZcntTestL.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test
* @bug 8031321
* @library /testlibrary /../../test/lib /compiler/whitebox ..
+ * @modules java.base/sun.misc
+ * java.management
* @build LZcntTestL
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/verifycode/TZcntTestI.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/TZcntTestI.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test
* @bug 8031321
* @library /testlibrary /../../test/lib /compiler/whitebox ..
+ * @modules java.base/sun.misc
+ * java.management
* @build TZcntTestI
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/bmi/verifycode/TZcntTestL.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/TZcntTestL.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test
* @bug 8031321
* @library /testlibrary /../../test/lib /compiler/whitebox ..
+ * @modules java.base/sun.misc
+ * java.management
* @build TZcntTestL
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/classcast/NullCheckDroppingsTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/classcast/NullCheckDroppingsTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8054492
* @summary "Casting can result in redundant null checks in generated code"
* @library /testlibrary /../../test/lib /testlibrary/com/oracle/java/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build NullCheckDroppingsTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/mathexact/AddExactIConstantTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/AddExactIConstantTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8024924
* @summary Test constant addExact
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @compile AddExactIConstantTest.java Verify.java
* @run main AddExactIConstantTest
*
--- a/hotspot/test/compiler/intrinsics/mathexact/AddExactILoadTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/AddExactILoadTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8024924
* @summary Test non constant addExact
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @compile AddExactILoadTest.java Verify.java
* @run main AddExactILoadTest
*
--- a/hotspot/test/compiler/intrinsics/mathexact/AddExactILoopDependentTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/AddExactILoopDependentTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8024924
* @summary Test non constant addExact
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @compile AddExactILoopDependentTest.java Verify.java
* @run main AddExactILoopDependentTest
*
--- a/hotspot/test/compiler/intrinsics/mathexact/AddExactINonConstantTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/AddExactINonConstantTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8024924
* @summary Test non constant addExact
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @compile AddExactINonConstantTest.java Verify.java
* @run main AddExactINonConstantTest
*
--- a/hotspot/test/compiler/intrinsics/mathexact/AddExactIRepeatTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/AddExactIRepeatTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8025657
* @summary Test repeating addExact
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @compile AddExactIRepeatTest.java Verify.java
* @run main AddExactIRepeatTest
*
--- a/hotspot/test/compiler/intrinsics/mathexact/AddExactLConstantTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/AddExactLConstantTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8026844
* @summary Test constant addExact
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @compile AddExactLConstantTest.java Verify.java
* @run main AddExactLConstantTest
*
--- a/hotspot/test/compiler/intrinsics/mathexact/AddExactLNonConstantTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/AddExactLNonConstantTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8026844
* @summary Test non constant addExact
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @compile AddExactLNonConstantTest.java Verify.java
* @run main AddExactLNonConstantTest
*
--- a/hotspot/test/compiler/intrinsics/mathexact/DecExactITest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/DecExactITest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8026844
* @summary Test decrementExact
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @compile DecExactITest.java Verify.java
* @run main DecExactITest
*
--- a/hotspot/test/compiler/intrinsics/mathexact/DecExactLTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/DecExactLTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8026844
* @summary Test decrementExact
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @compile DecExactLTest.java Verify.java
* @run main DecExactLTest
*
--- a/hotspot/test/compiler/intrinsics/mathexact/IncExactITest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/IncExactITest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8026844
* @summary Test incrementExact
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @compile IncExactITest.java Verify.java
* @run main IncExactITest
*
--- a/hotspot/test/compiler/intrinsics/mathexact/IncExactLTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/IncExactLTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8026844
* @summary Test incrementExact
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @compile IncExactLTest.java Verify.java
* @run main IncExactLTest
*
--- a/hotspot/test/compiler/intrinsics/mathexact/MulExactIConstantTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/MulExactIConstantTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8026844
* @summary Test constant multiplyExact
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @compile MulExactIConstantTest.java Verify.java
* @run main MulExactIConstantTest
*
--- a/hotspot/test/compiler/intrinsics/mathexact/MulExactILoadTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/MulExactILoadTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8026844
* @summary Test multiplyExact
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @compile MulExactILoadTest.java Verify.java
* @run main MulExactILoadTest
*
--- a/hotspot/test/compiler/intrinsics/mathexact/MulExactILoopDependentTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/MulExactILoopDependentTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8026844
* @summary Test loop dependent multiplyExact
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @compile MulExactILoopDependentTest.java Verify.java
* @run main MulExactILoopDependentTest
*
--- a/hotspot/test/compiler/intrinsics/mathexact/MulExactINonConstantTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/MulExactINonConstantTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8026844
* @summary Test non constant multiplyExact
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @compile MulExactINonConstantTest.java Verify.java
* @run main MulExactINonConstantTest
*
--- a/hotspot/test/compiler/intrinsics/mathexact/MulExactIRepeatTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/MulExactIRepeatTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8026844
* @summary Test repeating multiplyExact
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @compile MulExactIRepeatTest.java Verify.java
* @run main MulExactIRepeatTest
*
--- a/hotspot/test/compiler/intrinsics/mathexact/MulExactLConstantTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/MulExactLConstantTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8026844
* @summary Test constant mulExact
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @compile MulExactLConstantTest.java Verify.java
* @run main MulExactLConstantTest
*
--- a/hotspot/test/compiler/intrinsics/mathexact/MulExactLNonConstantTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/MulExactLNonConstantTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8026844
* @summary Test non constant mulExact
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @compile MulExactLNonConstantTest.java Verify.java
* @run main MulExactLNonConstantTest
*
--- a/hotspot/test/compiler/intrinsics/mathexact/NegExactIConstantTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/NegExactIConstantTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8026844
* @summary Test constant negExact
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @compile NegExactIConstantTest.java Verify.java
* @run main NegExactIConstantTest
*
--- a/hotspot/test/compiler/intrinsics/mathexact/NegExactILoadTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/NegExactILoadTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8026844
* @summary Test negExact
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @compile NegExactILoadTest.java Verify.java
* @run main NegExactILoadTest
*
--- a/hotspot/test/compiler/intrinsics/mathexact/NegExactILoopDependentTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/NegExactILoopDependentTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8026844
* @summary Test negExact loop dependent
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @compile NegExactILoopDependentTest.java Verify.java
* @run main NegExactILoopDependentTest
*
--- a/hotspot/test/compiler/intrinsics/mathexact/NegExactINonConstantTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/NegExactINonConstantTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8026844
* @summary Test non constant negExact
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @compile NegExactINonConstantTest.java Verify.java
* @run main NegExactINonConstantTest
*
--- a/hotspot/test/compiler/intrinsics/mathexact/NegExactLConstantTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/NegExactLConstantTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8026844
* @summary Test constant negExact
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @compile NegExactLConstantTest.java Verify.java
* @run main NegExactLConstantTest
*
--- a/hotspot/test/compiler/intrinsics/mathexact/NegExactLNonConstantTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/NegExactLNonConstantTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8026844
* @summary Test constant negExact
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @compile NegExactLNonConstantTest.java Verify.java
* @run main NegExactLNonConstantTest
*
--- a/hotspot/test/compiler/intrinsics/mathexact/SubExactICondTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/SubExactICondTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8026844
* @summary Test subtractExact as condition
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @compile SubExactICondTest.java Verify.java
* @run main SubExactICondTest
*
--- a/hotspot/test/compiler/intrinsics/mathexact/SubExactIConstantTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/SubExactIConstantTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8026844
* @summary Test constant subtractExact
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @compile SubExactIConstantTest.java Verify.java
* @run main SubExactIConstantTest
*
--- a/hotspot/test/compiler/intrinsics/mathexact/SubExactILoadTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/SubExactILoadTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8026844
* @summary Test non constant subtractExact
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @compile SubExactILoadTest.java Verify.java
* @run main SubExactILoadTest
*
--- a/hotspot/test/compiler/intrinsics/mathexact/SubExactILoopDependentTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/SubExactILoopDependentTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8026844
* @summary Test non constant subtractExact
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @compile SubExactILoopDependentTest.java Verify.java
* @run main SubExactILoopDependentTest
*
--- a/hotspot/test/compiler/intrinsics/mathexact/SubExactINonConstantTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/SubExactINonConstantTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8026844
* @summary Test non constant subtractExact
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @compile SubExactINonConstantTest.java Verify.java
* @run main SubExactINonConstantTest
*
--- a/hotspot/test/compiler/intrinsics/mathexact/SubExactIRepeatTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/SubExactIRepeatTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8026844
* @summary Test repeating subtractExact
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @compile SubExactIRepeatTest.java Verify.java
* @run main SubExactIRepeatTest
*
--- a/hotspot/test/compiler/intrinsics/mathexact/SubExactLConstantTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/SubExactLConstantTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8027353
* @summary Test constant subtractExact
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @compile SubExactLConstantTest.java Verify.java
* @run main SubExactLConstantTest
*
--- a/hotspot/test/compiler/intrinsics/mathexact/SubExactLNonConstantTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/SubExactLNonConstantTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8027353
* @summary Test non constant subtractExact
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @compile SubExactLNonConstantTest.java Verify.java
* @run main SubExactLNonConstantTest
*
--- a/hotspot/test/compiler/intrinsics/mathexact/sanity/AddExactIntTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/AddExactIntTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test
* @library /testlibrary /../../test/lib /compiler/whitebox
* /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build AddExactIntTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/mathexact/sanity/AddExactLongTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/AddExactLongTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test
* @library /testlibrary /../../test/lib /compiler/whitebox
* /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build AddExactLongTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/mathexact/sanity/DecrementExactIntTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/DecrementExactIntTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test
* @library /testlibrary /../../test/lib /compiler/whitebox
* /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build DecrementExactIntTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/mathexact/sanity/DecrementExactLongTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/DecrementExactLongTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test
* @library /testlibrary /../../test/lib /compiler/whitebox
* /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build DecrementExactLongTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/mathexact/sanity/IncrementExactIntTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/IncrementExactIntTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test
* @library /testlibrary /../../test/lib /compiler/whitebox
* /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build IncrementExactIntTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/mathexact/sanity/IncrementExactLongTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/IncrementExactLongTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test
* @library /testlibrary /../../test/lib /compiler/whitebox
* /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build IncrementExactLongTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/mathexact/sanity/MultiplyExactIntTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/MultiplyExactIntTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test
* @library /testlibrary /../../test/lib /compiler/whitebox
* /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build MultiplyExactIntTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/mathexact/sanity/MultiplyExactLongTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/MultiplyExactLongTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test
* @library /testlibrary /../../test/lib /compiler/whitebox
* /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build MultiplyExactLongTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/mathexact/sanity/NegateExactIntTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/NegateExactIntTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test
* @library /testlibrary /../../test/lib /compiler/whitebox
* /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build NegateExactIntTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/mathexact/sanity/NegateExactLongTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/NegateExactLongTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test
* @library /testlibrary /../../test/lib /compiler/whitebox
* /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build NegateExactLongTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/mathexact/sanity/SubtractExactIntTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/SubtractExactIntTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test
* @library /testlibrary /../../test/lib /compiler/whitebox
* /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build SubtractExactIntTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/mathexact/sanity/SubtractExactLongTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/SubtractExactLongTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test
* @library /testlibrary /../../test/lib /compiler/whitebox
* /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build SubtractExactLongTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/sha/cli/TestUseSHA1IntrinsicsOptionOnSupportedCPU.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/sha/cli/TestUseSHA1IntrinsicsOptionOnSupportedCPU.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8035968
* @summary Verify UseSHA1Intrinsics option processing on supported CPU,
* @library /testlibrary /../../test/lib /compiler/testlibrary testcases
+ * @modules java.base/sun.misc
+ * java.management
* @build TestUseSHA1IntrinsicsOptionOnSupportedCPU
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/sha/cli/TestUseSHA1IntrinsicsOptionOnUnsupportedCPU.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/sha/cli/TestUseSHA1IntrinsicsOptionOnUnsupportedCPU.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8035968
* @summary Verify UseSHA1Intrinsics option processing on unsupported CPU,
* @library /testlibrary /../../test/lib /compiler/testlibrary testcases
+ * @modules java.base/sun.misc
+ * java.management
* @build TestUseSHA1IntrinsicsOptionOnUnsupportedCPU
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/sha/cli/TestUseSHA256IntrinsicsOptionOnSupportedCPU.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/sha/cli/TestUseSHA256IntrinsicsOptionOnSupportedCPU.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8035968
* @summary Verify UseSHA256Intrinsics option processing on supported CPU,
* @library /testlibrary /../../test/lib /compiler/testlibrary testcases
+ * @modules java.base/sun.misc
+ * java.management
* @build TestUseSHA256IntrinsicsOptionOnSupportedCPU
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/sha/cli/TestUseSHA256IntrinsicsOptionOnUnsupportedCPU.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/sha/cli/TestUseSHA256IntrinsicsOptionOnUnsupportedCPU.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8035968
* @summary Verify UseSHA256Intrinsics option processing on unsupported CPU,
* @library /testlibrary /../../test/lib /compiler/testlibrary testcases
+ * @modules java.base/sun.misc
+ * java.management
* @build TestUseSHA256IntrinsicsOptionOnUnsupportedCPU
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/sha/cli/TestUseSHA512IntrinsicsOptionOnSupportedCPU.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/sha/cli/TestUseSHA512IntrinsicsOptionOnSupportedCPU.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8035968
* @summary Verify UseSHA512Intrinsics option processing on supported CPU.
* @library /testlibrary /../../test/lib /compiler/testlibrary testcases
+ * @modules java.base/sun.misc
+ * java.management
* @build TestUseSHA512IntrinsicsOptionOnSupportedCPU
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/sha/cli/TestUseSHA512IntrinsicsOptionOnUnsupportedCPU.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/sha/cli/TestUseSHA512IntrinsicsOptionOnUnsupportedCPU.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8035968
* @summary Verify UseSHA512Intrinsics option processing on unsupported CPU,
* @library /testlibrary /../../test/lib /compiler/testlibrary testcases
+ * @modules java.base/sun.misc
+ * java.management
* @build TestUseSHA512IntrinsicsOptionOnUnsupportedCPU
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/sha/cli/TestUseSHAOptionOnSupportedCPU.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/sha/cli/TestUseSHAOptionOnSupportedCPU.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8035968
* @summary Verify UseSHA option processing on supported CPU,
* @library /testlibrary /../../test/lib /compiler/testlibrary testcases
+ * @modules java.base/sun.misc
+ * java.management
* @build TestUseSHAOptionOnSupportedCPU
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/sha/cli/TestUseSHAOptionOnUnsupportedCPU.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/sha/cli/TestUseSHAOptionOnUnsupportedCPU.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8035968
* @summary Verify UseSHA option processing on unsupported CPU.
* @library /testlibrary /../../test/lib /compiler/testlibrary testcases
+ * @modules java.base/sun.misc
+ * java.management
* @build TestUseSHAOptionOnUnsupportedCPU
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/sha/sanity/TestSHA1Intrinsics.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/sha/sanity/TestSHA1Intrinsics.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8035968
* @summary Verify that SHA-1 intrinsic is actually used.
* @library /testlibrary /../../test/lib /compiler/testlibrary ../
+ * @modules java.base/sun.misc
+ * java.management
* @build TestSHA intrinsics.Verifier TestSHA1Intrinsics
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/sha/sanity/TestSHA1MultiBlockIntrinsics.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/sha/sanity/TestSHA1MultiBlockIntrinsics.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @bug 8035968
* @summary Verify that SHA-1 multi block intrinsic is actually used.
* @library /testlibrary /../../test/lib /compiler/testlibrary ../
+ * @modules java.base/sun.misc
+ * java.management
* @build TestSHA intrinsics.Verifier TestSHA1MultiBlockIntrinsics
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/sha/sanity/TestSHA256Intrinsics.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/sha/sanity/TestSHA256Intrinsics.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @bug 8035968
* @summary Verify that SHA-256 intrinsic is actually used.
* @library /testlibrary /../../test/lib /compiler/testlibrary ../
+ * @modules java.base/sun.misc
+ * java.management
* @build TestSHA intrinsics.Verifier TestSHA256Intrinsics
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/sha/sanity/TestSHA256MultiBlockIntrinsics.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/sha/sanity/TestSHA256MultiBlockIntrinsics.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @bug 8035968
* @summary Verify that SHA-256 multi block intrinsic is actually used.
* @library /testlibrary /../../test/lib /compiler/testlibrary ../
+ * @modules java.base/sun.misc
+ * java.management
* @build TestSHA intrinsics.Verifier TestSHA256MultiBlockIntrinsics
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/sha/sanity/TestSHA512Intrinsics.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/sha/sanity/TestSHA512Intrinsics.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @bug 8035968
* @summary Verify that SHA-512 intrinsic is actually used.
* @library /testlibrary /../../test/lib /compiler/testlibrary ../
+ * @modules java.base/sun.misc
+ * java.management
* @build TestSHA intrinsics.Verifier TestSHA512Intrinsics
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/sha/sanity/TestSHA512MultiBlockIntrinsics.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/sha/sanity/TestSHA512MultiBlockIntrinsics.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @bug 8035968
* @summary Verify that SHA-512 multi block intrinsic is actually used.
* @library /testlibrary /../../test/lib /compiler/testlibrary ../
+ * @modules java.base/sun.misc
+ * java.management
* @build TestSHA intrinsics.Verifier TestSHA512MultiBlockIntrinsics
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/intrinsics/unsafe/UnsafeGetAddressTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/intrinsics/unsafe/UnsafeGetAddressTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
* @test
* @bug 6653795
* @summary C2 intrinsic for Unsafe.getAddress performs pointer sign extension on 32-bit systems
+ * @modules java.base/sun.misc
* @run main UnsafeGetAddressTest
*
*/
--- a/hotspot/test/compiler/jsr292/ConcurrentClassLoadingTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/jsr292/ConcurrentClassLoadingTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8022595
* @summary JSR292: deadlock during class loading of MethodHandles, MethodHandleImpl & MethodHandleNatives
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main/othervm ConcurrentClassLoadingTest
*/
import com.oracle.java.testlibrary.Utils;
--- a/hotspot/test/compiler/jsr292/CreatesInterfaceDotEqualsCallInfo.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/jsr292/CreatesInterfaceDotEqualsCallInfo.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,7 @@
* @test
* @bug 8026124
* @summary Javascript file provoked assertion failure in linkResolver.cpp
- *
+ * @modules jdk.scripting.nashorn/jdk.nashorn.tools
* @run main/othervm CreatesInterfaceDotEqualsCallInfo
*/
--- a/hotspot/test/compiler/jsr292/RedefineMethodUsedByMultipleMethodHandles.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/jsr292/RedefineMethodUsedByMultipleMethodHandles.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,10 @@
* @test
* @bug 8042235
* @summary redefining method used by multiple MethodHandles crashes VM
+ * @modules java.base/jdk.internal.org.objectweb.asm
+ * java.compiler
+ * java.instrument
+ * java.management
* @compile -XDignore.symbol.file RedefineMethodUsedByMultipleMethodHandles.java
* @run main RedefineMethodUsedByMultipleMethodHandles
*/
--- a/hotspot/test/compiler/jsr292/VMAnonymousClasses.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/jsr292/VMAnonymousClasses.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,8 @@
/**
* @test
* @bug 8058828
+ * @modules java.base/jdk.internal.org.objectweb.asm
+ * java.base/sun.misc
* @run main/bootclasspath -Xbatch VMAnonymousClasses
*/
--- a/hotspot/test/compiler/jsr292/methodHandleExceptions/TestAMEnotNPE.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/jsr292/methodHandleExceptions/TestAMEnotNPE.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -35,6 +35,7 @@
* @test @bug 8025260 8016839
* @summary Ensure that AbstractMethodError and IllegalAccessError are thrown appropriately, not NullPointerException
*
+ * @modules java.base/jdk.internal.org.objectweb.asm
* @compile -XDignore.symbol.file TestAMEnotNPE.java ByteClassLoader.java p/C.java p/Dok.java p/E.java p/F.java p/I.java p/Tdirect.java p/Treflect.java
*
* @run main/othervm TestAMEnotNPE
--- a/hotspot/test/compiler/oracle/CheckCompileCommandOption.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/oracle/CheckCompileCommandOption.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,8 @@
* @bug 8055286 8056964 8059847 8069035
* @summary "Checks parsing of -XX:CompileCommand=option"
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main CheckCompileCommandOption
*/
--- a/hotspot/test/compiler/oracle/TestCompileCommand.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/oracle/TestCompileCommand.java Tue Apr 14 12:10:00 2015 -0700
@@ -31,6 +31,8 @@
* @bug 8069389
* @summary "Regression tests of -XX:CompileCommand"
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main TestCompileCommand
*/
--- a/hotspot/test/compiler/osr/TestOSRWithNonEmptyStack.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/osr/TestOSRWithNonEmptyStack.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -33,6 +33,7 @@
* @test
* @bug 8051344
* @summary Force OSR compilation with non-empty stack at the OSR entry point.
+ * @modules java.base/jdk.internal.org.objectweb.asm
* @compile -XDignore.symbol.file TestOSRWithNonEmptyStack.java
* @run main/othervm -XX:CompileOnly=TestCase.test TestOSRWithNonEmptyStack
*/
--- a/hotspot/test/compiler/profiling/spectrapredefineclass/Launcher.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/profiling/spectrapredefineclass/Launcher.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,9 @@
* @test
* @bug 8038636
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.instrument
+ * java.management
* @build Agent
* @run main ClassFileInstaller Agent
* @run main Launcher
--- a/hotspot/test/compiler/profiling/spectrapredefineclass_classloaders/Launcher.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/profiling/spectrapredefineclass_classloaders/Launcher.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,9 @@
* @test
* @bug 8040237
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.instrument
+ * java.management
* @build Agent Test A B
* @run main ClassFileInstaller Agent
* @run main Launcher
--- a/hotspot/test/compiler/rangechecks/TestRangeCheckSmearing.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rangechecks/TestRangeCheckSmearing.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8066103
* @summary C2's range check smearing allows out of bound array accesses
* @library /testlibrary /../../test/lib /compiler/whitebox
+ * @modules java.base/sun.misc
+ * java.management
* @build TestRangeCheckSmearing
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* @run main ClassFileInstaller com.oracle.java.testlibrary.Platform
--- a/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsOptionOnSupportedConfig.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsOptionOnSupportedConfig.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Verify PrintPreciseRTMLockingStatistics on CPUs with
* rtm support and on VM with rtm locking support,
* @library /testlibrary /../../test/lib /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestPrintPreciseRTMLockingStatisticsOptionOnSupportedConfig
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsOptionOnUnsupportedConfig.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsOptionOnUnsupportedConfig.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Verify PrintPreciseRTMLockingStatistics on CPUs without
* rtm support and/or unsupported VM.
* @library /testlibrary /../../test/lib /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestPrintPreciseRTMLockingStatisticsOptionOnUnsupportedConfig
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/cli/TestRTMAbortRatioOptionOnSupportedConfig.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/cli/TestRTMAbortRatioOptionOnSupportedConfig.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Verify RTMAbortRatio option processing on CPU with rtm
* support and on VM with rtm locking support.
* @library /testlibrary /../../test/lib /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestRTMAbortRatioOptionOnSupportedConfig
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/cli/TestRTMAbortRatioOptionOnUnsupportedConfig.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/cli/TestRTMAbortRatioOptionOnUnsupportedConfig.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Verify RTMAbortRatio option processing on CPU without rtm
* support or on VM that does not support rtm locking.
* @library /testlibrary /../../test/lib /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestRTMAbortRatioOptionOnUnsupportedConfig
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/cli/TestRTMAbortThresholdOption.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/cli/TestRTMAbortThresholdOption.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8031320
* @summary Verify processing of RTMAbortThreshold option.
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestRTMAbortThresholdOption
* @run main/othervm TestRTMAbortThresholdOption
*/
--- a/hotspot/test/compiler/rtm/cli/TestRTMLockingCalculationDelayOption.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/cli/TestRTMLockingCalculationDelayOption.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8031320
* @summary Verify processing of RTMLockingCalculationDelay option.
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestRTMLockingCalculationDelayOption
* @run main/othervm TestRTMLockingCalculationDelayOption
*/
--- a/hotspot/test/compiler/rtm/cli/TestRTMLockingThresholdOption.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/cli/TestRTMLockingThresholdOption.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8031320
* @summary Verify processing of RTMLockingThreshold option.
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestRTMLockingThresholdOption
* @run main/othervm TestRTMLockingThresholdOption
*/
--- a/hotspot/test/compiler/rtm/cli/TestRTMRetryCountOption.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/cli/TestRTMRetryCountOption.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8031320
* @summary Verify processing of RTMRetryCount option.
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestRTMRetryCountOption
* @run main/othervm TestRTMRetryCountOption
*/
--- a/hotspot/test/compiler/rtm/cli/TestRTMSpinLoopCountOption.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/cli/TestRTMSpinLoopCountOption.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8031320
* @summary Verify processing of RTMSpinLoopCount option.
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestRTMSpinLoopCountOption
* @run main/othervm TestRTMSpinLoopCountOption
*/
--- a/hotspot/test/compiler/rtm/cli/TestRTMTotalCountIncrRateOptionOnSupportedConfig.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/cli/TestRTMTotalCountIncrRateOptionOnSupportedConfig.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Verify RTMTotalCountIncrRate option processing on CPU with
* rtm support and on VM with rtm locking support.
* @library /testlibrary /../../test/lib /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestRTMTotalCountIncrRateOptionOnSupportedConfig
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/cli/TestRTMTotalCountIncrRateOptionOnUnsupportedConfig.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/cli/TestRTMTotalCountIncrRateOptionOnUnsupportedConfig.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -33,6 +33,8 @@
* @summary Verify RTMTotalCountIncrRate option processing on CPU without
* rtm support and/or on VM without rtm locking support.
* @library /testlibrary /../../test/lib /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestRTMTotalCountIncrRateOptionOnUnsupportedConfig
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnSupportedConfig.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnSupportedConfig.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Verify UseRTMDeopt option processing on CPUs with rtm support
* when rtm locking is supported by VM.
* @library /testlibrary /../../test/lib /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestUseRTMDeoptOptionOnSupportedConfig
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnUnsupportedConfig.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnUnsupportedConfig.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Verify UseRTMDeopt option processing on CPUs without rtm support
* or on VMs without rtm locking support.
* @library /testlibrary /../../test/lib /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestUseRTMDeoptOptionOnUnsupportedConfig
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnSupportedConfig.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnSupportedConfig.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Verify UseRTMForStackLocks option processing on CPU with
* rtm support when VM supports rtm locking.
* @library /testlibrary /../../test/lib /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestUseRTMForStackLocksOptionOnSupportedConfig
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnUnsupportedConfig.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnUnsupportedConfig.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Verify UseRTMForStackLocks option processing on CPUs without
* rtm support and/or on VMs without rtm locking support.
* @library /testlibrary /../../test/lib /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestUseRTMForStackLocksOptionOnUnsupportedConfig
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnSupportedConfig.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnSupportedConfig.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Verify UseRTMLocking option processing on CPU with rtm support and
* on VM with rtm-locking support.
* @library /testlibrary /../../test/lib /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestUseRTMLockingOptionOnSupportedConfig
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnUnsupportedCPU.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnUnsupportedCPU.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Verify UseRTMLocking option processing on CPU without
* rtm support.
* @library /testlibrary /../../test/lib /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestUseRTMLockingOptionOnUnsupportedCPU
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnUnsupportedVM.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnUnsupportedVM.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Verify UseRTMLocking option processing on CPU with rtm support
* in case when VM should not support this option.
* @library /testlibrary /../../test/lib /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestUseRTMLockingOptionOnUnsupportedVM
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionWithBiasedLocking.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionWithBiasedLocking.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Verify processing of UseRTMLocking and UseBiasedLocking
* options combination on CPU and VM with rtm support.
* @library /testlibrary /../../test/lib /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestUseRTMLockingOptionWithBiasedLocking
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/cli/TestUseRTMXendForLockBusyOption.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMXendForLockBusyOption.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8031320
* @summary Verify processing of UseRTMXendForLockBusy option.
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestUseRTMXendForLockBusyOption
* @run main/othervm TestUseRTMXendForLockBusyOption
*/
--- a/hotspot/test/compiler/rtm/locking/TestRTMAbortRatio.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/locking/TestRTMAbortRatio.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Verify that RTMAbortRatio affects amount of aborts before
* deoptimization.
* @library /testlibrary /../../test/lib /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestRTMAbortRatio
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/locking/TestRTMAbortThreshold.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/locking/TestRTMAbortThreshold.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Verify that RTMAbortThreshold option affects
* amount of aborts after which abort ratio is calculated.
* @library /testlibrary /../../test/lib /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestRTMAbortThreshold
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,8 @@
* method's RTM state. And if we don't use RTMDeopt, then
* RTM state remain the same after such deoptimization.
* @library /testlibrary /../../test/lib /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestRTMAfterNonRTMDeopt
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnHighAbortRatio.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnHighAbortRatio.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Verify that on high abort ratio method will be recompiled
* without rtm locking.
* @library /testlibrary /../../test/lib /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestRTMDeoptOnHighAbortRatio
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnLowAbortRatio.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnLowAbortRatio.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8031320
* @summary Verify that on low abort ratio method will be recompiled.
* @library /testlibrary /../../test/lib /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestRTMDeoptOnLowAbortRatio
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/locking/TestRTMLockingCalculationDelay.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/locking/TestRTMLockingCalculationDelay.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Verify that RTMLockingCalculationDelay affect when
* abort ratio calculation is started.
* @library /testlibrary /../../test/lib /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestRTMLockingCalculationDelay
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/locking/TestRTMLockingThreshold.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/locking/TestRTMLockingThreshold.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Verify that RTMLockingThreshold affects rtm state transition
* ProfileRTM => UseRTM.
* @library /testlibrary /../../test/lib /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestRTMLockingThreshold
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/locking/TestRTMRetryCount.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/locking/TestRTMRetryCount.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8031320
* @summary Verify that RTMRetryCount affects actual amount of retries.
* @library /testlibrary /../../test/lib /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestRTMRetryCount
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/locking/TestRTMSpinLoopCount.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/locking/TestRTMSpinLoopCount.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Verify that RTMSpinLoopCount affects time spent
* between locking attempts.
* @library /testlibrary /../../test/lib /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestRTMSpinLoopCount
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java Tue Apr 14 12:10:00 2015 -0700
@@ -28,6 +28,8 @@
* @summary Verify that RTMTotalCountIncrRate option affects
* RTM locking statistics.
* @library /testlibrary /../../test/lib /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestRTMTotalCountIncrRate
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/locking/TestUseRTMAfterLockInflation.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/locking/TestUseRTMAfterLockInflation.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Verify that rtm locking is used for stack locks before
* inflation and after it used for inflated locks.
* @library /testlibrary /../../test/lib /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestUseRTMAfterLockInflation
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/locking/TestUseRTMDeopt.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/locking/TestUseRTMDeopt.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Verify that UseRTMDeopt affects uncommon trap installation in
* copmpiled methods with synchronized block.
* @library /testlibrary /../../test/lib /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestUseRTMDeopt
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/locking/TestUseRTMForInflatedLocks.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/locking/TestUseRTMForInflatedLocks.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8031320
* @summary Verify that rtm locking is used for inflated locks.
* @library /testlibrary /../../test/lib /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestUseRTMForInflatedLocks
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/locking/TestUseRTMForStackLocks.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/locking/TestUseRTMForStackLocks.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8031320
* @summary Verify that rtm locking is used for stack locks.
* @library /testlibrary /../../test/lib /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestUseRTMForStackLocks
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/locking/TestUseRTMXendForLockBusy.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/locking/TestUseRTMXendForLockBusy.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Verify that UseRTMXendForLockBusy option affects
* method behaviour if lock is busy.
* @library /testlibrary /../../test/lib /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestUseRTMXendForLockBusy
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/method_options/TestNoRTMLockElidingOption.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/method_options/TestNoRTMLockElidingOption.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Verify that NoRTMLockEliding option could be applied to
* specified method and that such method will not use rtm.
* @library /testlibrary /../../test/lib /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestNoRTMLockElidingOption
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/method_options/TestUseRTMLockElidingOption.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/method_options/TestUseRTMLockElidingOption.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,8 @@
* specified method and that such method will not be deoptimized
* on high abort ratio.
* @library /testlibrary /../../test/lib /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestUseRTMLockElidingOption
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/rtm/print/TestPrintPreciseRTMLockingStatistics.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/rtm/print/TestPrintPreciseRTMLockingStatistics.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,8 @@
* different types. Test also verify that VM output does not
* contain rtm locking statistics when it should not.
* @library /testlibrary /../../test/lib /compiler/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestPrintPreciseRTMLockingStatistics
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/runtime/8010927/Test8010927.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/runtime/8010927/Test8010927.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
* @bug 8010927
* @summary Kitchensink crashed with SIGSEGV, Problematic frame: v ~StubRoutines::checkcast_arraycopy
* @library /../../test/lib /testlibrary
+ * @modules java.base/sun.misc
* @build Test8010927
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/startup/NumCompilerThreadsCheck.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/startup/NumCompilerThreadsCheck.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8034775
* @summary Ensures correct minimal number of compiler threads (provided by -XX:CICompilerCount=)
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.*;
--- a/hotspot/test/compiler/startup/SmallCodeCacheStartup.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/startup/SmallCodeCacheStartup.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* to initialize all compiler threads. The option -Xcomp gives the VM more time to
* trigger the old bug.
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.*;
import static com.oracle.java.testlibrary.Asserts.assertTrue;
--- a/hotspot/test/compiler/startup/StartupOutput.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/startup/StartupOutput.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8026949
* @summary Test ensures correct VM output during startup
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.*;
--- a/hotspot/test/compiler/tiered/ConstantGettersTransitionsTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/tiered/ConstantGettersTransitionsTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
/**
* @test ConstantGettersTransitionsTest
* @library /testlibrary /../../test/lib /compiler/whitebox
+ * @modules java.base/sun.misc
+ * java.management
* @build TransitionsTestExecutor ConstantGettersTransitionsTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main/othervm/timeout=240 -Xmixed -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
--- a/hotspot/test/compiler/tiered/LevelTransitionTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/tiered/LevelTransitionTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,8 @@
/**
* @test LevelTransitionTest
* @library /testlibrary /../../test/lib /compiler/whitebox
+ * @modules java.base/sun.misc
+ * java.management
* @ignore 8067651
* @build TransitionsTestExecutor LevelTransitionTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/tiered/NonTieredLevelsTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/tiered/NonTieredLevelsTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
/**
* @test NonTieredLevelsTest
* @library /testlibrary /../../test/lib /compiler/whitebox
+ * @modules java.management
* @build NonTieredLevelsTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/tiered/TieredLevelsTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/tiered/TieredLevelsTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
/**
* @test TieredLevelsTest
* @library /testlibrary /../../test/lib /compiler/whitebox
+ * @modules java.management
* @build TieredLevelsTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/types/correctness/CorrectnessTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/types/correctness/CorrectnessTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test CorrectnessTest
* @bug 8038418
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @ignore 8066173
* @compile execution/TypeConflict.java execution/TypeProfile.java
* execution/MethodHandleDelegate.java
--- a/hotspot/test/compiler/types/correctness/OffTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/types/correctness/OffTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test CorrectnessTest
* @bug 8038418
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @ignore 8066173
* @compile execution/TypeConflict.java execution/TypeProfile.java
* execution/MethodHandleDelegate.java
--- a/hotspot/test/compiler/uncommontrap/TestUnstableIfTrap.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/uncommontrap/TestUnstableIfTrap.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -41,6 +41,11 @@
* @test
* @bug 8030976 8059226
* @library /testlibrary /compiler/testlibrary /../../test/lib
+ * @modules java.base/jdk.internal.org.objectweb.asm
+ * java.base/sun.misc
+ * java.compiler
+ * java.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @build TestUnstableIfTrap com.oracle.java.testlibrary.* uncommontrap.Verifier
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/unsafe/GetUnsafeObjectG1PreBarrier.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/unsafe/GetUnsafeObjectG1PreBarrier.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
* @test
* @bug 8016474
* @summary The bug only happens with C1 and G1 using a different ObjectAlignmentInBytes than KlassAlignmentInBytes (which is 8)
+ * @modules java.base/sun.misc
* @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=32 GetUnsafeObjectG1PreBarrier
*/
--- a/hotspot/test/compiler/unsafe/UnsafeRaw.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/unsafe/UnsafeRaw.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8058744
* @summary Invalid pattern-matching of address computations in raw unsafe
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main/othervm -Xbatch UnsafeRaw
*/
--- a/hotspot/test/compiler/whitebox/AllocationCodeBlobTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/whitebox/AllocationCodeBlobTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -35,6 +35,7 @@
* @test AllocationCodeBlobTest
* @bug 8059624 8064669
* @library /testlibrary /../../test/lib
+ * @modules java.management
* @build AllocationCodeBlobTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/whitebox/ClearMethodStateTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/whitebox/ClearMethodStateTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
* @test ClearMethodStateTest
* @bug 8006683 8007288 8022832
* @library /testlibrary /../../test/lib
+ * @modules java.management
* @build ClearMethodStateTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/whitebox/DeoptimizeAllTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/whitebox/DeoptimizeAllTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
* @test DeoptimizeAllTest
* @bug 8006683 8007288 8022832
* @library /testlibrary /../../test/lib
+ * @modules java.management
* @build DeoptimizeAllTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/whitebox/DeoptimizeFramesTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/whitebox/DeoptimizeFramesTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
* @test DeoptimizeFramesTest
* @bug 8028595
* @library /testlibrary /../../test/lib
+ * @modules java.management
* @build DeoptimizeFramesTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/whitebox/DeoptimizeMethodTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/whitebox/DeoptimizeMethodTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
* @test DeoptimizeMethodTest
* @bug 8006683 8007288 8022832
* @library /testlibrary /../../test/lib
+ * @modules java.management
* @build DeoptimizeMethodTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/whitebox/DeoptimizeMultipleOSRTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/whitebox/DeoptimizeMultipleOSRTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,7 @@
* @test DeoptimizeMultipleOSRTest
* @bug 8061817
* @library /testlibrary /../../test/lib
+ * @modules java.management
* @build DeoptimizeMultipleOSRTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/whitebox/EnqueueMethodForCompilationTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/whitebox/EnqueueMethodForCompilationTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
* @test EnqueueMethodForCompilationTest
* @bug 8006683 8007288 8022832
* @library /testlibrary /../../test/lib
+ * @modules java.management
* @build EnqueueMethodForCompilationTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/whitebox/ForceNMethodSweepTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/whitebox/ForceNMethodSweepTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -35,6 +35,7 @@
* @test
* @bug 8059624 8064669
* @library /testlibrary /../../test/lib
+ * @modules java.management
* @build ForceNMethodSweepTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/whitebox/GetCodeHeapEntriesTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/whitebox/GetCodeHeapEntriesTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -34,6 +34,7 @@
* @test GetCodeHeapEntriesTest
* @bug 8059624
* @library /testlibrary /../../test/lib
+ * @modules java.management
* @build GetCodeHeapEntriesTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/whitebox/GetNMethodTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/whitebox/GetNMethodTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,7 @@
* @test GetNMethodTest
* @bug 8038240
* @library /testlibrary /../../test/lib
+ * @modules java.management
* @build GetNMethodTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/whitebox/IsMethodCompilableTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/whitebox/IsMethodCompilableTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test IsMethodCompilableTest
* @bug 8007270 8006683 8007288 8022832
* @library /testlibrary /../../test/lib /testlibrary/com/oracle/java/testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build IsMethodCompilableTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/whitebox/LockCompilationTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/whitebox/LockCompilationTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
* @test LockCompilationTest
* @bug 8059624
* @library /testlibrary /../../test/lib
+ * @modules java.management
* @build LockCompilationTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/whitebox/MakeMethodNotCompilableTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/whitebox/MakeMethodNotCompilableTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
* @test MakeMethodNotCompilableTest
* @bug 8012322 8006683 8007288 8022832
* @library /testlibrary /../../test/lib
+ * @modules java.management
* @build MakeMethodNotCompilableTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/whitebox/SetDontInlineMethodTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/whitebox/SetDontInlineMethodTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
* @test SetDontInlineMethodTest
* @bug 8006683 8007288 8022832
* @library /testlibrary /../../test/lib
+ * @modules java.management
* @build SetDontInlineMethodTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/compiler/whitebox/SetForceInlineMethodTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/compiler/whitebox/SetForceInlineMethodTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
* @test SetForceInlineMethodTest
* @bug 8006683 8007288 8022832
* @library /testlibrary /../../test/lib
+ * @modules java.management
* @build SetForceInlineMethodTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/gc/6581734/Test6581734.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/6581734/Test6581734.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
* @bug 6581734
* @requires vm.gc=="ConcMarkSweep" | vm.gc=="null"
* @summary CMS Old Gen's collection usage is zero after GC which is incorrect
+ * @modules java.management
* @run main/othervm -Xmx512m -verbose:gc -XX:+UseConcMarkSweepGC Test6581734
*
*/
--- a/hotspot/test/gc/6941923/Test6941923.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/6941923/Test6941923.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 6941923
* @summary test flags for gc log rotation
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main/othervm/timeout=600 Test6941923
*
*/
--- a/hotspot/test/gc/7072527/TestFullGCCount.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/7072527/TestFullGCCount.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
* @test TestFullGCount.java
* @bug 7072527
* @summary CMS: JMM GC counters overcount in some cases
+ * @modules java.management
* @run main/othervm -XX:+PrintGC TestFullGCCount
*/
import java.util.*;
--- a/hotspot/test/gc/TestCardTablePageCommits.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/TestCardTablePageCommits.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,8 @@
* @bug 8059066
* @summary Tests that the card table does not commit the same page twice
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run driver TestCardTablePageCommits
*/
public class TestCardTablePageCommits {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/gc/TestDisableExplicitGC.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test TestDisableExplicitGC
+ * @requires vm.opt.DisableExplicitGC == null
+ * @summary Verify GC behavior with DisableExplicitGC flag.
+ * @library /testlibrary
+ * @run main/othervm -XX:+PrintGCDetails TestDisableExplicitGC
+ * @run main/othervm/fail -XX:+DisableExplicitGC -XX:+PrintGCDetails TestDisableExplicitGC
+ * @run main/othervm -XX:-DisableExplicitGC -XX:+PrintGCDetails TestDisableExplicitGC
+ */
+import java.lang.management.GarbageCollectorMXBean;
+import java.util.List;
+import static com.oracle.java.testlibrary.Asserts.*;
+
+public class TestDisableExplicitGC {
+
+ public static void main(String[] args) throws InterruptedException {
+ List<GarbageCollectorMXBean> list = java.lang.management.ManagementFactory.getGarbageCollectorMXBeans();
+ long collectionCountBefore = getCollectionCount(list);
+ System.gc();
+ long collectionCountAfter = getCollectionCount(list);
+ assertLT(collectionCountBefore, collectionCountAfter);
+ }
+
+ private static long getCollectionCount(List<GarbageCollectorMXBean> list) {
+ int collectionCount = 0;
+ for (GarbageCollectorMXBean gcMXBean : list) {
+ collectionCount += gcMXBean.getCollectionCount();
+ }
+ return collectionCount;
+ }
+}
--- a/hotspot/test/gc/TestGCLogRotationViaJcmd.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/TestGCLogRotationViaJcmd.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 7090324
* @summary test for gc log rotation via jcmd
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main/othervm -Xloggc:test.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=3 TestGCLogRotationViaJcmd
*
*/
--- a/hotspot/test/gc/TestObjectAlignment.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/TestObjectAlignment.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8021823
* @summary G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main/othervm TestObjectAlignment -Xmx20M -XX:+ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=8
* @run main/othervm TestObjectAlignment -Xmx20M -XX:+ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=16
* @run main/othervm TestObjectAlignment -Xmx20M -XX:+ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=32
--- a/hotspot/test/gc/TestSmallHeap.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/TestSmallHeap.java Tue Apr 14 12:10:00 2015 -0700
@@ -29,6 +29,7 @@
* @requires vm.compMode != "Xcomp"
* @summary Verify that starting the VM with a small heap works
* @library /testlibrary /../../test/lib
+ * @modules java.management/sun.management
* @build TestSmallHeap
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xmx2m -XX:+UseParallelGC TestSmallHeap
--- a/hotspot/test/gc/TestSoftReferencesBehaviorOnOOME.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/TestSoftReferencesBehaviorOnOOME.java Tue Apr 14 12:10:00 2015 -0700
@@ -26,6 +26,8 @@
* @key gc
* @summary Tests that all SoftReferences has been cleared at time of OOM.
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @ignore 8073669
* @build TestSoftReferencesBehaviorOnOOME
* @run main/othervm -Xmx128m TestSoftReferencesBehaviorOnOOME 512 2k
--- a/hotspot/test/gc/TestVerifyDuringStartup.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/TestVerifyDuringStartup.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8010463 8011343 8011898
* @summary Simple test run with -XX:+VerifyDuringStartup -XX:-UseTLAB to verify 8010463
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.JDKToolFinder;
--- a/hotspot/test/gc/TestVerifySilently.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/TestVerifySilently.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8032771
* @summary Test silent verification.
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.OutputAnalyzer;
--- a/hotspot/test/gc/arguments/TestArrayAllocatorMallocLimit.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/arguments/TestArrayAllocatorMallocLimit.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @bug 8054823
* @key gc
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run driver TestArrayAllocatorMallocLimit
*/
--- a/hotspot/test/gc/arguments/TestCMSHeapSizeFlags.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/arguments/TestCMSHeapSizeFlags.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8006088
* @summary Tests argument processing for initial and maximum heap size for the CMS collector
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build TestCMSHeapSizeFlags TestMaxHeapSizeTools
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/gc/arguments/TestCompressedClassFlags.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/arguments/TestCompressedClassFlags.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,8 @@
* @summary Tests that VM prints a warning when -XX:CompressedClassSpaceSize
* is used together with -XX:-UseCompressedClassPointers
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
public class TestCompressedClassFlags {
public static void main(String[] args) throws Exception {
--- a/hotspot/test/gc/arguments/TestDynMaxHeapFreeRatio.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/arguments/TestDynMaxHeapFreeRatio.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@
* @bug 8028391
* @summary Verify that MaxHeapFreeRatio flag is manageable
* @library /testlibrary
+ * @modules java.management
* @run main TestDynMaxHeapFreeRatio
* @run main/othervm -XX:MinHeapFreeRatio=0 -XX:MaxHeapFreeRatio=100 TestDynMaxHeapFreeRatio
* @run main/othervm -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=50 -XX:-UseAdaptiveSizePolicy TestDynMaxHeapFreeRatio
--- a/hotspot/test/gc/arguments/TestDynMinHeapFreeRatio.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/arguments/TestDynMinHeapFreeRatio.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
* @bug 8028391
* @summary Verify that MinHeapFreeRatio flag is manageable
* @library /testlibrary
+ * @modules java.management
* @run main TestDynMinHeapFreeRatio
* @run main/othervm -XX:MinHeapFreeRatio=0 -XX:MaxHeapFreeRatio=100 TestDynMinHeapFreeRatio
* @run main/othervm -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=50 -XX:-UseAdaptiveSizePolicy TestDynMinHeapFreeRatio
--- a/hotspot/test/gc/arguments/TestG1ConcRefinementThreads.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/arguments/TestG1ConcRefinementThreads.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8047976
* @summary Tests argument processing for G1ConcRefinementThreads
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.*;
--- a/hotspot/test/gc/arguments/TestG1HeapRegionSize.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/arguments/TestG1HeapRegionSize.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
* @key gc
* @bug 8021879
* @summary Verify that the flag G1HeapRegionSize is updated properly
+ * @modules java.management/sun.management
* @run main/othervm -Xmx64m TestG1HeapRegionSize 1048576
* @run main/othervm -XX:G1HeapRegionSize=2m -Xmx64m TestG1HeapRegionSize 2097152
* @run main/othervm -XX:G1HeapRegionSize=3m -Xmx64m TestG1HeapRegionSize 2097152
--- a/hotspot/test/gc/arguments/TestG1HeapSizeFlags.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/arguments/TestG1HeapSizeFlags.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8006088
* @summary Tests argument processing for initial and maximum heap size for the G1 collector
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build TestG1HeapSizeFlags TestMaxHeapSizeTools
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/gc/arguments/TestG1PercentageOptions.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/arguments/TestG1PercentageOptions.java Tue Apr 14 12:10:00 2015 -0700
@@ -27,6 +27,8 @@
* @bug 8068942
* @summary Test argument processing of various percentage options
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run driver TestG1PercentageOptions
*/
--- a/hotspot/test/gc/arguments/TestHeapFreeRatio.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/arguments/TestHeapFreeRatio.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8025661
* @summary Test parsing of -Xminf and -Xmaxf
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main/othervm TestHeapFreeRatio
*/
--- a/hotspot/test/gc/arguments/TestInitialTenuringThreshold.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/arguments/TestInitialTenuringThreshold.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8014765
* @summary Tests argument processing for initial tenuring threshold
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main/othervm TestInitialTenuringThreshold
* @author thomas.schatzl@oracle.com
*/
@@ -72,4 +74,4 @@
runWithThresholds(16, 8, true);
runWithThresholds(8, 17, true);
}
-}
\ No newline at end of file
+}
--- a/hotspot/test/gc/arguments/TestMaxNewSize.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/arguments/TestMaxNewSize.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Make sure that MaxNewSize always has a useful value after argument
* processing.
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestMaxNewSize
* @run main TestMaxNewSize -XX:+UseSerialGC
* @run main TestMaxNewSize -XX:+UseParallelGC
--- a/hotspot/test/gc/arguments/TestMinInitialErgonomics.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/arguments/TestMinInitialErgonomics.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8006088
* @summary Test ergonomics decisions related to minimum and initial heap size.
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build TestMinInitialErgonomics TestMaxHeapSizeTools
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/gc/arguments/TestObjectTenuringFlags.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/arguments/TestObjectTenuringFlags.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Tests argument processing for NeverTenure, AlwaysTenure,
* and MaxTenuringThreshold
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestObjectTenuringFlags FlagsValue
* @run main/othervm TestObjectTenuringFlags
*/
--- a/hotspot/test/gc/arguments/TestParallelGCThreads.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/arguments/TestParallelGCThreads.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8059527
* @summary Tests argument processing for ParallelGCThreads
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run driver TestParallelGCThreads
*/
--- a/hotspot/test/gc/arguments/TestParallelHeapSizeFlags.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/arguments/TestParallelHeapSizeFlags.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @summary Tests argument processing for initial and maximum heap size for the
* parallel collectors.
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build TestParallelHeapSizeFlags TestMaxHeapSizeTools
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/gc/arguments/TestSerialHeapSizeFlags.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/arguments/TestSerialHeapSizeFlags.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8006088
* @summary Tests argument processing for initial and maximum heap size for the Serial collector
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build TestSerialHeapSizeFlags TestMaxHeapSizeTools
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/gc/arguments/TestSurvivorAlignmentInBytesOption.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/arguments/TestSurvivorAlignmentInBytesOption.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -34,6 +34,8 @@
* & vm.opt.UnlockExperimentalVMOptions == null
* & (vm.opt.IgnoreUnrecognizedVMOptions == null
* | vm.opt.IgnoreUnrecognizedVMOptions == "false")
+ * @modules java.base/sun.misc
+ * java.management
* @run main TestSurvivorAlignmentInBytesOption
*/
public class TestSurvivorAlignmentInBytesOption {
--- a/hotspot/test/gc/arguments/TestUnrecognizedVMOptionsHandling.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/arguments/TestUnrecognizedVMOptionsHandling.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8017611
* @summary Tests handling unrecognized VM options
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main/othervm TestUnrecognizedVMOptionsHandling
*/
--- a/hotspot/test/gc/arguments/TestUseCompressedOopsErgo.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/arguments/TestUseCompressedOopsErgo.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013, 2014 Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8010722
* @summary Tests ergonomics for UseCompressedOops.
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management/sun.management
* @build TestUseCompressedOopsErgo TestUseCompressedOopsErgoTools
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/gc/arguments/TestUseNUMAInterleaving.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/arguments/TestUseNUMAInterleaving.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @bug 8059614
* @key gc
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run driver TestUseNUMAInterleaving
*/
import com.oracle.java.testlibrary.ProcessTools;
--- a/hotspot/test/gc/class_unloading/TestCMSClassUnloadingEnabledHWM.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/class_unloading/TestCMSClassUnloadingEnabledHWM.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @key gc
* @bug 8049831
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build TestCMSClassUnloadingEnabledHWM
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/gc/class_unloading/TestG1ClassUnloadingHWM.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/class_unloading/TestG1ClassUnloadingHWM.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @key gc
* @bug 8049831
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build TestG1ClassUnloadingHWM
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/gc/concurrentMarkSweep/GuardShrinkWarning.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/concurrentMarkSweep/GuardShrinkWarning.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @key gc
* @key regression
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main/othervm GuardShrinkWarning
* @author jon.masamitsu@oracle.com
*/
--- a/hotspot/test/gc/defnew/HeapChangeLogging.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/defnew/HeapChangeLogging.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test HeapChangeLogging.java
* @bug 8027440
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build HeapChangeLogging
* @summary Allocate to get a promotion failure and verify that that heap change logging is present.
* @run main HeapChangeLogging
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/gc/ergonomics/TestDynamicNumberOfGCThreads.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test TestDynamicNumberOfGCThreads
+ * @bug 8017462
+ * @summary Ensure that UseDynamicNumberOfGCThreads runs
+ * @requires vm.gc=="null"
+ * @key gc
+ * @library /testlibrary
+ */
+
+import com.oracle.java.testlibrary.ProcessTools;
+import com.oracle.java.testlibrary.OutputAnalyzer;
+
+public class TestDynamicNumberOfGCThreads {
+ public static void main(String[] args) throws Exception {
+
+ testDynamicNumberOfGCThreads("UseConcMarkSweepGC");
+
+ testDynamicNumberOfGCThreads("UseG1GC");
+
+ testDynamicNumberOfGCThreads("UseParallelGC");
+ }
+
+ private static void verifyDynamicNumberOfGCThreads(OutputAnalyzer output) {
+ output.shouldContain("new_active_workers");
+ output.shouldHaveExitValue(0);
+ }
+
+ private static void testDynamicNumberOfGCThreads(String gcFlag) throws Exception {
+ // UseDynamicNumberOfGCThreads and TraceDynamicGCThreads enabled
+ ProcessBuilder pb_enabled =
+ ProcessTools.createJavaProcessBuilder("-XX:+" + gcFlag, "-Xmx10M", "-XX:+PrintGCDetails", "-XX:+UseDynamicNumberOfGCThreads", "-XX:+TraceDynamicGCThreads", GCTest.class.getName());
+ verifyDynamicNumberOfGCThreads(new OutputAnalyzer(pb_enabled.start()));
+ }
+
+ static class GCTest {
+ private static byte[] garbage;
+ public static void main(String [] args) {
+ System.out.println("Creating garbage");
+ // create 128MB of garbage. This should result in at least one GC
+ for (int i = 0; i < 1024; i++) {
+ garbage = new byte[128 * 1024];
+ }
+ System.out.println("Done");
+ }
+ }
+}
--- a/hotspot/test/gc/g1/Test2GbHeap.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/g1/Test2GbHeap.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @key gc
* @key regression
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import java.util.ArrayList;
--- a/hotspot/test/gc/g1/TestEagerReclaimHumongousRegions.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/g1/TestEagerReclaimHumongousRegions.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* up the heap with humongous objects that should be eagerly reclaimable to avoid Full GC.
* @key gc
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import java.util.regex.Pattern;
--- a/hotspot/test/gc/g1/TestEagerReclaimHumongousRegionsClearMarkBits.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/g1/TestEagerReclaimHumongousRegionsClearMarkBits.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* mark bitmaps at reclaim.
* @key gc
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import java.util.ArrayList;
--- a/hotspot/test/gc/g1/TestEagerReclaimHumongousRegionsWithRefs.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/g1/TestEagerReclaimHumongousRegionsWithRefs.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,8 @@
* should still be eagerly reclaimable to avoid Full GC.
* @key gc
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import java.util.regex.Pattern;
--- a/hotspot/test/gc/g1/TestG1TraceEagerReclaimHumongousObjects.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/g1/TestG1TraceEagerReclaimHumongousObjects.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* includes the expected necessary messages.
* @key gc
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.ProcessTools;
--- a/hotspot/test/gc/g1/TestGCLogMessages.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/g1/TestGCLogMessages.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,142 +23,172 @@
/*
* @test TestGCLogMessages
- * @bug 8035406 8027295 8035398 8019342 8027959 8048179
+ * @bug 8035406 8027295 8035398 8019342 8027959 8048179 8027962
* @summary Ensure that the PrintGCDetails output for a minor GC with G1
* includes the expected necessary messages.
* @key gc
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.ProcessTools;
import com.oracle.java.testlibrary.OutputAnalyzer;
public class TestGCLogMessages {
- public static void main(String[] args) throws Exception {
- testNormalLogs();
- testWithToSpaceExhaustionLogs();
- }
- private static void testNormalLogs() throws Exception {
-
- ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
- "-Xmx10M",
- GCTest.class.getName());
+ private enum Level {
+ OFF, FINER, FINEST;
+ public boolean lessOrEqualTo(Level other) {
+ return this.compareTo(other) < 0;
+ }
+ }
- OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ private class LogMessageWithLevel {
+ String message;
+ Level level;
- output.shouldNotContain("[Redirty Cards");
- output.shouldNotContain("[Parallel Redirty");
- output.shouldNotContain("[Redirtied Cards");
- output.shouldNotContain("[Code Root Purge");
- output.shouldNotContain("[String Dedup Fixup");
- output.shouldNotContain("[Young Free CSet");
- output.shouldNotContain("[Non-Young Free CSet");
- output.shouldNotContain("[Humongous Register");
- output.shouldNotContain("[Humongous Reclaim");
- output.shouldHaveExitValue(0);
+ public LogMessageWithLevel(String message, Level level) {
+ this.message = message;
+ this.level = level;
+ }
+ };
- pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
- "-XX:+UseStringDeduplication",
- "-Xmx10M",
- "-XX:+PrintGCDetails",
- GCTest.class.getName());
-
- output = new OutputAnalyzer(pb.start());
+ private LogMessageWithLevel allLogMessages[] = new LogMessageWithLevel[] {
+ // Ext Root Scan
+ new LogMessageWithLevel("Thread Roots (ms)", Level.FINEST),
+ new LogMessageWithLevel("StringTable Roots (ms)", Level.FINEST),
+ new LogMessageWithLevel("Universe Roots (ms)", Level.FINEST),
+ new LogMessageWithLevel("JNI Handles Roots (ms)", Level.FINEST),
+ new LogMessageWithLevel("ObjectSynchronizer Roots (ms)", Level.FINEST),
+ new LogMessageWithLevel("FlatProfiler Roots", Level.FINEST),
+ new LogMessageWithLevel("Management Roots", Level.FINEST),
+ new LogMessageWithLevel("SystemDictionary Roots", Level.FINEST),
+ new LogMessageWithLevel("CLDG Roots", Level.FINEST),
+ new LogMessageWithLevel("JVMTI Roots", Level.FINEST),
+ new LogMessageWithLevel("CodeCache Roots", Level.FINEST),
+ new LogMessageWithLevel("SATB Filtering", Level.FINEST),
+ new LogMessageWithLevel("CM RefProcessor Roots", Level.FINEST),
+ new LogMessageWithLevel("Wait For Strong CLD", Level.FINEST),
+ new LogMessageWithLevel("Weak CLD Roots", Level.FINEST),
+ // Redirty Cards
+ new LogMessageWithLevel("Redirty Cards", Level.FINER),
+ new LogMessageWithLevel("Parallel Redirty", Level.FINEST),
+ new LogMessageWithLevel("Redirtied Cards", Level.FINEST),
+ // Misc Top-level
+ new LogMessageWithLevel("Code Root Purge", Level.FINER),
+ new LogMessageWithLevel("String Dedup Fixup", Level.FINER),
+ // Free CSet
+ new LogMessageWithLevel("Young Free CSet", Level.FINEST),
+ new LogMessageWithLevel("Non-Young Free CSet", Level.FINEST),
+ // Humongous Eager Reclaim
+ new LogMessageWithLevel("Humongous Reclaim", Level.FINER),
+ new LogMessageWithLevel("Humongous Register", Level.FINER),
+ };
- output.shouldContain("[Redirty Cards");
- output.shouldNotContain("[Parallel Redirty");
- output.shouldNotContain("[Redirtied Cards");
- output.shouldContain("[Code Root Purge");
- output.shouldContain("[String Dedup Fixup");
- output.shouldNotContain("[Young Free CSet");
- output.shouldNotContain("[Non-Young Free CSet");
- output.shouldContain("[Humongous Register");
- output.shouldNotContain("[Humongous Total");
- output.shouldNotContain("[Humongous Candidate");
- output.shouldContain("[Humongous Reclaim");
- output.shouldNotContain("[Humongous Reclaimed");
- output.shouldHaveExitValue(0);
+ void checkMessagesAtLevel(OutputAnalyzer output, LogMessageWithLevel messages[], Level level) throws Exception {
+ for (LogMessageWithLevel l : messages) {
+ if (level.lessOrEqualTo(l.level)) {
+ output.shouldNotContain(l.message);
+ } else {
+ output.shouldContain(l.message);
+ }
+ }
+ }
- pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
- "-XX:+UseStringDeduplication",
- "-Xmx10M",
- "-XX:+PrintGCDetails",
- "-XX:+UnlockExperimentalVMOptions",
- "-XX:G1LogLevel=finest",
- GCTest.class.getName());
+ public static void main(String[] args) throws Exception {
+ new TestGCLogMessages().testNormalLogs();
+ new TestGCLogMessages().testWithToSpaceExhaustionLogs();
+ }
+
+ private void testNormalLogs() throws Exception {
- output = new OutputAnalyzer(pb.start());
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
+ "-Xmx10M",
+ GCTest.class.getName());
+
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ checkMessagesAtLevel(output, allLogMessages, Level.OFF);
+ output.shouldHaveExitValue(0);
- output.shouldContain("[Redirty Cards");
- output.shouldContain("[Parallel Redirty");
- output.shouldContain("[Redirtied Cards");
- output.shouldContain("[Code Root Purge");
- output.shouldContain("[String Dedup Fixup");
- output.shouldContain("[Young Free CSet");
- output.shouldContain("[Non-Young Free CSet");
- output.shouldContain("[Humongous Register");
- output.shouldContain("[Humongous Total");
- output.shouldContain("[Humongous Candidate");
- output.shouldContain("[Humongous Reclaim");
- output.shouldContain("[Humongous Reclaimed");
- output.shouldHaveExitValue(0);
- }
+ pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
+ "-XX:+UseStringDeduplication",
+ "-Xmx10M",
+ "-XX:+PrintGCDetails",
+ GCTest.class.getName());
+
+ output = new OutputAnalyzer(pb.start());
+ checkMessagesAtLevel(output, allLogMessages, Level.FINER);
+
+ pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
+ "-XX:+UseStringDeduplication",
+ "-Xmx10M",
+ "-XX:+PrintGCDetails",
+ "-XX:+UnlockExperimentalVMOptions",
+ "-XX:G1LogLevel=finest",
+ GCTest.class.getName());
- private static void testWithToSpaceExhaustionLogs() throws Exception {
- ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
- "-Xmx32M",
- "-Xmn16M",
- "-XX:+PrintGCDetails",
- GCTestWithToSpaceExhaustion.class.getName());
+ output = new OutputAnalyzer(pb.start());
+ checkMessagesAtLevel(output, allLogMessages, Level.FINEST);
+ output.shouldHaveExitValue(0);
+ }
- OutputAnalyzer output = new OutputAnalyzer(pb.start());
- output.shouldContain("[Evacuation Failure");
- output.shouldNotContain("[Recalculate Used");
- output.shouldNotContain("[Remove Self Forwards");
- output.shouldNotContain("[Restore RemSet");
- output.shouldHaveExitValue(0);
+ LogMessageWithLevel exhFailureMessages[] = new LogMessageWithLevel[] {
+ new LogMessageWithLevel("Evacuation Failure", Level.FINER),
+ new LogMessageWithLevel("Recalculate Used", Level.FINEST),
+ new LogMessageWithLevel("Remove Self Forwards", Level.FINEST),
+ new LogMessageWithLevel("Restore RemSet", Level.FINEST),
+ };
+
+ private void testWithToSpaceExhaustionLogs() throws Exception {
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
+ "-Xmx32M",
+ "-Xmn16M",
+ "-XX:+PrintGCDetails",
+ GCTestWithToSpaceExhaustion.class.getName());
+
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ checkMessagesAtLevel(output, exhFailureMessages, Level.FINER);
+ output.shouldHaveExitValue(0);
- pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
- "-Xmx32M",
- "-Xmn16M",
- "-XX:+PrintGCDetails",
- "-XX:+UnlockExperimentalVMOptions",
- "-XX:G1LogLevel=finest",
- GCTestWithToSpaceExhaustion.class.getName());
+ pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
+ "-Xmx32M",
+ "-Xmn16M",
+ "-XX:+PrintGCDetails",
+ "-XX:+UnlockExperimentalVMOptions",
+ "-XX:G1LogLevel=finest",
+ GCTestWithToSpaceExhaustion.class.getName());
- output = new OutputAnalyzer(pb.start());
- output.shouldContain("[Evacuation Failure");
- output.shouldContain("[Recalculate Used");
- output.shouldContain("[Remove Self Forwards");
- output.shouldContain("[Restore RemSet");
- output.shouldHaveExitValue(0);
- }
+ output = new OutputAnalyzer(pb.start());
+ checkMessagesAtLevel(output, exhFailureMessages, Level.FINEST);
+ output.shouldHaveExitValue(0);
+ }
- static class GCTest {
- private static byte[] garbage;
- public static void main(String [] args) {
- System.out.println("Creating garbage");
- // create 128MB of garbage. This should result in at least one GC
- for (int i = 0; i < 1024; i++) {
- garbage = new byte[128 * 1024];
- }
- System.out.println("Done");
+ static class GCTest {
+ private static byte[] garbage;
+ public static void main(String [] args) {
+ System.out.println("Creating garbage");
+ // create 128MB of garbage. This should result in at least one GC
+ for (int i = 0; i < 1024; i++) {
+ garbage = new byte[128 * 1024];
+ }
+ System.out.println("Done");
+ }
}
- }
- static class GCTestWithToSpaceExhaustion {
- private static byte[] garbage;
- private static byte[] largeObject;
- public static void main(String [] args) {
- largeObject = new byte[16*1024*1024];
- System.out.println("Creating garbage");
- // create 128MB of garbage. This should result in at least one GC,
- // some of them with to-space exhaustion.
- for (int i = 0; i < 1024; i++) {
- garbage = new byte[128 * 1024];
- }
- System.out.println("Done");
+ static class GCTestWithToSpaceExhaustion {
+ private static byte[] garbage;
+ private static byte[] largeObject;
+ public static void main(String [] args) {
+ largeObject = new byte[16*1024*1024];
+ System.out.println("Creating garbage");
+ // create 128MB of garbage. This should result in at least one GC,
+ // some of them with to-space exhaustion.
+ for (int i = 0; i < 1024; i++) {
+ garbage = new byte[128 * 1024];
+ }
+ System.out.println("Done");
+ }
}
- }
}
+
--- a/hotspot/test/gc/g1/TestHumongousAllocInitialMark.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/g1/TestHumongousAllocInitialMark.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 7168848
* @summary G1: humongous object allocations should initiate marking cycles when necessary
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.*;
--- a/hotspot/test/gc/g1/TestHumongousCodeCacheRoots.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/g1/TestHumongousCodeCacheRoots.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @key gc
* @bug 8027756
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build TestHumongousCodeCacheRoots
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/gc/g1/TestHumongousShrinkHeap.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/g1/TestHumongousShrinkHeap.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,7 @@
* @summary Verify that heap shrinks after GC in the presence of fragmentation
* due to humongous objects
* @library /testlibrary
+ * @modules java.management/sun.management
* @run main/othervm -XX:-ExplicitGCInvokesConcurrent -XX:MinHeapFreeRatio=10
* -XX:MaxHeapFreeRatio=12 -XX:+UseG1GC -XX:G1HeapRegionSize=1M -verbose:gc
* TestHumongousShrinkHeap
--- a/hotspot/test/gc/g1/TestPrintGCDetails.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/g1/TestPrintGCDetails.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @key gc
* @key regression
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.ProcessTools;
--- a/hotspot/test/gc/g1/TestPrintRegionRememberedSetInfo.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/g1/TestPrintRegionRememberedSetInfo.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8014240
* @summary Test output of G1PrintRegionRememberedSetInfo
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main TestPrintRegionRememberedSetInfo
* @author thomas.schatzl@oracle.com
*/
--- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -21,7 +21,7 @@
* questions.
*/
-import static com.oracle.java.testlibrary.Asserts.assertLessThanOrEqual;
+import com.oracle.java.testlibrary.Asserts;
import com.oracle.java.testlibrary.OutputAnalyzer;
import com.oracle.java.testlibrary.Platform;
import com.oracle.java.testlibrary.ProcessTools;
@@ -36,23 +36,29 @@
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
-import sun.misc.Unsafe;
+import sun.misc.Unsafe; // for ADDRESS_SIZE
+import sun.hotspot.WhiteBox;
public class TestShrinkAuxiliaryData {
+ private static final int REGION_SIZE = 1024 * 1024;
+
private final static String[] initialOpts = new String[]{
"-XX:MinHeapFreeRatio=10",
"-XX:MaxHeapFreeRatio=11",
"-XX:+UseG1GC",
- "-XX:G1HeapRegionSize=1m",
+ "-XX:G1HeapRegionSize=" + REGION_SIZE,
"-XX:-ExplicitGCInvokesConcurrent",
- "-XX:+PrintGCDetails"
+ "-XX:+PrintGCDetails",
+ "-XX:+UnlockDiagnosticVMOptions",
+ "-XX:+WhiteBoxAPI",
+ "-Xbootclasspath/a:.",
};
- private final int RSetCacheSize;
+ private final int hotCardTableSize;
- protected TestShrinkAuxiliaryData(int RSetCacheSize) {
- this.RSetCacheSize = RSetCacheSize;
+ protected TestShrinkAuxiliaryData(int hotCardTableSize) {
+ this.hotCardTableSize = hotCardTableSize;
}
protected void test() throws Exception {
@@ -60,16 +66,16 @@
Collections.addAll(vmOpts, initialOpts);
int maxCacheSize = Math.max(0, Math.min(31, getMaxCacheSize()));
- if (maxCacheSize < RSetCacheSize) {
+ if (maxCacheSize < hotCardTableSize) {
System.out.format("Skiping test for %d cache size due max cache size %d",
- RSetCacheSize, maxCacheSize
+ hotCardTableSize, maxCacheSize
);
return;
}
printTestInfo(maxCacheSize);
- vmOpts.add("-XX:G1ConcRSLogCacheSize=" + RSetCacheSize);
+ vmOpts.add("-XX:G1ConcRSLogCacheSize=" + hotCardTableSize);
vmOpts.addAll(Arrays.asList(Utils.getTestJavaOpts()));
// for 32 bits ObjectAlignmentInBytes is not a option
@@ -92,11 +98,13 @@
private void performTest(List<String> opts) throws Exception {
ProcessBuilder pb
- = ProcessTools.createJavaProcessBuilder(
- opts.toArray(new String[opts.size()])
- );
+ = ProcessTools.createJavaProcessBuilder(
+ opts.toArray(new String[opts.size()])
+ );
OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ System.out.println(output.getStdout());
+ System.err.println(output.getStderr());
output.shouldHaveExitValue(0);
}
@@ -107,12 +115,13 @@
formatSymbols.setGroupingSeparator(' ');
grouped.setDecimalFormatSymbols(formatSymbols);
- System.out.format("Test will use %s bytes of memory of %s available%n"
+ System.out.format(
+ "Test will use %s bytes of memory of %s available%n"
+ "Available memory is %s with %d bytes pointer size - can save %s pointers%n"
+ "Max cache size: 2^%d = %s elements%n",
grouped.format(ShrinkAuxiliaryDataTest.getMemoryUsedByTest()),
- grouped.format(Runtime.getRuntime().freeMemory()),
- grouped.format(Runtime.getRuntime().freeMemory()
+ grouped.format(Runtime.getRuntime().maxMemory()),
+ grouped.format(Runtime.getRuntime().maxMemory()
- ShrinkAuxiliaryDataTest.getMemoryUsedByTest()),
Unsafe.ADDRESS_SIZE,
grouped.format((Runtime.getRuntime().freeMemory()
@@ -135,6 +144,7 @@
if (availableMemory <= 0) {
return 0;
}
+
long availablePointersCount = availableMemory / Unsafe.ADDRESS_SIZE;
return (63 - (int) Long.numberOfLeadingZeros(availablePointersCount));
}
@@ -142,17 +152,48 @@
static class ShrinkAuxiliaryDataTest {
public static void main(String[] args) throws IOException {
- int iterateCount = DEFAULT_ITERATION_COUNT;
+
+ ShrinkAuxiliaryDataTest testCase = new ShrinkAuxiliaryDataTest();
- if (args.length > 0) {
- try {
- iterateCount = Integer.parseInt(args[0]);
- } catch (NumberFormatException e) {
- //num_iterate remains default
- }
+ if (!testCase.checkEnvApplicability()) {
+ return;
}
- new ShrinkAuxiliaryDataTest().test(iterateCount);
+ testCase.test();
+ }
+
+ /**
+ * Checks is this environment suitable to run this test
+ * - memory is enough to decommit (page size is not big)
+ * - RSet cache size is not too big
+ *
+ * @return true if test could run, false if test should be skipped
+ */
+ protected boolean checkEnvApplicability() {
+
+ int pageSize = WhiteBox.getWhiteBox().getVMPageSize();
+ System.out.println( "Page size = " + pageSize
+ + " region size = " + REGION_SIZE
+ + " aux data ~= " + (REGION_SIZE * 3 / 100));
+ // If auxdata size will be less than page size it wouldn't decommit.
+ // Auxiliary data size is about ~3.6% of heap size.
+ if (pageSize >= REGION_SIZE * 3 / 100) {
+ System.out.format("Skipping test for too large page size = %d",
+ pageSize
+ );
+ return false;
+ }
+
+ if (REGION_SIZE * REGIONS_TO_ALLOCATE > Runtime.getRuntime().maxMemory()) {
+ System.out.format("Skipping test for too low available memory. "
+ + "Need %d, available %d",
+ REGION_SIZE * REGIONS_TO_ALLOCATE,
+ Runtime.getRuntime().maxMemory()
+ );
+ return false;
+ }
+
+ return true;
}
class GarbageObject {
@@ -177,41 +218,54 @@
private final List<GarbageObject> garbage = new ArrayList();
- public void test(int num_iterate) throws IOException {
+ public void test() throws IOException {
+
+ MemoryUsage muFull, muFree, muAuxDataFull, muAuxDataFree;
+ float auxFull, auxFree;
allocate();
link();
mutate();
- deallocate();
+
+ muFull = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
+ long numUsedRegions = WhiteBox.getWhiteBox().g1NumMaxRegions()
+ - WhiteBox.getWhiteBox().g1NumFreeRegions();
+ muAuxDataFull = WhiteBox.getWhiteBox().g1AuxiliaryMemoryUsage();
+ auxFull = (float)muAuxDataFull.getUsed() / numUsedRegions;
- MemoryUsage muBeforeHeap
- = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
- MemoryUsage muBeforeNonHeap
- = ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage();
+ System.out.format("Full aux data ratio= %f, regions max= %d, used= %d\n",
+ auxFull, WhiteBox.getWhiteBox().g1NumMaxRegions(), numUsedRegions
+ );
+
+ deallocate();
+ System.gc();
- for (int i = 0; i < num_iterate; i++) {
- allocate();
- link();
- mutate();
- deallocate();
- }
+ muFree = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
+ muAuxDataFree = WhiteBox.getWhiteBox().g1AuxiliaryMemoryUsage();
+
+ numUsedRegions = WhiteBox.getWhiteBox().g1NumMaxRegions()
+ - WhiteBox.getWhiteBox().g1NumFreeRegions();
+ auxFree = (float)muAuxDataFree.getUsed() / numUsedRegions;
- System.gc();
- MemoryUsage muAfterHeap
- = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
- MemoryUsage muAfterNonHeap
- = ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage();
+ System.out.format("Free aux data ratio= %f, regions max= %d, used= %d\n",
+ auxFree, WhiteBox.getWhiteBox().g1NumMaxRegions(), numUsedRegions
+ );
- assertLessThanOrEqual(muAfterHeap.getCommitted(), muBeforeHeap.getCommitted(),
- String.format("heap decommit failed - after > before: %d > %d",
- muAfterHeap.getCommitted(), muBeforeHeap.getCommitted()
+ Asserts.assertLessThanOrEqual(muFree.getCommitted(), muFull.getCommitted(),
+ String.format("heap decommit failed - full > free: %d > %d",
+ muFree.getCommitted(), muFull.getCommitted()
)
);
- if (muAfterHeap.getCommitted() < muBeforeHeap.getCommitted()) {
- assertLessThanOrEqual(muAfterNonHeap.getCommitted(), muBeforeNonHeap.getCommitted(),
- String.format("non-heap decommit failed - after > before: %d > %d",
- muAfterNonHeap.getCommitted(), muBeforeNonHeap.getCommitted()
+ System.out.format("State used committed\n");
+ System.out.format("Full aux data: %10d %10d\n", muAuxDataFull.getUsed(), muAuxDataFull.getCommitted());
+ System.out.format("Free aux data: %10d %10d\n", muAuxDataFree.getUsed(), muAuxDataFree.getCommitted());
+
+ // if decommited check that aux data has same ratio
+ if (muFree.getCommitted() < muFull.getCommitted()) {
+ Asserts.assertLessThanOrEqual(auxFree, auxFull,
+ String.format("auxiliary data decommit failed - full > free: %f > %f",
+ auxFree, auxFull
)
);
}
@@ -238,8 +292,7 @@
for (int i = 0; i < NUM_LINKS; i++) {
int regionToLink;
do {
- regionToLink = (int) (Math.random()
- * REGIONS_TO_ALLOCATE);
+ regionToLink = (int) (Math.random() * REGIONS_TO_ALLOCATE);
} while (regionToLink == regionNumber);
// get random garbage object from random region
@@ -265,11 +318,8 @@
return REGIONS_TO_ALLOCATE * REGION_SIZE;
}
- private static final int REGION_SIZE = 1024 * 1024;
- private static final int DEFAULT_ITERATION_COUNT = 1; // iterate main scenario
- private static final int REGIONS_TO_ALLOCATE = 5;
+ private static final int REGIONS_TO_ALLOCATE = 100;
private static final int NUM_OBJECTS_PER_REGION = 10;
private static final int NUM_LINKS = 20; // how many links create for each object
-
}
}
--- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData00.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData00.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,11 +23,17 @@
/**
* @test TestShrinkAuxiliaryData00
- * @bug 8038423
+ * @bug 8038423 8061715
* @summary Checks that decommitment occurs for JVM with different
* G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
+ * @requires vm.gc=="G1" | vm.gc=="null"
* @library /testlibrary /../../test/lib
- * @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData00
+ * @modules java.base/sun.misc
+ * java.management
+ * @build com.oracle.java.testlibrary.* sun.hotspot.WhiteBox
+ * TestShrinkAuxiliaryData TestShrinkAuxiliaryData00
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * sun.hotspot.WhiteBox$WhiteBoxPermission
* @run driver/timeout=720 TestShrinkAuxiliaryData00
*/
public class TestShrinkAuxiliaryData00 {
--- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData05.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData05.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,12 +23,17 @@
/**
* @test TestShrinkAuxiliaryData05
- * @bug 8038423
+ * @bug 8038423 8061715
* @summary Checks that decommitment occurs for JVM with different
* G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
* @requires vm.gc=="G1" | vm.gc=="null"
* @library /testlibrary /../../test/lib
- * @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData05
+ * @modules java.base/sun.misc
+ * java.management
+ * @build com.oracle.java.testlibrary.* sun.hotspot.WhiteBox
+ * TestShrinkAuxiliaryData TestShrinkAuxiliaryData05
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * sun.hotspot.WhiteBox$WhiteBoxPermission
* @run driver/timeout=720 TestShrinkAuxiliaryData05
*/
public class TestShrinkAuxiliaryData05 {
--- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData10.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData10.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,12 +23,17 @@
/**
* @test TestShrinkAuxiliaryData10
- * @bug 8038423
+ * @bug 8038423 8061715
* @summary Checks that decommitment occurs for JVM with different
* G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
* @requires vm.gc=="G1" | vm.gc=="null"
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
+ * @build com.oracle.java.testlibrary.* sun.hotspot.WhiteBox
* @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData10
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * sun.hotspot.WhiteBox$WhiteBoxPermission
* @run driver/timeout=720 TestShrinkAuxiliaryData10
*/
public class TestShrinkAuxiliaryData10 {
--- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData15.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData15.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,12 +23,17 @@
/**
* @test TestShrinkAuxiliaryData15
- * @bug 8038423
+ * @bug 8038423 8061715
* @summary Checks that decommitment occurs for JVM with different
* G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
* @requires vm.gc=="G1" | vm.gc=="null"
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
+ * @build com.oracle.java.testlibrary.* sun.hotspot.WhiteBox
* @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData15
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * sun.hotspot.WhiteBox$WhiteBoxPermission
* @run driver/timeout=720 TestShrinkAuxiliaryData15
*/
public class TestShrinkAuxiliaryData15 {
--- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData20.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData20.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,12 +23,17 @@
/**
* @test TestShrinkAuxiliaryData20
- * @bug 8038423
+ * @bug 8038423 8061715
* @summary Checks that decommitment occurs for JVM with different
* G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
* @requires vm.gc=="G1" | vm.gc=="null"
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
+ * @build com.oracle.java.testlibrary.* sun.hotspot.WhiteBox
* @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData20
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * sun.hotspot.WhiteBox$WhiteBoxPermission
* @run driver/timeout=720 TestShrinkAuxiliaryData20
*/
public class TestShrinkAuxiliaryData20 {
--- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData25.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData25.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,12 +23,17 @@
/**
* @test TestShrinkAuxiliaryData25
- * @bug 8038423
+ * @bug 8038423 8061715
* @summary Checks that decommitment occurs for JVM with different
* G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
* @requires vm.gc=="G1" | vm.gc=="null"
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
+ * @build com.oracle.java.testlibrary.* sun.hotspot.WhiteBox
* @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData25
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * sun.hotspot.WhiteBox$WhiteBoxPermission
* @run driver/timeout=720 TestShrinkAuxiliaryData25
*/
public class TestShrinkAuxiliaryData25 {
--- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData30.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData30.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,12 +23,17 @@
/**
* @test TestShrinkAuxiliaryData30
- * @bug 8038423
+ * @bug 8038423 8061715
* @summary Checks that decommitment occurs for JVM with different
* G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
* @requires vm.gc=="G1" | vm.gc=="null"
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
+ * @build com.oracle.java.testlibrary.* sun.hotspot.WhiteBox
* @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData30
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * sun.hotspot.WhiteBox$WhiteBoxPermission
* @run driver/timeout=720 TestShrinkAuxiliaryData30
*/
public class TestShrinkAuxiliaryData30 {
--- a/hotspot/test/gc/g1/TestShrinkDefragmentedHeap.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/g1/TestShrinkDefragmentedHeap.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,8 @@
* 3. invoke gc and check that memory returned to the system (amount of committed memory got down)
*
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management/sun.management
*/
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryUsage;
--- a/hotspot/test/gc/g1/TestStringDeduplicationAgeThreshold.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/g1/TestStringDeduplicationAgeThreshold.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8029075
* @key gc
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
public class TestStringDeduplicationAgeThreshold {
--- a/hotspot/test/gc/g1/TestStringDeduplicationFullGC.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/g1/TestStringDeduplicationFullGC.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8029075
* @key gc
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
public class TestStringDeduplicationFullGC {
--- a/hotspot/test/gc/g1/TestStringDeduplicationInterned.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/g1/TestStringDeduplicationInterned.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8029075
* @key gc
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
public class TestStringDeduplicationInterned {
--- a/hotspot/test/gc/g1/TestStringDeduplicationPrintOptions.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/g1/TestStringDeduplicationPrintOptions.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8029075
* @key gc
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
public class TestStringDeduplicationPrintOptions {
--- a/hotspot/test/gc/g1/TestStringDeduplicationTableRehash.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/g1/TestStringDeduplicationTableRehash.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8029075
* @key gc
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
public class TestStringDeduplicationTableRehash {
--- a/hotspot/test/gc/g1/TestStringDeduplicationTableResize.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/g1/TestStringDeduplicationTableResize.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8029075
* @key gc
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
public class TestStringDeduplicationTableResize {
--- a/hotspot/test/gc/g1/TestStringDeduplicationYoungGC.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/g1/TestStringDeduplicationYoungGC.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8029075
* @key gc
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
public class TestStringDeduplicationYoungGC {
--- a/hotspot/test/gc/g1/TestStringSymbolTableStats.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/g1/TestStringSymbolTableStats.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @summary Ensure that the G1TraceStringSymbolTableScrubbing prints the expected message.
* @key gc
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.ProcessTools;
--- a/hotspot/test/gc/g1/TestSummarizeRSetStats.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/g1/TestSummarizeRSetStats.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test TestSummarizeRSetStats.java
* @bug 8013895
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management/sun.management
* @build TestSummarizeRSetStatsTools TestSummarizeRSetStats
* @summary Verify output of -XX:+G1SummarizeRSetStats
* @run main TestSummarizeRSetStats
--- a/hotspot/test/gc/g1/TestSummarizeRSetStatsPerRegion.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/g1/TestSummarizeRSetStatsPerRegion.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test TestSummarizeRSetStatsPerRegion.java
* @bug 8014078
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management/sun.management
* @build TestSummarizeRSetStatsTools TestSummarizeRSetStatsPerRegion
* @summary Verify output of -XX:+G1SummarizeRSetStats in regards to per-region type output
* @run main TestSummarizeRSetStatsPerRegion
--- a/hotspot/test/gc/g1/TestSummarizeRSetStatsThreads.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/g1/TestSummarizeRSetStatsThreads.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* refinement threads do not crash the VM.
* @key gc
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management/sun.management
*/
import java.util.regex.Matcher;
--- a/hotspot/test/gc/logging/TestGCId.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/logging/TestGCId.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @summary Ensure that the GCId is logged
* @key gc
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.ProcessTools;
--- a/hotspot/test/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java Tue Apr 14 12:10:00 2015 -0700
@@ -26,6 +26,8 @@
* @bug 8004924
* @summary Checks that jmap -heap contains the flag CompressedClassSpaceSize
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:CompressedClassSpaceSize=50m CompressedClassSpaceSizeInJmapHeap
*/
--- a/hotspot/test/gc/metaspace/TestCapacityUntilGCWrapAround.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/metaspace/TestCapacityUntilGCWrapAround.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @key gc
* @bug 8049831
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build TestCapacityUntilGCWrapAround
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/gc/metaspace/TestMetaspaceMemoryPool.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/metaspace/TestMetaspaceMemoryPool.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,8 @@
* @summary Tests that a MemoryPoolMXBeans is created for metaspace and that a
* MemoryManagerMXBean is created.
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops TestMetaspaceMemoryPool
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:MaxMetaspaceSize=60m TestMetaspaceMemoryPool
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedClassPointers TestMetaspaceMemoryPool
--- a/hotspot/test/gc/metaspace/TestMetaspacePerfCounters.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/metaspace/TestMetaspacePerfCounters.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -33,7 +33,10 @@
* @library /testlibrary
* @summary Tests that performance counters for metaspace and compressed class
* space exists and works.
- *
+ * @modules java.base/sun.misc
+ * java.compiler
+ * java.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+UsePerfData -XX:+UseSerialGC TestMetaspacePerfCounters
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+UsePerfData -XX:+UseParallelGC -XX:+UseParallelOldGC TestMetaspacePerfCounters
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedClassPointers -XX:+UsePerfData -XX:+UseG1GC TestMetaspacePerfCounters
--- a/hotspot/test/gc/metaspace/TestMetaspaceSizeFlags.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/metaspace/TestMetaspaceSizeFlags.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,8 @@
* @bug 8024650
* @summary Test that metaspace size flags can be set correctly
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
public class TestMetaspaceSizeFlags {
public static final long K = 1024L;
--- a/hotspot/test/gc/metaspace/TestPerfCountersAndMemoryPools.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/metaspace/TestPerfCountersAndMemoryPools.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -33,6 +33,9 @@
* @requires vm.gc=="Serial" | vm.gc=="null"
* @summary Tests that a MemoryPoolMXBeans and PerfCounters for metaspace
* report the same data.
+ * @modules java.base/sun.misc
+ * java.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:-UseCompressedKlassPointers -XX:+UseSerialGC -XX:+UsePerfData -Xint TestPerfCountersAndMemoryPools
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedKlassPointers -XX:+UseSerialGC -XX:+UsePerfData -Xint TestPerfCountersAndMemoryPools
*/
--- a/hotspot/test/gc/parallelScavenge/AdaptiveGCBoundary.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/parallelScavenge/AdaptiveGCBoundary.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @key gc
* @key regression
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main/othervm AdaptiveGCBoundary
* @author jon.masamitsu@oracle.com
*/
--- a/hotspot/test/gc/startup_warnings/TestCMS.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/startup_warnings/TestCMS.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8006398
* @summary Test that CMS does not print a warning message
* @library /testlibrary
+* @modules java.base/sun.misc
+* java.management
*/
import com.oracle.java.testlibrary.OutputAnalyzer;
--- a/hotspot/test/gc/startup_warnings/TestDefNewCMS.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/startup_warnings/TestDefNewCMS.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8065972
* @summary Test that the unsupported DefNew+CMS combination does not start
* @library /testlibrary
+* @modules java.base/sun.misc
+* java.management
*/
import com.oracle.java.testlibrary.OutputAnalyzer;
--- a/hotspot/test/gc/startup_warnings/TestDefaultMaxRAMFraction.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/startup_warnings/TestDefaultMaxRAMFraction.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8021967
* @summary Test that the deprecated TestDefaultMaxRAMFraction flag print a warning message
* @library /testlibrary
+* @modules java.base/sun.misc
+* java.management
*/
import com.oracle.java.testlibrary.OutputAnalyzer;
--- a/hotspot/test/gc/startup_warnings/TestG1.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/startup_warnings/TestG1.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8006398
* @summary Test that the G1 collector does not print a warning message
* @library /testlibrary
+* @modules java.base/sun.misc
+* java.management
*/
import com.oracle.java.testlibrary.OutputAnalyzer;
--- a/hotspot/test/gc/startup_warnings/TestNoParNew.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/startup_warnings/TestNoParNew.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8065972
* @summary Test that specifying -XX:-UseParNewGC on the command line logs a warning message
* @library /testlibrary
+* @modules java.base/sun.misc
+* java.management
*/
import com.oracle.java.testlibrary.OutputAnalyzer;
--- a/hotspot/test/gc/startup_warnings/TestParNewCMS.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/startup_warnings/TestParNewCMS.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8065972
* @summary Test that specifying -XX:+UseParNewGC on the command line logs a warning message
* @library /testlibrary
+* @modules java.base/sun.misc
+* java.management
*/
import com.oracle.java.testlibrary.OutputAnalyzer;
--- a/hotspot/test/gc/startup_warnings/TestParNewSerialOld.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/startup_warnings/TestParNewSerialOld.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8065972
* @summary Test that the unsupported ParNew+SerialOld combination does not start
* @library /testlibrary
+* @modules java.base/sun.misc
+* java.management
*/
import com.oracle.java.testlibrary.OutputAnalyzer;
--- a/hotspot/test/gc/startup_warnings/TestParallelGC.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/startup_warnings/TestParallelGC.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8006398
* @summary Test that ParallelGC does not print a warning message
* @library /testlibrary
+* @modules java.base/sun.misc
+* java.management
*/
import com.oracle.java.testlibrary.OutputAnalyzer;
--- a/hotspot/test/gc/startup_warnings/TestParallelScavengeSerialOld.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/startup_warnings/TestParallelScavengeSerialOld.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8006398
* @summary Test that the ParallelScavenge+SerialOld combination does not print a warning message
* @library /testlibrary
+* @modules java.base/sun.misc
+* java.management
*/
import com.oracle.java.testlibrary.OutputAnalyzer;
--- a/hotspot/test/gc/startup_warnings/TestSerialGC.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/startup_warnings/TestSerialGC.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8006398
* @summary Test that SerialGC does not print a warning message
* @library /testlibrary
+* @modules java.base/sun.misc
+* java.management
*/
import com.oracle.java.testlibrary.OutputAnalyzer;
--- a/hotspot/test/gc/survivorAlignment/TestAllocationInEden.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/survivorAlignment/TestAllocationInEden.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @summary Verify that object's alignment in eden space is not affected by
* SurvivorAlignmentInBytes option.
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build TestAllocationInEden SurvivorAlignmentTestMain AlignmentHelper
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/gc/survivorAlignment/TestPromotionFromEdenToTenured.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/survivorAlignment/TestPromotionFromEdenToTenured.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @summary Verify that objects promoted from eden space to tenured space during
* full GC are not aligned to SurvivorAlignmentInBytes value.
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build TestPromotionFromEdenToTenured SurvivorAlignmentTestMain
* AlignmentHelper
* @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterFullGC.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterFullGC.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @summary Verify that objects promoted from survivor space to tenured space
* during full GC are not aligned to SurvivorAlignmentInBytes value.
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build TestPromotionFromSurvivorToTenuredAfterFullGC
* SurvivorAlignmentTestMain AlignmentHelper
* @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterMinorGC.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterMinorGC.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* when their age exceeded tenuring threshold are not aligned to
* SurvivorAlignmentInBytes value.
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build TestPromotionFromSurvivorToTenuredAfterMinorGC
* SurvivorAlignmentTestMain AlignmentHelper
* @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/gc/survivorAlignment/TestPromotionToSurvivor.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/survivorAlignment/TestPromotionToSurvivor.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @summary Verify that objects promoted from eden space to survivor space after
* minor GC are aligned to SurvivorAlignmentInBytes.
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build TestPromotionToSurvivor
* SurvivorAlignmentTestMain AlignmentHelper
* @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/gc/whitebox/TestConcMarkCycleWB.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/whitebox/TestConcMarkCycleWB.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,10 @@
* @bug 8065579
* @requires vm.gc=="null" | vm.gc=="G1"
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.compiler
+ * java.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @build ClassFileInstaller com.oracle.java.testlibrary.* sun.hotspot.WhiteBox TestConcMarkCycleWB
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/gc/whitebox/TestWBGC.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/gc/whitebox/TestWBGC.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8055098
* @summary Test verify that WB methods isObjectInOldGen and youngGC works correctly.
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build TestWBGC
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* @run driver TestWBGC
--- a/hotspot/test/runtime/6819213/TestBootNativeLibraryPath.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/6819213/TestBootNativeLibraryPath.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
/*
* @test TestBootNativeLibraryPath.java
* @bug 6819213
+ * @modules java.compiler
* @compile -XDignore.symbol.file TestBootNativeLibraryPath.java
* @summary verify sun.boot.native.library.path is expandable on 32 bit systems
* @run main TestBootNativeLibraryPath
--- a/hotspot/test/runtime/8003720/Test8003720.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/8003720/Test8003720.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @test
* @bug 8003720
* @summary Method in interpreter stack frame can be deallocated
+ * @modules java.base/jdk.internal.org.objectweb.asm
+ * java.base/sun.misc
* @compile -XDignore.symbol.file Victim.java
* @run main/othervm -Xverify:all -Xint Test8003720
*/
--- a/hotspot/test/runtime/8026365/InvokeSpecialAnonTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/8026365/InvokeSpecialAnonTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @summary Test invokespecial of host class method from an anonymous class
* @author Robert Field
* @library /testlibrary
+ * @modules java.base/jdk.internal.org.objectweb.asm
+ * java.base/sun.misc
* @compile -XDignore.symbol.file InvokeSpecialAnonTest.java
* @run main ClassFileInstaller InvokeSpecialAnonTest AnonTester
* @run main/othervm -Xbootclasspath/a:. -Xverify:all InvokeSpecialAnonTest
--- a/hotspot/test/runtime/BadObjectClass/BootstrapRedefine.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/BadObjectClass/BootstrapRedefine.java Tue Apr 14 12:10:00 2015 -0700
@@ -26,6 +26,8 @@
* @bug 6583051
* @summary Give error if java.lang.Object has been incompatibly overridden on the bootpath
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @compile Object.java
* @run main BootstrapRedefine
*/
--- a/hotspot/test/runtime/CDSCompressedKPtrs/CDSCompressedKPtrs.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/CDSCompressedKPtrs/CDSCompressedKPtrs.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8003424
* @summary Testing UseCompressedClassPointers with CDS
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main CDSCompressedKPtrs
*/
--- a/hotspot/test/runtime/CDSCompressedKPtrs/CDSCompressedKPtrsError.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/CDSCompressedKPtrs/CDSCompressedKPtrsError.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8003424
* @summary Test that cannot use CDS if UseCompressedClassPointers is turned off.
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main CDSCompressedKPtrsError
*/
--- a/hotspot/test/runtime/CDSCompressedKPtrs/XShareAuto.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/CDSCompressedKPtrs/XShareAuto.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8005933
* @summary Test that -Xshare:auto uses CDS when explicitly specified with -server.
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main XShareAuto
*/
--- a/hotspot/test/runtime/ClassFile/JsrRewriting.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/ClassFile/JsrRewriting.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -34,6 +34,9 @@
* @bug 7149464
* @key cte_test
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.desktop
+ * java.management
* @run main JsrRewriting
*/
--- a/hotspot/test/runtime/ClassFile/OomWhileParsingRepeatedJsr.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/ClassFile/OomWhileParsingRepeatedJsr.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -34,6 +34,9 @@
* @bug 7123945
* @bug 8016029
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.desktop
+ * java.management
* @run main OomWhileParsingRepeatedJsr
*/
--- a/hotspot/test/runtime/ClassFile/UnsupportedClassFileVersion.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/ClassFile/UnsupportedClassFileVersion.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,9 @@
/*
* @test
* @library /testlibrary
+ * @modules java.base/jdk.internal.org.objectweb.asm
+ * java.base/sun.misc
+ * java.management
* @compile -XDignore.symbol.file UnsupportedClassFileVersion.java
* @run main UnsupportedClassFileVersion
*/
--- a/hotspot/test/runtime/CommandLine/BooleanFlagWithInvalidValue.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/CommandLine/BooleanFlagWithInvalidValue.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8006298
* @summary Setting an invalid value for a bool argument should result in a useful error message
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.*;
--- a/hotspot/test/runtime/CommandLine/CompilerConfigFileWarning.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/CommandLine/CompilerConfigFileWarning.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 7167142
* @summary Warn if unused .hotspot_compiler file is present
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import java.io.PrintWriter;
--- a/hotspot/test/runtime/CommandLine/ConfigFileParsing.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/CommandLine/ConfigFileParsing.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 7158804
* @summary Improve config file parsing
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import java.io.PrintWriter;
--- a/hotspot/test/runtime/CommandLine/ConfigFileWarning.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/CommandLine/ConfigFileWarning.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 7167142
* @summary Warn if unused .hotspot_rc file is present
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import java.io.PrintWriter;
--- a/hotspot/test/runtime/CommandLine/FlagWithInvalidValue.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/CommandLine/FlagWithInvalidValue.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8006298
* @summary Setting a flag to an invalid value should print a useful error message
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.*;
--- a/hotspot/test/runtime/CommandLine/NonBooleanFlagWithInvalidBooleanPrefix.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/CommandLine/NonBooleanFlagWithInvalidBooleanPrefix.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8006298
* @summary Using a bool (+/-) prefix on non-bool flag should result in a useful error message
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.*;
--- a/hotspot/test/runtime/CommandLine/ObsoleteFlagErrorMessage.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/CommandLine/ObsoleteFlagErrorMessage.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8060449
* @summary Newly obsolete command line options should still give useful error messages when used improperly.
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.*;
--- a/hotspot/test/runtime/CommandLine/TestHexArguments.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/CommandLine/TestHexArguments.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @summary Make sure there is no error using hexadecimal format in vm options
* @author Yumin Qi
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import java.io.File;
--- a/hotspot/test/runtime/CommandLine/TestNullTerminatedFlags.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/CommandLine/TestNullTerminatedFlags.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* @bug 6522873
* @summary Test that the VM don't allow random junk characters at the end of valid command line flags.
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run driver TestNullTerminatedFlags
*/
public class TestNullTerminatedFlags {
--- a/hotspot/test/runtime/CommandLine/TestVMOptions.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/CommandLine/TestVMOptions.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8060256
* @summary Test various command line options
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main TestVMOptions
*/
--- a/hotspot/test/runtime/CommandLine/TraceExceptionsTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/CommandLine/TraceExceptionsTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8048933
* @summary TraceExceptions output should have the exception message - useful for ClassNotFoundExceptions especially
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.*;
--- a/hotspot/test/runtime/CommandLine/UnrecognizedVMOption.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/CommandLine/UnrecognizedVMOption.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8006298
* @summary Using an unrecognized VM option should print the name of the option
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.*;
--- a/hotspot/test/runtime/CommandLine/VMOptionWarning.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/CommandLine/VMOptionWarning.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8027314
* @summary Warn if diagnostic or experimental vm option is used and -XX:+UnlockDiagnosticVMOptions or -XX:+UnlockExperimentalVMOptions, respectively, isn't specified. Warn if develop or notproduct vm option is used with product version of VM.
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.*;
--- a/hotspot/test/runtime/CompressedOops/CompressedClassPointers.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/CompressedOops/CompressedClassPointers.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8024927
* @summary Testing address of compressed class pointer space as best as possible.
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.*;
--- a/hotspot/test/runtime/CompressedOops/CompressedClassSpaceSize.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/CompressedOops/CompressedClassSpaceSize.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8022865
* @summary Tests for the -XX:CompressedClassSpaceSize command line option
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main CompressedClassSpaceSize
*/
import com.oracle.java.testlibrary.*;
--- a/hotspot/test/runtime/CompressedOops/CompressedKlassPointerAndOops.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/CompressedOops/CompressedKlassPointerAndOops.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @key regression
* @summary NPG: UseCompressedClassPointers asserts with ObjectAlignmentInBytes=32
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.*;
--- a/hotspot/test/runtime/CompressedOops/ObjectAlignment.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/CompressedOops/ObjectAlignment.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8022865
* @summary Tests for the -XX:ObjectAlignmentInBytes command line option
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main ObjectAlignment
*/
import com.oracle.java.testlibrary.*;
--- a/hotspot/test/runtime/CompressedOops/UseCompressedOops.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/CompressedOops/UseCompressedOops.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8022865
* @summary Tests for different combination of UseCompressedOops options
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main UseCompressedOops
*/
import java.util.ArrayList;
--- a/hotspot/test/runtime/EnclosingMethodAttr/EnclMethodAttr.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/EnclosingMethodAttr/EnclMethodAttr.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8044738
* @library /testlibrary
* @summary Check attribute_length of EnclosingMethod attribute
+ * @modules java.base/sun.misc
+ * java.management
* @run main EnclMethodAttr
*/
--- a/hotspot/test/runtime/ErrorHandling/ProblematicFrameTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/ErrorHandling/ProblematicFrameTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -26,6 +26,10 @@
* @bug 8050167
* @summary Test that error is not occurred during printing problematic frame
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.compiler
+ * java.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @build com.oracle.java.testlibrary.*
* @run driver ProblematicFrameTest
*/
--- a/hotspot/test/runtime/ErrorHandling/SecondaryErrorTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/ErrorHandling/SecondaryErrorTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -14,6 +14,8 @@
* @summary Synchronous signals during error reporting may terminate or hang VM process
* @library /testlibrary
* @author Thomas Stuefe (SAP)
+ * @modules java.base/sun.misc
+ * java.management
*/
public class SecondaryErrorTest {
--- a/hotspot/test/runtime/InternalApi/ThreadCpuTimesDeadlock.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/InternalApi/ThreadCpuTimesDeadlock.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
* @bug 7196045
* @bug 8014294
* @summary Possible JVM deadlock in ThreadTimesClosure when using HotspotInternal non-public API.
+ * @modules java.management/sun.management
* @run main/othervm -XX:+UsePerfData -Xmx32m ThreadCpuTimesDeadlock
*/
--- a/hotspot/test/runtime/LoadClass/LoadClassNegative.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/LoadClass/LoadClassNegative.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8020675
* @summary make sure there is no fatal error if a class is loaded from an invalid jar file which is in the bootclasspath
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @build TestForName
* @build LoadClassNegative
* @run main LoadClassNegative
--- a/hotspot/test/runtime/LocalVariableTable/TestLVT.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/LocalVariableTable/TestLVT.java Tue Apr 14 12:10:00 2015 -0700
@@ -26,6 +26,8 @@
* @bug 8049632
* @summary Test ClassFileParser::copy_localvariable_table cases
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @compile -g -XDignore.symbol.file TestLVT.java
* @run main TestLVT
*/
--- a/hotspot/test/runtime/Metaspace/FragmentMetaspace.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/Metaspace/FragmentMetaspace.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
/**
* @test
* @library /runtime/testlibrary
+ * @modules java.compiler
* @build GeneratedClassLoader
* @run main/othervm/timeout=200 -Xmx300m FragmentMetaspace
*/
--- a/hotspot/test/runtime/NMT/AutoshutdownNMT.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/NMT/AutoshutdownNMT.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @key nmt
* @summary Test for deprecated message if -XX:-AutoShutdownNMT is specified
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.*;
--- a/hotspot/test/runtime/NMT/BaselineWithParameter.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/NMT/BaselineWithParameter.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @key nmt jcmd regression
* @summary Regression test for invoking a jcmd with baseline=false, result was that the target VM crashed
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main/othervm -XX:NativeMemoryTracking=detail BaselineWithParameter
*/
--- a/hotspot/test/runtime/NMT/CommandLineDetail.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/NMT/CommandLineDetail.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @key nmt
* @summary Running with NMT detail should not result in an error
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.*;
--- a/hotspot/test/runtime/NMT/CommandLineEmptyArgument.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/NMT/CommandLineEmptyArgument.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @key nmt
* @summary Empty argument to NMT should result in an informative error message
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.*;
--- a/hotspot/test/runtime/NMT/CommandLineInvalidArgument.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/NMT/CommandLineInvalidArgument.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @key nmt
* @summary Invalid argument to NMT should result in an informative error message
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.*;
--- a/hotspot/test/runtime/NMT/CommandLineSummary.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/NMT/CommandLineSummary.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @key nmt
* @summary Running with NMT summary should not result in an error
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.*;
--- a/hotspot/test/runtime/NMT/CommandLineTurnOffNMT.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/NMT/CommandLineTurnOffNMT.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @key nmt
* @summary Turning off NMT should not result in an error
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.*;
--- a/hotspot/test/runtime/NMT/JcmdBaselineDetail.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/NMT/JcmdBaselineDetail.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @key nmt jcmd
* @summary Verify that jcmd correctly reports that baseline succeeds with NMT enabled with detailed tracking.
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main/othervm -XX:NativeMemoryTracking=detail JcmdBaselineDetail
*/
--- a/hotspot/test/runtime/NMT/JcmdDetailDiff.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/NMT/JcmdDetailDiff.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @summary run NMT baseline, allocate memory and verify output from detail.diff
* @key nmt jcmd
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @ignore
* @build JcmdDetailDiff
* @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/runtime/NMT/JcmdScale.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/NMT/JcmdScale.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @key nmt jcmd
* @summary Test the NMT scale parameter
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main/othervm -XX:NativeMemoryTracking=summary JcmdScale
*/
--- a/hotspot/test/runtime/NMT/JcmdScaleDetail.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/NMT/JcmdScaleDetail.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @key nmt jcmd
* @summary Test the NMT scale parameter with detail tracking level
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main/othervm -XX:NativeMemoryTracking=detail JcmdScaleDetail
*/
--- a/hotspot/test/runtime/NMT/JcmdSummaryDiff.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/NMT/JcmdSummaryDiff.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @summary run NMT baseline, allocate memory and verify output from summary.diff
* @key nmt jcmd
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build JcmdSummaryDiff
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=summary JcmdSummaryDiff
--- a/hotspot/test/runtime/NMT/JcmdWithNMTDisabled.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/NMT/JcmdWithNMTDisabled.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @key nmt jcmd
* @summary Verify that jcmd correctly reports that NMT is not enabled
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main JcmdWithNMTDisabled 1
*/
--- a/hotspot/test/runtime/NMT/MallocRoundingReportTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/NMT/MallocRoundingReportTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @summary Test consistency of NMT by creating allocations of the Test type with various sizes and verifying visibility with jcmd
* @key nmt jcmd
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build MallocRoundingReportTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail MallocRoundingReportTest
--- a/hotspot/test/runtime/NMT/MallocStressTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/NMT/MallocStressTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @summary Stress test for malloc tracking
* @key nmt jcmd stress
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build MallocStressTest
* @ignore - This test is disabled since it will stress NMT and timeout during normal testing
* @run main ClassFileInstaller sun.hotspot.WhiteBox
--- a/hotspot/test/runtime/NMT/MallocTestType.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/NMT/MallocTestType.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @summary Test consistency of NMT by leaking a few select allocations of the Test type and then verify visibility with jcmd
* @key nmt jcmd
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build MallocTestType
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/runtime/NMT/MallocTrackingVerify.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/NMT/MallocTrackingVerify.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @summary Test to verify correctness of malloc tracking
* @key nmt jcmd
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build MallocTrackingVerify
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail MallocTrackingVerify
--- a/hotspot/test/runtime/NMT/NMTWithCDS.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/NMT/NMTWithCDS.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8055061
* @key nmt
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main NMTWithCDS
*/
import com.oracle.java.testlibrary.*;
--- a/hotspot/test/runtime/NMT/PrintNMTStatisticsWithNMTDisabled.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/NMT/PrintNMTStatisticsWithNMTDisabled.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @key nmt
* @summary Trying to enable PrintNMTStatistics should result in a warning
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.*;
--- a/hotspot/test/runtime/NMT/ReleaseNoCommit.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/NMT/ReleaseNoCommit.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @summary Release uncommitted memory and make sure NMT handles it correctly
* @key nmt regression
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build ReleaseNoCommit
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=summary ReleaseNoCommit
--- a/hotspot/test/runtime/NMT/ShutdownTwice.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/NMT/ShutdownTwice.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @key nmt jcmd
* @summary Run shutdown twice
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main/othervm -XX:NativeMemoryTracking=detail ShutdownTwice
*/
--- a/hotspot/test/runtime/NMT/SummaryAfterShutdown.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/NMT/SummaryAfterShutdown.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @key nmt jcmd
* @summary Verify that jcmd correctly reports that NMT is not enabled after a shutdown
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main/othervm -XX:NativeMemoryTracking=detail SummaryAfterShutdown
*/
--- a/hotspot/test/runtime/NMT/SummarySanityCheck.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/NMT/SummarySanityCheck.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @key nmt jcmd
* @summary Sanity check the output of NMT
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build SummarySanityCheck
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/runtime/NMT/ThreadedMallocTestType.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/NMT/ThreadedMallocTestType.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test
* @key nmt jcmd
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build ThreadedMallocTestType
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/runtime/NMT/ThreadedVirtualAllocTestType.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/NMT/ThreadedVirtualAllocTestType.java Tue Apr 14 12:10:00 2015 -0700
@@ -25,6 +25,8 @@
* @test
* @key nmt jcmd
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build ThreadedVirtualAllocTestType
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/runtime/NMT/VirtualAllocCommitUncommitRecommit.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/NMT/VirtualAllocCommitUncommitRecommit.java Tue Apr 14 12:10:00 2015 -0700
@@ -26,6 +26,8 @@
* @summary Test reserve/commit/uncommit/release of virtual memory and that we track it correctly
* @key nmt jcmd
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build VirtualAllocCommitUncommitRecommit
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail VirtualAllocCommitUncommitRecommit
--- a/hotspot/test/runtime/NMT/VirtualAllocTestType.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/NMT/VirtualAllocTestType.java Tue Apr 14 12:10:00 2015 -0700
@@ -26,6 +26,8 @@
* @summary Test Reserve/Commit/Uncommit/Release of virtual memory and that we track it correctly
* @key nmt jcmd
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build VirtualAllocTestType
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/runtime/PerfMemDestroy/PerfMemDestroy.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/PerfMemDestroy/PerfMemDestroy.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8030955
* @summary Allow multiple calls to PerfMemory::destroy() without asserting.
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main PerfMemDestroy
*/
--- a/hotspot/test/runtime/RedefineObject/TestRedefineObject.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/RedefineObject/TestRedefineObject.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -33,6 +33,9 @@
* @bug 8005056
* @bug 8009728
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.instrument
+ * java.management
* @build Agent
* @run main ClassFileInstaller Agent
* @run main TestRedefineObject
--- a/hotspot/test/runtime/RedefineTests/RedefineAnnotations.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/RedefineTests/RedefineAnnotations.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,9 @@
* @test
* @library /testlibrary
* @summary Test that type annotations are retained after a retransform
+ * @modules java.base/jdk.internal.org.objectweb.asm
+ * java.instrument
+ * jdk.jartool/sun.tools.jar
* @run main RedefineAnnotations buildagent
* @run main/othervm -javaagent:redefineagent.jar RedefineAnnotations
*/
--- a/hotspot/test/runtime/RedefineTests/RedefineFinalizer.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/RedefineTests/RedefineFinalizer.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,9 @@
* @bug 6904403
* @summary Don't assert if we redefine finalize method
* @library /testlibrary
+ * @modules java.compiler
+ * java.instrument
+ * jdk.jartool/sun.tools.jar
* @build RedefineClassHelper
* @run main RedefineClassHelper
* @run main/othervm -javaagent:redefineagent.jar RedefineFinalizer
--- a/hotspot/test/runtime/RedefineTests/RedefineRunningMethods.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/RedefineTests/RedefineRunningMethods.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,9 @@
* @bug 8055008
* @summary Redefine EMCP and non-EMCP methods that are running in an infinite loop
* @library /testlibrary
+ * @modules java.compiler
+ * java.instrument
+ * jdk.jartool/sun.tools.jar
* @build RedefineClassHelper
* @run main RedefineClassHelper
* @run main/othervm -javaagent:redefineagent.jar -XX:TraceRedefineClasses=0x600 RedefineRunningMethods
--- a/hotspot/test/runtime/Safepoint/AssertSafepointCheckConsistency1.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/Safepoint/AssertSafepointCheckConsistency1.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8047290
* @summary Ensure that a Monitor::lock_without_safepoint_check fires an assert when it incorrectly acquires a lock which must always have safepoint checks.
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build AssertSafepointCheckConsistency1
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/runtime/Safepoint/AssertSafepointCheckConsistency2.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/Safepoint/AssertSafepointCheckConsistency2.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8047290
* @summary Ensure that a Monitor::lock fires an assert when it incorrectly acquires a lock which must never have safepoint checks.
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build AssertSafepointCheckConsistency2
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/runtime/Safepoint/AssertSafepointCheckConsistency3.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/Safepoint/AssertSafepointCheckConsistency3.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8047290
* @summary Ensure that Monitor::lock_without_safepoint_check does not assert when it correctly acquires a lock which must never have safepoint checks.
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build AssertSafepointCheckConsistency3
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/runtime/Safepoint/AssertSafepointCheckConsistency4.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/Safepoint/AssertSafepointCheckConsistency4.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8047290
* @summary Ensure that Monitor::lock does not assert when it correctly acquires a lock which must always have safepoint checks.
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build AssertSafepointCheckConsistency4
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/runtime/SharedArchiveFile/ArchiveDoesNotExist.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/SharedArchiveFile/ArchiveDoesNotExist.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* when sharing mode is ON, and continue w/o sharing if sharing
* mode is AUTO.
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main ArchiveDoesNotExist
*/
--- a/hotspot/test/runtime/SharedArchiveFile/CdsDifferentObjectAlignment.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/SharedArchiveFile/CdsDifferentObjectAlignment.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,8 @@
* should fail when loading.
* @library /testlibrary
* @bug 8025642
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.*;
--- a/hotspot/test/runtime/SharedArchiveFile/CdsSameObjectAlignment.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/SharedArchiveFile/CdsSameObjectAlignment.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @summary Testing CDS (class data sharing) using varying object alignment.
* Using same object alignment for each dump/load pair
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.*;
--- a/hotspot/test/runtime/SharedArchiveFile/DefaultUseWithClient.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/SharedArchiveFile/DefaultUseWithClient.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test DefaultUseWithClient
* @summary Test default behavior of sharing with -client
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main DefaultUseWithClient
* @bug 8032224
*/
--- a/hotspot/test/runtime/SharedArchiveFile/DumpSymbolAndStringTable.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/SharedArchiveFile/DumpSymbolAndStringTable.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8059510
* @summary Test jcmd VM.symboltable and VM.stringtable options
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main/othervm -XX:+UnlockDiagnosticVMOptions DumpSymbolAndStringTable
*/
--- a/hotspot/test/runtime/SharedArchiveFile/LimitSharedSizes.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/SharedArchiveFile/LimitSharedSizes.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,8 @@
/* @test LimitSharedSizes
* @summary Test handling of limits on shared space size
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main LimitSharedSizes
*/
--- a/hotspot/test/runtime/SharedArchiveFile/MaxMetaspaceSize.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/SharedArchiveFile/MaxMetaspaceSize.java Tue Apr 14 12:10:00 2015 -0700
@@ -26,6 +26,8 @@
* @bug 8067187
* @summary Testing CDS dumping with the -XX:MaxMetaspaceSize=<size> option
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.*;
--- a/hotspot/test/runtime/SharedArchiveFile/PrintSharedArchiveAndExit.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/SharedArchiveFile/PrintSharedArchiveAndExit.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8066670
* @summary Testing -XX:+PrintSharedArchiveAndExit option
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.*;
--- a/hotspot/test/runtime/SharedArchiveFile/SharedArchiveFile.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/SharedArchiveFile/SharedArchiveFile.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8014138
* @summary Testing new -XX:SharedArchiveFile=<file-name> option
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.*;
--- a/hotspot/test/runtime/SharedArchiveFile/SharedBaseAddress.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/SharedArchiveFile/SharedBaseAddress.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @summary Test variety of values for SharedBaseAddress, making sure
* VM handles normal values as well as edge values w/o a crash.
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main SharedBaseAddress
*/
--- a/hotspot/test/runtime/SharedArchiveFile/SharedSymbolTableBucketSize.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/SharedArchiveFile/SharedSymbolTableBucketSize.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8059510
* @summary Test SharedSymbolTableBucketSize option
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.*;
--- a/hotspot/test/runtime/SharedArchiveFile/SpaceUtilizationCheck.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/SharedArchiveFile/SpaceUtilizationCheck.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test SpaceUtilizationCheck
* @summary Check if the space utilization for shared spaces is adequate
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main SpaceUtilizationCheck
*/
--- a/hotspot/test/runtime/Thread/TestThreadDumpMonitorContention.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/Thread/TestThreadDumpMonitorContention.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,8 @@
* whether jstack reports "locked" by more than one thread.
*
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main/othervm TestThreadDumpMonitorContention
*/
--- a/hotspot/test/runtime/Thread/ThreadPriorities.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/Thread/ThreadPriorities.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* whether jstack reports correct priorities for them.
*
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main ThreadPriorities
*/
--- a/hotspot/test/runtime/Unsafe/AllocateInstance.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/Unsafe/AllocateInstance.java Tue Apr 14 12:10:00 2015 -0700
@@ -25,6 +25,8 @@
* @test
* @summary Verifies the behaviour of Unsafe.allocateInstance
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main AllocateInstance
*/
--- a/hotspot/test/runtime/Unsafe/AllocateMemory.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/Unsafe/AllocateMemory.java Tue Apr 14 12:10:00 2015 -0700
@@ -25,6 +25,8 @@
* @test
* @summary Verifies behaviour of Unsafe.allocateMemory
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:MallocMaxTestWords=100m AllocateMemory
*/
--- a/hotspot/test/runtime/Unsafe/CopyMemory.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/Unsafe/CopyMemory.java Tue Apr 14 12:10:00 2015 -0700
@@ -25,6 +25,8 @@
* @test
* @summary Verifies behaviour of Unsafe.copyMemory
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main CopyMemory
*/
--- a/hotspot/test/runtime/Unsafe/DefineClass.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/Unsafe/DefineClass.java Tue Apr 14 12:10:00 2015 -0700
@@ -25,6 +25,9 @@
* @test
* @summary Verifies the behaviour of Unsafe.defineClass
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.compiler
+ * java.management
* @run main DefineClass
*/
--- a/hotspot/test/runtime/Unsafe/FieldOffset.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/Unsafe/FieldOffset.java Tue Apr 14 12:10:00 2015 -0700
@@ -25,6 +25,8 @@
* @test
* @summary Verifies the behaviour of Unsafe.fieldOffset
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main FieldOffset
*/
--- a/hotspot/test/runtime/Unsafe/GetField.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/Unsafe/GetField.java Tue Apr 14 12:10:00 2015 -0700
@@ -25,6 +25,8 @@
* @test
* @summary Verifies behaviour of Unsafe.getField
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main GetField
*/
--- a/hotspot/test/runtime/Unsafe/GetPutAddress.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/Unsafe/GetPutAddress.java Tue Apr 14 12:10:00 2015 -0700
@@ -25,6 +25,8 @@
* @test
* Verify behaviour of Unsafe.get/putAddress and Unsafe.addressSize
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main GetPutAddress
*/
--- a/hotspot/test/runtime/Unsafe/GetPutBoolean.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/Unsafe/GetPutBoolean.java Tue Apr 14 12:10:00 2015 -0700
@@ -25,6 +25,8 @@
* @test
* @summary Verify behaviour of Unsafe.get/putBoolean
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main GetPutBoolean
*/
--- a/hotspot/test/runtime/Unsafe/GetPutByte.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/Unsafe/GetPutByte.java Tue Apr 14 12:10:00 2015 -0700
@@ -25,6 +25,8 @@
* @test
* @summary Verify behaviour of Unsafe.get/putByte
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main GetPutByte
*/
--- a/hotspot/test/runtime/Unsafe/GetPutChar.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/Unsafe/GetPutChar.java Tue Apr 14 12:10:00 2015 -0700
@@ -25,6 +25,8 @@
* @test
* @summary Verify behaviour of Unsafe.get/putChar
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main GetPutChar
*/
--- a/hotspot/test/runtime/Unsafe/GetPutDouble.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/Unsafe/GetPutDouble.java Tue Apr 14 12:10:00 2015 -0700
@@ -25,6 +25,8 @@
* @test
* @summary Verify behaviour of Unsafe.get/putDouble
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main GetPutDouble
*/
--- a/hotspot/test/runtime/Unsafe/GetPutFloat.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/Unsafe/GetPutFloat.java Tue Apr 14 12:10:00 2015 -0700
@@ -25,6 +25,8 @@
* @test
* @summary Verify behaviour of Unsafe.get/putFloat
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main GetPutFloat
*/
--- a/hotspot/test/runtime/Unsafe/GetPutInt.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/Unsafe/GetPutInt.java Tue Apr 14 12:10:00 2015 -0700
@@ -24,6 +24,8 @@
/*
* @test
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main GetPutInt
*/
--- a/hotspot/test/runtime/Unsafe/GetPutLong.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/Unsafe/GetPutLong.java Tue Apr 14 12:10:00 2015 -0700
@@ -25,6 +25,8 @@
* @test
* @summary Verify behaviour of Unsafe.get/putLong
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main GetPutLong
*/
--- a/hotspot/test/runtime/Unsafe/GetPutObject.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/Unsafe/GetPutObject.java Tue Apr 14 12:10:00 2015 -0700
@@ -25,6 +25,8 @@
* @test
* @summary Verify behaviour of Unsafe.get/putObject
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main GetPutObject
*/
--- a/hotspot/test/runtime/Unsafe/GetPutShort.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/Unsafe/GetPutShort.java Tue Apr 14 12:10:00 2015 -0700
@@ -25,6 +25,8 @@
* @test
* @summary Verify behaviour of Unsafe.get/putShort
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main GetPutShort
*/
--- a/hotspot/test/runtime/Unsafe/GetUnsafe.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/Unsafe/GetUnsafe.java Tue Apr 14 12:10:00 2015 -0700
@@ -25,6 +25,7 @@
* @test
* @summary Verifies that getUnsafe() actually throws SecurityException when unsafeAccess is prohibited.
* @library /testlibrary
+ * @modules java.base/sun.misc
* @run main GetUnsafe
*/
--- a/hotspot/test/runtime/Unsafe/PageSize.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/Unsafe/PageSize.java Tue Apr 14 12:10:00 2015 -0700
@@ -25,6 +25,8 @@
* @test
* @summary Make sure pageSize() returns a value that is a power of two
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main PageSize
*/
--- a/hotspot/test/runtime/Unsafe/RangeCheck.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/Unsafe/RangeCheck.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8001071
* @summary Add simple range check into VM implemenation of Unsafe access methods
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.*;
--- a/hotspot/test/runtime/Unsafe/Reallocate.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/Unsafe/Reallocate.java Tue Apr 14 12:10:00 2015 -0700
@@ -25,6 +25,8 @@
* @test
* @bug 8058897
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:MallocMaxTestWords=100m Reallocate
*/
--- a/hotspot/test/runtime/Unsafe/SetMemory.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/Unsafe/SetMemory.java Tue Apr 14 12:10:00 2015 -0700
@@ -25,6 +25,8 @@
* @test
* @summary Verifies that setMemory works correctly
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main SetMemory
*/
--- a/hotspot/test/runtime/Unsafe/ThrowException.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/Unsafe/ThrowException.java Tue Apr 14 12:10:00 2015 -0700
@@ -25,6 +25,8 @@
* @test
* @summary Verify that throwException() can throw an exception
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main ThrowException
*/
--- a/hotspot/test/runtime/XCheckJniJsig/XCheckJSig.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/XCheckJniJsig/XCheckJSig.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 7051189 8023393
* @summary Need to suppress info message if -Xcheck:jni is used with libjsig.so
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main XCheckJSig
*/
--- a/hotspot/test/runtime/classFileParserBug/ClassFileParserBug.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/classFileParserBug/ClassFileParserBug.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8040018
* @library /testlibrary
* @summary Check for exception instead of assert.
+ * @modules java.base/sun.misc
+ * java.management
* @run main ClassFileParserBug
*/
--- a/hotspot/test/runtime/classFileParserBug/TestEmptyBootstrapMethodsAttr.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/classFileParserBug/TestEmptyBootstrapMethodsAttr.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8041918
* @library /testlibrary
* @summary Test empty bootstrap_methods table within BootstrapMethods attribute
+ * @modules java.base/sun.misc
+ * java.management
* @compile TestEmptyBootstrapMethodsAttr.java
* @run main TestEmptyBootstrapMethodsAttr
*/
--- a/hotspot/test/runtime/contended/Basic.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/contended/Basic.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -42,7 +42,7 @@
* @test
* @bug 8003985
* @summary Support Contended Annotation - JEP 142
- *
+ * @modules java.base/sun.misc
* @run main/othervm -XX:-RestrictContended Basic
*/
public class Basic {
--- a/hotspot/test/runtime/contended/DefaultValue.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/contended/DefaultValue.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -43,6 +43,7 @@
* @bug 8014509
* @summary \@Contended: explicit default value behaves differently from the implicit value
*
+ * @modules java.base/sun.misc
* @run main/othervm -XX:-RestrictContended DefaultValue
*/
public class DefaultValue {
--- a/hotspot/test/runtime/contended/HasNonStatic.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/contended/HasNonStatic.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -43,6 +43,7 @@
* @bug 8015270
* @summary \@Contended: fix multiple issues in the layout code
*
+ * @modules java.base/sun.misc
* @run main/othervm -XX:-RestrictContended HasNonStatic
*/
public class HasNonStatic {
--- a/hotspot/test/runtime/contended/Inheritance1.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/contended/Inheritance1.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -43,6 +43,7 @@
* @bug 8012939
* @summary \@Contended doesn't work correctly with inheritance
*
+ * @modules java.base/sun.misc
* @run main/othervm -XX:-RestrictContended Inheritance1
*/
public class Inheritance1 {
--- a/hotspot/test/runtime/contended/OopMaps.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/contended/OopMaps.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -44,6 +44,7 @@
* @bug 8015493
* @summary \@Contended: fix multiple issues in the layout code
*
+ * @modules java.base/sun.misc
* @run main/othervm -XX:-RestrictContended -XX:ContendedPaddingWidth=128 -Xmx128m OopMaps
*/
public class OopMaps {
--- a/hotspot/test/runtime/contended/OopMapsSameGroup.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/contended/OopMapsSameGroup.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -43,6 +43,7 @@
* @bug 8015272
* @summary \@Contended within the same group to use the same oop map
*
+ * @modules java.base/sun.misc
* @run main/othervm -XX:-RestrictContended -XX:ContendedPaddingWidth=128 -Xmx128m OopMapsSameGroup
*/
public class OopMapsSameGroup {
--- a/hotspot/test/runtime/contended/Options.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/contended/Options.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,8 @@
* @summary ContendedPaddingWidth should be range-checked
*
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main Options
*/
public class Options {
--- a/hotspot/test/runtime/duplAttributes/DuplAttributesTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/duplAttributes/DuplAttributesTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
* @bug 8040292
* @library /testlibrary
* @summary Throw exceptions when duplicate attributes are detected.
+ * @modules java.base/sun.misc
+ * java.management
* @run main DuplAttributesTest
*/
--- a/hotspot/test/runtime/finalStatic/FinalStatic.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/finalStatic/FinalStatic.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
* @test
* @bug 8028553
* @summary Test that VerifyError is not thrown when 'overriding' a static method.
+ * @modules java.base/jdk.internal.org.objectweb.asm
* @run main FinalStatic
*/
--- a/hotspot/test/runtime/lambda-features/TestConcreteClassWithAbstractMethod.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/lambda-features/TestConcreteClassWithAbstractMethod.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
* @test
* @bug 8032010
* @summary method lookup on an abstract method in a concrete class should be successful
+ * @modules java.base/jdk.internal.org.objectweb.asm
* @run main TestConcreteClassWithAbstractMethod
*/
--- a/hotspot/test/runtime/memory/LargePages/TestLargePageSizeInBytes.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/memory/LargePages/TestLargePageSizeInBytes.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @summary Tests that the flag -XX:LargePageSizeInBytes does not cause warnings on Solaris
* @bug 8049536
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run driver TestLargePageSizeInBytes
*/
--- a/hotspot/test/runtime/memory/LargePages/TestLargePagesFlags.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/memory/LargePages/TestLargePagesFlags.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,8 @@
/* @test TestLargePagesFlags
* @summary Tests how large pages are choosen depending on the given large pages flag combinations.
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main TestLargePagesFlags
*/
--- a/hotspot/test/runtime/memory/ReadFromNoaccessArea.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/memory/ReadFromNoaccessArea.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test
* @summary Test that touching noaccess area in class ReservedHeapSpace results in SIGSEGV/ACCESS_VIOLATION
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build ReadFromNoaccessArea
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/runtime/memory/ReserveMemory.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/memory/ReserveMemory.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
* @bug 8012015
* @summary Make sure reserved (but uncommitted) memory is not accessible
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build ReserveMemory
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/runtime/memory/RunUnitTestsConcurrently.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/memory/RunUnitTestsConcurrently.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test
* @summary Test launches unit tests inside vm concurrently
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build RunUnitTestsConcurrently
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/runtime/verifier/OverriderMsg.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/verifier/OverriderMsg.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,9 @@
* @test OverriderMsg
* @bug 8026894
* @library /testlibrary
+ * @modules java.base/jdk.internal.org.objectweb.asm
+ * java.base/sun.misc
+ * java.management
* @compile -XDignore.symbol.file OverriderMsg.java
* @run main/othervm OverriderMsg
*/
--- a/hotspot/test/runtime/verifier/TestANewArray.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/verifier/TestANewArray.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -34,6 +34,9 @@
* @test
* @summary Test that anewarray bytecode is valid only if it specifies 255 or fewer dimensions.
* @library /testlibrary
+ * @modules java.base/jdk.internal.org.objectweb.asm
+ * java.base/sun.misc
+ * java.management
* @compile -XDignore.symbol.file TestANewArray.java
* @run main/othervm TestANewArray 49
* @run main/othervm TestANewArray 50
--- a/hotspot/test/runtime/verifier/TestMultiANewArray.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/runtime/verifier/TestMultiANewArray.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,9 @@
* @test TestMultiANewArray
* @bug 8038076
* @library /testlibrary
+ * @modules java.base/jdk.internal.org.objectweb.asm
+ * java.base/sun.misc
+ * java.management
* @compile -XDignore.symbol.file TestMultiANewArray.java
* @run main/othervm TestMultiANewArray 49
* @run main/othervm TestMultiANewArray 50
--- a/hotspot/test/serviceability/attach/AttachSetGetFlag.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/serviceability/attach/AttachSetGetFlag.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,11 @@
* @bug 8054823
* @summary Tests the setFlag and printFlag attach command
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.compiler
+ * java.management
+ * jdk.attach/sun.tools.attach
+ * jdk.jvmstat/sun.jvmstat.monitor
* @build com.oracle.java.testlibrary.* AttachSetGetFlag
* @run driver AttachSetGetFlag
*/
--- a/hotspot/test/serviceability/dcmd/compiler/CodeCacheTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/serviceability/dcmd/compiler/CodeCacheTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,10 @@
* @test CodeCacheTest
* @bug 8054889
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.compiler
+ * java.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @build com.oracle.java.testlibrary.*
* @build com.oracle.java.testlibrary.dcmd.*
* @run testng/othervm -XX:+SegmentedCodeCache CodeCacheTest
--- a/hotspot/test/serviceability/dcmd/compiler/CodelistTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/serviceability/dcmd/compiler/CodelistTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,10 @@
* @test CodelistTest
* @bug 8054889
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.compiler
+ * java.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @build com.oracle.java.testlibrary.*
* @build com.oracle.java.testlibrary.dcmd.*
* @build MethodIdentifierParser
--- a/hotspot/test/serviceability/dcmd/compiler/CompilerQueueTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/serviceability/dcmd/compiler/CompilerQueueTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,10 @@
* @test CompilerQueueTest
* @bug 8054889
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.compiler
+ * java.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @ignore 8069160
* @build com.oracle.java.testlibrary.*
* @build com.oracle.java.testlibrary.dcmd.*
--- a/hotspot/test/serviceability/dcmd/framework/HelpTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/serviceability/dcmd/framework/HelpTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -33,6 +33,10 @@
* @test
* @summary Test of diagnostic command help (tests all DCMD executors)
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.compiler
+ * java.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @ignore 8072440
* @build com.oracle.java.testlibrary.*
* @build com.oracle.java.testlibrary.dcmd.*
--- a/hotspot/test/serviceability/dcmd/framework/InvalidCommandTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/serviceability/dcmd/framework/InvalidCommandTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -33,6 +33,10 @@
* @test
* @summary Test of invalid diagnostic command (tests all DCMD executors)
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.compiler
+ * java.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @ignore 8072440
* @build com.oracle.java.testlibrary.*
* @build com.oracle.java.testlibrary.dcmd.*
--- a/hotspot/test/serviceability/dcmd/framework/VMVersionTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/serviceability/dcmd/framework/VMVersionTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -34,6 +34,10 @@
* @test
* @summary Test of diagnostic command VM.version (tests all DCMD executors)
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.compiler
+ * java.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @ignore 8072440
* @build com.oracle.java.testlibrary.*
* @build com.oracle.java.testlibrary.dcmd.*
--- a/hotspot/test/serviceability/dcmd/gc/ClassHistogramAllTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/serviceability/dcmd/gc/ClassHistogramAllTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -25,6 +25,10 @@
* @test
* @summary Test of diagnostic command GC.class_histogram -all=true
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.compiler
+ * java.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @build com.oracle.java.testlibrary.*
* @build com.oracle.java.testlibrary.dcmd.*
* @build ClassHistogramTest
--- a/hotspot/test/serviceability/dcmd/gc/ClassHistogramTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/serviceability/dcmd/gc/ClassHistogramTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -33,6 +33,10 @@
* @test
* @summary Test of diagnostic command GC.class_histogram
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.compiler
+ * java.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @build com.oracle.java.testlibrary.*
* @build com.oracle.java.testlibrary.dcmd.*
* @run testng ClassHistogramTest
--- a/hotspot/test/serviceability/dcmd/gc/HeapDumpAllTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/serviceability/dcmd/gc/HeapDumpAllTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -25,6 +25,10 @@
* @test
* @summary Test of diagnostic command GC.heap_dump -all=true
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.compiler
+ * java.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @build com.oracle.java.testlibrary.*
* @build com.oracle.java.testlibrary.dcmd.*
* @build HeapDumpTest
--- a/hotspot/test/serviceability/dcmd/gc/HeapDumpTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/serviceability/dcmd/gc/HeapDumpTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -35,6 +35,10 @@
* @test
* @summary Test of diagnostic command GC.heap_dump
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.compiler
+ * java.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @build com.oracle.java.testlibrary.*
* @build com.oracle.java.testlibrary.dcmd.*
* @run testng HeapDumpTest
--- a/hotspot/test/serviceability/dcmd/gc/RunFinalizationTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/serviceability/dcmd/gc/RunFinalizationTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -35,6 +35,10 @@
* @test
* @summary Test of diagnostic command GC.run_finalization
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.compiler
+ * java.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @build com.oracle.java.testlibrary.*
* @build com.oracle.java.testlibrary.dcmd.*
* @run testng RunFinalizationTest
--- a/hotspot/test/serviceability/dcmd/gc/RunGCTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/serviceability/dcmd/gc/RunGCTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -37,6 +37,10 @@
* @test
* @summary Test of diagnostic command GC.run
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.compiler
+ * java.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @build com.oracle.java.testlibrary.*
* @build com.oracle.java.testlibrary.dcmd.*
* @run testng/othervm -XX:+PrintGCDetails -Xloggc:RunGC.gclog -XX:-ExplicitGCInvokesConcurrent RunGCTest
--- a/hotspot/test/serviceability/dcmd/thread/PrintConcurrentLocksTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/serviceability/dcmd/thread/PrintConcurrentLocksTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -25,6 +25,10 @@
* @test
* @summary Test of diagnostic command Thread.print -l=true
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.compiler
+ * java.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @build com.oracle.java.testlibrary.*
* @build com.oracle.java.testlibrary.dcmd.*
* @build PrintTest
--- a/hotspot/test/serviceability/dcmd/thread/PrintTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/serviceability/dcmd/thread/PrintTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -38,6 +38,10 @@
* @test
* @summary Test of diagnostic command Thread.print
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.compiler
+ * java.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @build com.oracle.java.testlibrary.*
* @build com.oracle.java.testlibrary.dcmd.*
* @run testng PrintTest
--- a/hotspot/test/serviceability/dcmd/vm/ClassHierarchyTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/serviceability/dcmd/vm/ClassHierarchyTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -25,6 +25,10 @@
* @test
* @summary Test of diagnostic command VM.class_hierarchy
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.compiler
+ * java.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @build com.oracle.java.testlibrary.*
* @build com.oracle.java.testlibrary.dcmd.*
* @run testng ClassHierarchyTest
--- a/hotspot/test/serviceability/dcmd/vm/ClassLoaderStatsTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/serviceability/dcmd/vm/ClassLoaderStatsTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,10 @@
* @test
* @summary Test of diagnostic command VM.classloader_stats
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.compiler
+ * java.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @build com.oracle.java.testlibrary.*
* @build com.oracle.java.testlibrary.dcmd.*
* @run testng ClassLoaderStatsTest
--- a/hotspot/test/serviceability/dcmd/vm/CommandLineTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/serviceability/dcmd/vm/CommandLineTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -31,6 +31,10 @@
* @test
* @summary Test of diagnostic command VM.command_line
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.compiler
+ * java.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @build com.oracle.java.testlibrary.*
* @build com.oracle.java.testlibrary.dcmd.*
* @run testng/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+ThereShouldNotBeAnyVMOptionNamedLikeThis CommandLineTest
--- a/hotspot/test/serviceability/dcmd/vm/DynLibsTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/serviceability/dcmd/vm/DynLibsTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -33,6 +33,10 @@
* @test
* @summary Test of VM.dynlib diagnostic command via MBean
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.compiler
+ * java.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @build com.oracle.java.testlibrary.*
* @build com.oracle.java.testlibrary.dcmd.*
* @run testng DynLibsTest
--- a/hotspot/test/serviceability/dcmd/vm/FlagsTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/serviceability/dcmd/vm/FlagsTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -30,6 +30,10 @@
* @test
* @summary Test of diagnostic command VM.flags
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.compiler
+ * java.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @build com.oracle.java.testlibrary.*
* @build com.oracle.java.testlibrary.dcmd.*
* @run testng/othervm -Xmx129m -XX:+PrintGC -XX:+UnlockDiagnosticVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+ThereShouldNotBeAnyVMOptionNamedLikeThis_Right -XX:-TieredCompilation FlagsTest
--- a/hotspot/test/serviceability/dcmd/vm/SystemPropertiesTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/serviceability/dcmd/vm/SystemPropertiesTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -31,6 +31,10 @@
* @test
* @summary Test of diagnostic command VM.system_properties
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.compiler
+ * java.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @build com.oracle.java.testlibrary.*
* @build com.oracle.java.testlibrary.dcmd.*
* @run testng SystemPropertiesTest
--- a/hotspot/test/serviceability/dcmd/vm/UptimeTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/serviceability/dcmd/vm/UptimeTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -35,6 +35,10 @@
* @test
* @summary Test of diagnostic command VM.uptime
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.compiler
+ * java.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @build com.oracle.java.testlibrary.*
* @build com.oracle.java.testlibrary.dcmd.*
* @run testng UptimeTest
--- a/hotspot/test/serviceability/jvmti/GetObjectSizeOverflow.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/serviceability/jvmti/GetObjectSizeOverflow.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,11 @@
* @test
* @bug 8027230
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.compiler
+ * java.instrument
+ * java.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @build ClassFileInstaller com.oracle.java.testlibrary.* GetObjectSizeOverflowAgent
* @run main ClassFileInstaller GetObjectSizeOverflowAgent
* @run main GetObjectSizeOverflow
--- a/hotspot/test/serviceability/jvmti/TestLambdaFormRetransformation.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/serviceability/jvmti/TestLambdaFormRetransformation.java Tue Apr 14 12:10:00 2015 -0700
@@ -27,6 +27,10 @@
* @bug 8008678
* @summary JSR 292: constant pool reconstitution must support pseudo strings
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.instrument
+ * java.management
+ * jdk.jartool/sun.tools.jar
* @compile -XDignore.symbol.file TestLambdaFormRetransformation.java
* @run main TestLambdaFormRetransformation
*/
--- a/hotspot/test/serviceability/jvmti/TestRedefineWithUnresolvedClass.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/serviceability/jvmti/TestRedefineWithUnresolvedClass.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,12 @@
* @summary Redefine a class with an UnresolvedClass reference in the constant pool.
* @bug 8035150
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.compiler
+ * java.instrument
+ * java.management
+ * jdk.jartool/sun.tools.jar
+ * jdk.jvmstat/sun.jvmstat.monitor
* @build com.oracle.java.testlibrary.* UnresolvedClassAgent
* @run main TestRedefineWithUnresolvedClass
*/
--- a/hotspot/test/serviceability/sa/jmap-hashcode/Test8028623.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/serviceability/sa/jmap-hashcode/Test8028623.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,10 @@
* @bug 8028623
* @summary Test hashing of extended characters in Serviceability Agent.
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.compiler
+ * java.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @ignore 8044416
* @build com.oracle.java.testlibrary.*
* @compile -encoding utf8 Test8028623.java
--- a/hotspot/test/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -44,6 +44,10 @@
* @key regression
* @summary Regression test for hprof export issue due to large heaps (>2G)
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.compiler
+ * java.management/sun.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @build com.oracle.java.testlibrary.* JMapHProfLargeHeapProc
* @run main JMapHProfLargeHeapTest
*/
--- a/hotspot/test/testlibrary_tests/OutputAnalyzerReportingTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/testlibrary_tests/OutputAnalyzerReportingTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,8 @@
* such as printing additional diagnostic info
* (exit code, stdout, stderr, command line, etc.)
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import java.io.ByteArrayOutputStream;
--- a/hotspot/test/testlibrary_tests/OutputAnalyzerTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/testlibrary_tests/OutputAnalyzerTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test
* @summary Test the OutputAnalyzer utility class
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
*/
import com.oracle.java.testlibrary.OutputAnalyzer;
--- a/hotspot/test/testlibrary_tests/RandomGeneratorTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/testlibrary_tests/RandomGeneratorTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test
* @summary Verify correctnes of the random generator from Utility.java
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run driver RandomGeneratorTest SAME_SEED
* @run driver RandomGeneratorTest NO_SEED
* @run driver RandomGeneratorTest DIFFERENT_SEED
--- a/hotspot/test/testlibrary_tests/RedefineClassTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/testlibrary_tests/RedefineClassTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,9 @@
* @test
* @library /testlibrary
* @summary Proof of concept test for RedefineClassHelper
+ * @modules java.compiler
+ * java.instrument
+ * jdk.jartool/sun.tools.jar
* @build RedefineClassHelper
* @run main RedefineClassHelper
* @run main/othervm -javaagent:redefineagent.jar RedefineClassTest
--- a/hotspot/test/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -39,6 +39,8 @@
* in com.oracle.java.testlibrary.Platform one and only one predicate
* evaluates to true.
* @library /testlibrary
+ * @modules java.base/sun.misc
+ * java.management
* @run main TestMutuallyExclusivePlatformPredicates
*/
public class TestMutuallyExclusivePlatformPredicates {
--- a/hotspot/test/testlibrary_tests/TestPlatformIsTieredSupported.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/testlibrary_tests/TestPlatformIsTieredSupported.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,8 @@
* @test
* @summary Verifies that Platform::isTieredSupported returns correct value.
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management
* @build TestPlatformIsTieredSupported
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/testlibrary_tests/ctw/ClassesDirTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/testlibrary_tests/ctw/ClassesDirTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,9 @@
* @test
* @bug 8012447
* @library /testlibrary /../../test/lib /testlibrary/ctw/src
+ * @modules java.base/sun.misc
+ * java.base/sun.reflect
+ * java.management
* @build ClassFileInstaller sun.hotspot.tools.ctw.CompileTheWorld sun.hotspot.WhiteBox Foo Bar
* @run main ClassFileInstaller sun.hotspot.WhiteBox Foo Bar
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/testlibrary_tests/ctw/ClassesListTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/testlibrary_tests/ctw/ClassesListTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,9 @@
* @test
* @bug 8012447
* @library /testlibrary /../../test/lib /testlibrary/ctw/src
+ * @modules java.base/sun.misc
+ * java.base/sun.reflect
+ * java.management
* @build ClassFileInstaller sun.hotspot.tools.ctw.CompileTheWorld sun.hotspot.WhiteBox Foo Bar
* @run main ClassFileInstaller sun.hotspot.WhiteBox Foo Bar
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/testlibrary_tests/ctw/JarDirTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/testlibrary_tests/ctw/JarDirTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,11 @@
* @test
* @bug 8012447
* @library /testlibrary /../../test/lib /testlibrary/ctw/src
+ * @modules java.base/sun.misc
+ * java.base/sun.reflect
+ * java.compiler
+ * java.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @build ClassFileInstaller com.oracle.java.testlibrary.* sun.hotspot.tools.ctw.CompileTheWorld sun.hotspot.WhiteBox Foo Bar
* @run main ClassFileInstaller sun.hotspot.WhiteBox Foo Bar
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/testlibrary_tests/ctw/JarsTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/testlibrary_tests/ctw/JarsTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,11 @@
* @test
* @bug 8012447
* @library /testlibrary /../../test/lib /testlibrary/ctw/src
+ * @modules java.base/sun.misc
+ * java.base/sun.reflect
+ * java.compiler
+ * java.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @build ClassFileInstaller com.oracle.java.testlibrary.* sun.hotspot.tools.ctw.CompileTheWorld sun.hotspot.WhiteBox Foo Bar
* @run main ClassFileInstaller sun.hotspot.WhiteBox Foo Bar
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/testlibrary_tests/whitebox/vm_flags/BooleanTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/testlibrary_tests/whitebox/vm_flags/BooleanTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,10 @@
* @test BooleanTest
* @bug 8028756
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.compiler
+ * java.management/sun.management
+ * jdk.jvmstat/sun.jvmstat.monitor
* @build BooleanTest ClassFileInstaller sun.hotspot.WhiteBox com.oracle.java.testlibrary.*
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/testlibrary_tests/whitebox/vm_flags/DoubleTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/testlibrary_tests/whitebox/vm_flags/DoubleTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
* @test DoubleTest
* @bug 8028756
* @library /testlibrary /../../test/lib
+ * @modules java.management/sun.management
* @build DoubleTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/testlibrary_tests/whitebox/vm_flags/IntxTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/testlibrary_tests/whitebox/vm_flags/IntxTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
* @test IntxTest
* @bug 8028756
* @library /testlibrary /../../test/lib
+ * @modules java.management/sun.management
* @build IntxTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/testlibrary_tests/whitebox/vm_flags/SizeTTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/testlibrary_tests/whitebox/vm_flags/SizeTTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test SizeTTest
* @bug 8054823
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management/sun.management
* @build SizeTTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/testlibrary_tests/whitebox/vm_flags/StringTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/testlibrary_tests/whitebox/vm_flags/StringTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
* @test StringTest
* @bug 8028756
* @library /testlibrary /../../test/lib
+ * @modules java.management/sun.management
* @build StringTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/testlibrary_tests/whitebox/vm_flags/Uint64Test.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/testlibrary_tests/whitebox/vm_flags/Uint64Test.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
* @test Uint64Test
* @bug 8028756
* @library /testlibrary /../../test/lib
+ * @modules java.management/sun.management
* @build Uint64Test
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/testlibrary_tests/whitebox/vm_flags/UintxTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/hotspot/test/testlibrary_tests/whitebox/vm_flags/UintxTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test UintxTest
* @bug 8028756
* @library /testlibrary /../../test/lib
+ * @modules java.base/sun.misc
+ * java.management/sun.management
* @build UintxTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/jaxp/.hgtags Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxp/.hgtags Tue Apr 14 12:10:00 2015 -0700
@@ -300,3 +300,5 @@
2a460ce60ed47081f756f0cc0321d8e9ba7cac17 jdk9-b55
139092a10dedd32bc1155e40c67a6ef682e39873 jdk9-b56
2c417f7d7b0dc98e887474884aa39f974894f0c2 jdk9-b57
+270fb9a2dcb5ff3ef95da6d529fa35187026af0a jdk9-b58
+a1a9d943446911a4a0f74f0d082c32094af944ae jdk9-b59
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/BasisLibrary.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/BasisLibrary.java Tue Apr 14 12:10:00 2015 -0700
@@ -270,7 +270,7 @@
if (Double.isNaN(start))
return(EMPTYSTRING);
- final int strlen = value.length();
+ final int strlen = getStringLength(value);
int istart = (int)Math.round(start) - 1;
if (istart > strlen)
@@ -278,6 +278,7 @@
if (istart < 1)
istart = 0;
try {
+ istart = value.offsetByCodePoints(0, istart);
return value.substring(istart);
} catch (IndexOutOfBoundsException e) {
runTimeError(RUN_TIME_INTERNAL_ERR, "substring()");
@@ -297,24 +298,30 @@
return(EMPTYSTRING);
int istart = (int)Math.round(start) - 1;
+ int ilength = (int)Math.round(length);
final int isum;
if (Double.isInfinite(length))
isum = Integer.MAX_VALUE;
else
- isum = istart + (int)Math.round(length);
+ isum = istart + ilength;
- final int strlen = value.length();
+ final int strlen = getStringLength(value);
if (isum < 0 || istart > strlen)
return(EMPTYSTRING);
- if (istart < 0)
+ if (istart < 0) {
+ ilength += istart;
istart = 0;
+ }
try {
- if (isum > strlen)
+ istart = value.offsetByCodePoints(0, istart);
+ if (isum > strlen) {
return value.substring(istart);
- else
- return value.substring(istart, isum);
+ } else {
+ int offset = value.offsetByCodePoints(istart, ilength);
+ return value.substring(istart, offset);
+ }
} catch (IndexOutOfBoundsException e) {
runTimeError(RUN_TIME_INTERNAL_ERR, "substring()");
return null;
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java Tue Apr 14 12:10:00 2015 -0700
@@ -1417,7 +1417,7 @@
// AttValue
boolean isVC = !fStandalone && (fSeenExternalDTD || fSeenExternalPE) ;
scanAttributeValue(defaultVal, nonNormalizedDefaultVal, atName,
- fAttributes, 0, isVC);
+ fAttributes, 0, isVC, elName);
}
return defaultType;
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java Tue Apr 14 12:10:00 2015 -0700
@@ -1547,7 +1547,7 @@
scanAttributeValue(tmpStr, fTempString2,
fAttributeQName.rawname, attributes,
- attIndex, isVC);
+ attIndex, isVC, fCurrentElement.rawname);
// content
int oldLen = attributes.getLength();
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLNSDocumentScannerImpl.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLNSDocumentScannerImpl.java Tue Apr 14 12:10:00 2015 -0700
@@ -437,7 +437,7 @@
XMLString tmpStr = getString();
scanAttributeValue(tmpStr, fTempString2,
fAttributeQName.rawname, attributes,
- attrIndex, isVC);
+ attrIndex, isVC, fCurrentElement.rawname);
String value = null;
//fTempString.toString();
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLScanner.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLScanner.java Tue Apr 14 12:10:00 2015 -0700
@@ -811,6 +811,7 @@
* @param attrIndex The index of the attribute to use from the list.
* @param checkEntities true if undeclared entities should be reported as VC violation,
* false if undeclared entities should be reported as WFC violation.
+ * @param eleName The name of element to which this attribute belongs.
*
* <strong>Note:</strong> This method uses fStringBuffer2, anything in it
* at the time of calling is lost.
@@ -819,13 +820,13 @@
XMLString nonNormalizedValue,
String atName,
XMLAttributes attributes, int attrIndex,
- boolean checkEntities)
+ boolean checkEntities, String eleName)
throws IOException, XNIException {
XMLStringBuffer stringBuffer = null;
// quote
int quote = fEntityScanner.peekChar();
if (quote != '\'' && quote != '"') {
- reportFatalError("OpenQuoteExpected", new Object[]{atName});
+ reportFatalError("OpenQuoteExpected", new Object[]{eleName, atName});
}
fEntityScanner.scanChar();
@@ -951,7 +952,7 @@
}
} else if (c == '<') {
reportFatalError("LessthanInAttValue",
- new Object[] { null, atName });
+ new Object[] { eleName, atName });
fEntityScanner.scanChar();
if (entityDepth == fEntityDepth && fNeedNonNormalizedValue) {
fStringBuffer2.append((char)c);
@@ -987,7 +988,7 @@
}
} else if (c != -1 && isInvalidLiteral(c)) {
reportFatalError("InvalidCharInAttValue",
- new Object[] {Integer.toString(c, 16)});
+ new Object[] {eleName, atName, Integer.toString(c, 16)});
fEntityScanner.scanChar();
if (entityDepth == fEntityDepth && fNeedNonNormalizedValue) {
fStringBuffer2.append((char)c);
@@ -1016,7 +1017,7 @@
// quote
int cquote = fEntityScanner.scanChar();
if (cquote != quote) {
- reportFatalError("CloseQuoteExpected", new Object[]{atName});
+ reportFatalError("CloseQuoteExpected", new Object[]{eleName, atName});
}
} // scanAttributeValue()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/parsers/Bug8073385.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package javax.xml.parsers;
+
+import java.io.StringReader;
+import java.util.Locale;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
+import org.xml.sax.SAXException;
+import org.xml.sax.InputSource;
+
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+import static org.testng.Assert.assertTrue;
+
+/**
+ * @bug 8073385
+ * @summary test that invalid XML character exception string contains
+ * information about character value, element and attribute names
+ */
+public class Bug8073385 {
+
+ private Locale defLoc;
+
+ @BeforeClass
+ private void setup() {
+ defLoc = Locale.getDefault();
+ Locale.setDefault(Locale.ENGLISH);
+ }
+
+ @AfterClass
+ private void cleanup() {
+ Locale.setDefault(defLoc);
+ }
+
+ @DataProvider(name = "illegalCharactersData")
+ public static Object[][] illegalCharactersData() {
+ return new Object[][]{
+ {0x00},
+ {0xFFFE},
+ {0xFFFF}
+ };
+ }
+
+ @Test(dataProvider = "illegalCharactersData")
+ public void test(int character) throws Exception {
+ // Construct the XML document as a String
+ int[] cps = new int[]{character};
+ String txt = new String(cps, 0, cps.length);
+ String inxml = "<topElement attTest=\'" + txt + "\'/>";
+ String exceptionText = "NO EXCEPTION OBSERVED";
+ String hexString = "0x" + Integer.toHexString(character);
+
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+ dbf.setValidating(false);
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ InputSource isrc = new InputSource(new StringReader(inxml));
+
+ try {
+ db.parse(isrc);
+ } catch (SAXException e) {
+ exceptionText = e.toString();
+ }
+ System.out.println("Got Exception:" + exceptionText);
+ assertTrue(exceptionText.contains("attribute \"attTest\""));
+ assertTrue(exceptionText.contains("element is \"topElement\""));
+ assertTrue(exceptionText.contains("Unicode: " + hexString));
+ }
+}
--- a/jaxws/.hgtags Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/.hgtags Tue Apr 14 12:10:00 2015 -0700
@@ -303,3 +303,5 @@
ca481b0492c82cc38fa0e6b746305ed88c26b4fd jdk9-b55
b4f913b48e699980bd11fe19cce134d0adb4c31c jdk9-b56
17c4241395e97312bd75e7acd693ffcdd41ae993 jdk9-b57
+1e06b36bb396c0495e0774f1c6b0356d03847659 jdk9-b58
+8a9ebae410bc388668fc203e559b5407bde757eb jdk9-b59
--- a/jaxws/src/java.xml.bind/share/classes/com/sun/xml/internal/bind/v2/ClassFactory.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.bind/share/classes/com/sun/xml/internal/bind/v2/ClassFactory.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,8 +30,6 @@
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.ref.WeakReference;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
import java.util.Map;
import java.util.WeakHashMap;
import java.util.logging.Level;
@@ -87,25 +85,19 @@
if(consRef!=null)
cons = consRef.get();
if(cons==null) {
- cons = AccessController.doPrivileged(new PrivilegedAction<Constructor<T>>() {
- @Override
- public Constructor<T> run() {
- try {
- return clazz.getDeclaredConstructor(emptyClass);
- } catch (NoSuchMethodException e) {
- logger.log(Level.INFO,"No default constructor found on "+clazz,e);
- NoSuchMethodError exp;
- if(clazz.getDeclaringClass()!=null && !Modifier.isStatic(clazz.getModifiers())) {
- exp = new NoSuchMethodError(Messages.NO_DEFAULT_CONSTRUCTOR_IN_INNER_CLASS
- .format(clazz.getName()));
- } else {
- exp = new NoSuchMethodError(e.getMessage());
- }
- exp.initCause(e);
- throw exp;
- }
+ try {
+ cons = clazz.getDeclaredConstructor(emptyClass);
+ } catch (NoSuchMethodException e) {
+ logger.log(Level.INFO,"No default constructor found on "+clazz,e);
+ NoSuchMethodError exp;
+ if(clazz.getDeclaringClass()!=null && !Modifier.isStatic(clazz.getModifiers())) {
+ exp = new NoSuchMethodError(Messages.NO_DEFAULT_CONSTRUCTOR_IN_INNER_CLASS.format(clazz.getName()));
+ } else {
+ exp = new NoSuchMethodError(e.getMessage());
}
- });
+ exp.initCause(e);
+ throw exp;
+ }
int classMod = clazz.getModifiers();
--- a/jaxws/src/java.xml.bind/share/classes/com/sun/xml/internal/org/jvnet/mimepull/MIMEMessage.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.bind/share/classes/com/sun/xml/internal/org/jvnet/mimepull/MIMEMessage.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,12 +25,18 @@
package com.sun.xml.internal.org.jvnet.mimepull;
+import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.ByteBuffer;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -40,19 +46,21 @@
*
* @author Jitendra Kotamraju
*/
-public class MIMEMessage {
+public class MIMEMessage implements Closeable {
+
private static final Logger LOGGER = Logger.getLogger(MIMEMessage.class.getName());
MIMEConfig config;
private final InputStream in;
- private final List<MIMEPart> partsList;
- private final Map<String, MIMEPart> partsMap;
private final Iterator<MIMEEvent> it;
private boolean parsed; // true when entire message is parsed
private MIMEPart currentPart;
private int currentIndex;
+ private final List<MIMEPart> partsList = new ArrayList<MIMEPart>();
+ private final Map<String, MIMEPart> partsMap = new HashMap<String, MIMEPart>();
+
/**
* @see MIMEMessage(InputStream, String, MIMEConfig)
*/
@@ -64,9 +72,9 @@
* Creates a MIME message from the content's stream. The content stream
* is closed when EOF is reached.
*
- * @param in MIME message stream
+ * @param in MIME message stream
* @param boundary the separator for parts(pass it without --)
- * @param config various configuration parameters
+ * @param config various configuration parameters
*/
public MIMEMessage(InputStream in, String boundary, MIMEConfig config) {
this.in = in;
@@ -74,8 +82,6 @@
MIMEParser parser = new MIMEParser(in, boundary, config);
it = parser.iterator();
- partsList = new ArrayList<MIMEPart>();
- partsMap = new HashMap<String, MIMEPart>();
if (config.isParseEagerly()) {
parseAll();
}
@@ -108,14 +114,14 @@
LOGGER.log(Level.FINE, "index={0}", index);
MIMEPart part = (index < partsList.size()) ? partsList.get(index) : null;
if (parsed && part == null) {
- throw new MIMEParsingException("There is no "+index+" attachment part ");
+ throw new MIMEParsingException("There is no " + index + " attachment part ");
}
if (part == null) {
// Parsing will done lazily and will be driven by reading the part
part = new MIMEPart(this);
partsList.add(index, part);
}
- LOGGER.log(Level.FINE, "Got attachment at index={0} attachment={1}", new Object[]{index, part});
+ LOGGER.log(Level.FINE, "Got attachment at index={0} attachment={1}", new Object[] {index, part});
return part;
}
@@ -132,14 +138,14 @@
LOGGER.log(Level.FINE, "Content-ID={0}", contentId);
MIMEPart part = getDecodedCidPart(contentId);
if (parsed && part == null) {
- throw new MIMEParsingException("There is no attachment part with Content-ID = "+contentId);
+ throw new MIMEParsingException("There is no attachment part with Content-ID = " + contentId);
}
if (part == null) {
// Parsing is done lazily and is driven by reading the part
part = new MIMEPart(this, contentId);
partsMap.put(contentId, part);
}
- LOGGER.log(Level.FINE, "Got attachment for Content-ID={0} attachment={1}", new Object[]{contentId, part});
+ LOGGER.log(Level.FINE, "Got attachment for Content-ID={0} attachment={1}", new Object[] {contentId, part});
return part;
}
@@ -151,7 +157,7 @@
try {
String tempCid = URLDecoder.decode(cid, "utf-8");
part = partsMap.get(tempCid);
- } catch(UnsupportedEncodingException ue) {
+ } catch (UnsupportedEncodingException ue) {
// Ignore it
}
}
@@ -159,22 +165,43 @@
return part;
}
-
/**
* Parses the whole MIME message eagerly
*/
public final void parseAll() {
- while(makeProgress()) {
+ while (makeProgress()) {
// Nothing to do
}
}
+ /**
+ * Closes all parsed {@link com.sun.xml.internal.org.jvnet.mimepull.MIMEPart parts}.
+ * This method is safe to call even if parsing of message failed.
+ * <p/>
+ * Does not throw {@link com.sun.xml.internal.org.jvnet.mimepull.MIMEParsingException} if an
+ * error occurred during closing a MIME part. The exception (if any) is
+ * still logged.
+ */
+ @Override
+ public void close() {
+ close(partsList);
+ close(partsMap.values());
+ }
+
+ private void close(final Collection<MIMEPart> parts) {
+ for (final MIMEPart part : parts) {
+ try {
+ part.close();
+ } catch (final MIMEParsingException closeError) {
+ LOGGER.log(Level.FINE, "Exception during closing MIME part", closeError);
+ }
+ }
+ }
/**
* Parses the MIME message in a pull fashion.
*
- * @return
- * false if the parsing is completed.
+ * @return false if the parsing is completed.
*/
public synchronized boolean makeProgress() {
if (!it.hasNext()) {
@@ -183,23 +210,23 @@
MIMEEvent event = it.next();
- switch(event.getEventType()) {
- case START_MESSAGE :
+ switch (event.getEventType()) {
+ case START_MESSAGE:
LOGGER.log(Level.FINE, "MIMEEvent={0}", MIMEEvent.EVENT_TYPE.START_MESSAGE);
break;
- case START_PART :
+ case START_PART:
LOGGER.log(Level.FINE, "MIMEEvent={0}", MIMEEvent.EVENT_TYPE.START_PART);
break;
- case HEADERS :
+ case HEADERS:
LOGGER.log(Level.FINE, "MIMEEvent={0}", MIMEEvent.EVENT_TYPE.HEADERS);
- MIMEEvent.Headers headers = (MIMEEvent.Headers)event;
+ MIMEEvent.Headers headers = (MIMEEvent.Headers) event;
InternetHeaders ih = headers.getHeaders();
List<String> cids = ih.getHeader("content-id");
- String cid = (cids != null) ? cids.get(0) : currentIndex+"";
- if (cid.length() > 2 && cid.charAt(0)=='<') {
- cid = cid.substring(1,cid.length()-1);
+ String cid = (cids != null) ? cids.get(0) : currentIndex + "";
+ if (cid.length() > 2 && cid.charAt(0) == '<') {
+ cid = cid.substring(1, cid.length() - 1);
}
MIMEPart listPart = (currentIndex < partsList.size()) ? partsList.get(currentIndex) : null;
MIMEPart mapPart = getDecodedCidPart(cid);
@@ -219,31 +246,31 @@
currentPart.setHeaders(ih);
break;
- case CONTENT :
+ case CONTENT:
LOGGER.log(Level.FINER, "MIMEEvent={0}", MIMEEvent.EVENT_TYPE.CONTENT);
- MIMEEvent.Content content = (MIMEEvent.Content)event;
+ MIMEEvent.Content content = (MIMEEvent.Content) event;
ByteBuffer buf = content.getData();
currentPart.addBody(buf);
break;
- case END_PART :
+ case END_PART:
LOGGER.log(Level.FINE, "MIMEEvent={0}", MIMEEvent.EVENT_TYPE.END_PART);
currentPart.doneParsing();
++currentIndex;
break;
- case END_MESSAGE :
+ case END_MESSAGE:
LOGGER.log(Level.FINE, "MIMEEvent={0}", MIMEEvent.EVENT_TYPE.END_MESSAGE);
parsed = true;
try {
in.close();
- } catch(IOException ioe) {
+ } catch (IOException ioe) {
throw new MIMEParsingException(ioe);
}
break;
- default :
- throw new MIMEParsingException("Unknown Parser state = "+event.getEventType());
+ default:
+ throw new MIMEParsingException("Unknown Parser state = " + event.getEventType());
}
return true;
}
--- a/jaxws/src/java.xml.bind/share/classes/com/sun/xml/internal/org/jvnet/mimepull/MIMEPart.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.bind/share/classes/com/sun/xml/internal/org/jvnet/mimepull/MIMEPart.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
package com.sun.xml.internal.org.jvnet.mimepull;
+import java.io.Closeable;
import java.io.File;
import java.io.InputStream;
import java.nio.ByteBuffer;
@@ -42,10 +43,11 @@
*
* @author Jitendra Kotamraju, Martin Grebac
*/
-public class MIMEPart {
+public class MIMEPart implements Closeable {
private static final Logger LOGGER = Logger.getLogger(MIMEPart.class.getName());
+ private volatile boolean closed;
private volatile InternetHeaders headers;
private volatile String contentId;
private String contentType;
@@ -55,6 +57,8 @@
final MIMEMessage msg;
private final DataHead dataHead;
+ private final Object lock = new Object();
+
MIMEPart(MIMEMessage msg) {
this.msg = msg;
this.dataHead = new DataHead(this);
@@ -91,8 +95,16 @@
* the temp file that is used to serve this part's content). After
* calling this, one shouldn't call {@link #read()} or {@link #readOnce()}
*/
+ @Override
public void close() {
- dataHead.close();
+ if (!closed) {
+ synchronized (lock) {
+ if (!closed) {
+ dataHead.close();
+ closed = true;
+ }
+ }
+ }
}
/**
@@ -242,6 +254,15 @@
this.contentTransferEncoding = cte;
}
+ /**
+ * Return {@code true} if this part has already been closed, {@code false} otherwise.
+ *
+ * @return {@code true} if this part has already been closed, {@code false} otherwise.
+ */
+ public boolean isClosed() {
+ return closed;
+ }
+
@Override
public String toString() {
return "Part="+contentId+":"+contentTransferEncoding;
--- a/jaxws/src/java.xml.bind/share/classes/com/sun/xml/internal/org/jvnet/mimepull/MemoryData.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.bind/share/classes/com/sun/xml/internal/org/jvnet/mimepull/MemoryData.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -84,9 +84,6 @@
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE, "Created temp file = {0}", tempFile);
}
- // delete the temp file when VM exits as a last resort for file clean up
- tempFile.deleteOnExit();
- if (LOGGER.isLoggable(Level.FINE)) {LOGGER.log(Level.FINE, "Created temp file = {0}", tempFile);}
dataHead.dataFile = new DataFile(tempFile);
} catch (IOException ioe) {
throw new MIMEParsingException(ioe);
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/ContextFinder.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/ContextFinder.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,6 @@
package javax.xml.bind;
-import java.util.Iterator;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@@ -34,15 +33,13 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
+import java.security.AccessController;
import java.util.Map;
import java.util.Properties;
import java.util.StringTokenizer;
import java.util.logging.ConsoleHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
-import java.security.AccessController;
-
-import static javax.xml.bind.JAXBContext.JAXB_CONTEXT_FACTORY;
/**
@@ -55,7 +52,24 @@
* @see JAXBContext
*/
class ContextFinder {
+
+ /**
+ * When JAXB is in J2SE, rt.jar has to have a JAXB implementation.
+ * However, rt.jar cannot have META-INF/services/javax.xml.bind.JAXBContext
+ * because if it has, it will take precedence over any file that applications have
+ * in their jar files.
+ *
+ * <p>
+ * When the user bundles his own JAXB implementation, we'd like to use it, and we
+ * want the platform default to be used only when there's no other JAXB provider.
+ *
+ * <p>
+ * For this reason, we have to hard-code the class name into the API.
+ */
+ private static final String PLATFORM_DEFAULT_FACTORY_CLASS = "com.sun.xml.internal.bind.v2.ContextFactory";
+
private static final Logger logger;
+
static {
logger = Logger.getLogger("javax.xml.bind");
try {
@@ -72,7 +86,7 @@
// to honor what other frameworks
// have done on configurations.
}
- } catch(Throwable t) {
+ } catch (Throwable t) {
// just to be extra safe. in particular System.getProperty may throw
// SecurityException.
}
@@ -84,15 +98,15 @@
*/
private static void handleInvocationTargetException(InvocationTargetException x) throws JAXBException {
Throwable t = x.getTargetException();
- if( t != null ) {
- if( t instanceof JAXBException )
+ if (t != null) {
+ if (t instanceof JAXBException)
// one of our exceptions, just re-throw
- throw (JAXBException)t;
- if( t instanceof RuntimeException )
+ throw (JAXBException) t;
+ if (t instanceof RuntimeException)
// avoid wrapping exceptions unnecessarily
- throw (RuntimeException)t;
- if( t instanceof Error )
- throw (Error)t;
+ throw (RuntimeException) t;
+ if (t instanceof Error)
+ throw (Error) t;
}
}
@@ -121,18 +135,17 @@
/**
* Create an instance of a class using the specified ClassLoader
*/
- static JAXBContext newInstance( String contextPath,
- String className,
- ClassLoader classLoader,
- Map properties )
- throws JAXBException {
+ static JAXBContext newInstance(String contextPath,
+ String className,
+ ClassLoader classLoader,
+ Map properties) throws JAXBException {
+
try {
- Class spFactory = safeLoadClass(className,classLoader);
+ Class spFactory = ServiceLoaderUtil.safeLoadClass(className, PLATFORM_DEFAULT_FACTORY_CLASS, classLoader);
return newInstance(contextPath, spFactory, classLoader, properties);
} catch (ClassNotFoundException x) {
- throw new JAXBException(
- Messages.format( Messages.PROVIDER_NOT_FOUND, className ),
- x);
+ throw new JAXBException(Messages.format(Messages.PROVIDER_NOT_FOUND, className), x);
+
} catch (RuntimeException x) {
// avoid wrapping RuntimeException to JAXBException,
// because it indicates a bug in this code.
@@ -142,18 +155,12 @@
// reflection. Root element collisions detected in the call to
// createContext() are reported as JAXBExceptions - just re-throw it
// some other type of exception - just wrap it
- throw new JAXBException(
- Messages.format( Messages.COULD_NOT_INSTANTIATE, className, x ),
- x);
+ throw new JAXBException(Messages.format(Messages.COULD_NOT_INSTANTIATE, className, x), x);
}
}
- static JAXBContext newInstance( String contextPath,
- Class spFactory,
- ClassLoader classLoader,
- Map properties )
- throws JAXBException
- {
+ static JAXBContext newInstance(String contextPath, Class spFactory, ClassLoader classLoader, Map properties) throws JAXBException {
+
try {
/*
* javax.xml.bind.context.factory points to a class which has a
@@ -166,35 +173,35 @@
// first check the method that takes Map as the third parameter.
// this is added in 2.0.
try {
- Method m = spFactory.getMethod("createContext",String.class,ClassLoader.class,Map.class);
+ Method m = spFactory.getMethod("createContext", String.class, ClassLoader.class, Map.class);
// any failure in invoking this method would be considered fatal
- context = m.invoke(null,contextPath,classLoader,properties);
+ context = m.invoke(null, contextPath, classLoader, properties);
} catch (NoSuchMethodException e) {
// it's not an error for the provider not to have this method.
}
- if(context==null) {
+ if (context == null) {
// try the old method that doesn't take properties. compatible with 1.0.
// it is an error for an implementation not to have both forms of the createContext method.
- Method m = spFactory.getMethod("createContext",String.class,ClassLoader.class);
+ Method m = spFactory.getMethod("createContext", String.class, ClassLoader.class);
// any failure in invoking this method would be considered fatal
- context = m.invoke(null,contextPath,classLoader);
+ context = m.invoke(null, contextPath, classLoader);
}
- if(!(context instanceof JAXBContext)) {
+ if (!(context instanceof JAXBContext)) {
// the cast would fail, so generate an exception with a nice message
throw handleClassCastException(context.getClass(), JAXBContext.class);
}
- return (JAXBContext)context;
+ return (JAXBContext) context;
} catch (InvocationTargetException x) {
handleInvocationTargetException(x);
// for other exceptions, wrap the internal target exception
// with a JAXBException
Throwable e = x;
- if(x.getTargetException()!=null)
+ if (x.getTargetException() != null)
e = x.getTargetException();
- throw new JAXBException( Messages.format( Messages.COULD_NOT_INSTANTIATE, spFactory, e ), e );
+ throw new JAXBException(Messages.format(Messages.COULD_NOT_INSTANTIATE, spFactory, e), e);
} catch (RuntimeException x) {
// avoid wrapping RuntimeException to JAXBException,
// because it indicates a bug in this code.
@@ -204,29 +211,23 @@
// reflection. Root element collisions detected in the call to
// createContext() are reported as JAXBExceptions - just re-throw it
// some other type of exception - just wrap it
- throw new JAXBException(
- Messages.format( Messages.COULD_NOT_INSTANTIATE, spFactory, x ),
- x);
+ throw new JAXBException(Messages.format(Messages.COULD_NOT_INSTANTIATE, spFactory, x), x);
}
}
-
/**
* Create an instance of a class using the thread context ClassLoader
*/
- static JAXBContext newInstance(
- Class[] classes,
- Map properties,
- String className) throws JAXBException {
- ClassLoader cl = getContextClassLoader();
+ static JAXBContext newInstance(Class[] classes, Map properties, String className) throws JAXBException {
+
Class spi;
try {
- spi = safeLoadClass(className,cl);
+ spi = ServiceLoaderUtil.safeLoadClass(className, PLATFORM_DEFAULT_FACTORY_CLASS, getContextClassLoader());
} catch (ClassNotFoundException e) {
throw new JAXBException(e);
}
- if(logger.isLoggable(Level.FINE)) {
+ if (logger.isLoggable(Level.FINE)) {
// extra check to avoid costly which operation if not logged
logger.log(Level.FINE, "loaded {0} from {1}", new Object[]{className, which(spi)});
}
@@ -237,19 +238,16 @@
static JAXBContext newInstance(Class[] classes,
Map properties,
Class spFactory) throws JAXBException {
- Method m;
try {
- m = spFactory.getMethod("createContext", Class[].class, Map.class);
- } catch (NoSuchMethodException e) {
- throw new JAXBException(e);
- }
- try {
+ Method m = spFactory.getMethod("createContext", Class[].class, Map.class);
Object context = m.invoke(null, classes, properties);
- if(!(context instanceof JAXBContext)) {
+ if (!(context instanceof JAXBContext)) {
// the cast would fail, so generate an exception with a nice message
throw handleClassCastException(context.getClass(), JAXBContext.class);
}
- return (JAXBContext)context;
+ return (JAXBContext) context;
+ } catch (NoSuchMethodException e) {
+ throw new JAXBException(e);
} catch (IllegalAccessException e) {
throw new JAXBException(e);
} catch (InvocationTargetException e) {
@@ -263,241 +261,139 @@
}
}
- static JAXBContext find(String factoryId, String contextPath, ClassLoader classLoader, Map properties ) throws JAXBException {
+ static JAXBContext find(String factoryId, String contextPath, ClassLoader classLoader, Map properties) throws JAXBException {
// TODO: do we want/need another layer of searching in $java.home/lib/jaxb.properties like JAXP?
- final String jaxbContextFQCN = JAXBContext.class.getName();
-
- // search context path for jaxb.properties first
- StringBuilder propFileName;
- StringTokenizer packages = new StringTokenizer( contextPath, ":" );
- String factoryClassName;
-
- if(!packages.hasMoreTokens())
+ StringTokenizer packages = new StringTokenizer(contextPath, ":");
+ if (!packages.hasMoreTokens()) {
// no context is specified
throw new JAXBException(Messages.format(Messages.NO_PACKAGE_IN_CONTEXTPATH));
-
-
- logger.fine("Searching jaxb.properties");
-
- while( packages.hasMoreTokens() ) {
- String packageName = packages.nextToken(":").replace('.','/');
- // com.acme.foo - > com/acme/foo/jaxb.properties
- propFileName = new StringBuilder().append(packageName).append("/jaxb.properties");
+ }
- Properties props = loadJAXBProperties( classLoader, propFileName.toString() );
- if (props != null) {
- if (props.containsKey(factoryId)) {
- factoryClassName = props.getProperty(factoryId);
- return newInstance( contextPath, factoryClassName, classLoader, properties );
- } else {
- throw new JAXBException(Messages.format(Messages.MISSING_PROPERTY, packageName, factoryId));
- }
- }
+ // search for jaxb.properties in the class loader of each class first
+ logger.fine("Searching jaxb.properties");
+ while (packages.hasMoreTokens()) {
+ // com.acme.foo - > com/acme/foo/jaxb.properties
+ String className = classNameFromPackageProperties(factoryId, classLoader, packages.nextToken(":").replace('.', '/'));
+ if (className != null) return newInstance(contextPath, className, classLoader, properties);
}
- logger.fine("Searching the system property");
+ String factoryName = classNameFromSystemProperties();
+ if (factoryName != null) return newInstance(contextPath, factoryName, classLoader, properties);
- // search for a system property second (javax.xml.bind.JAXBContext)
- factoryClassName = AccessController.doPrivileged(new GetPropertyAction(JAXBContext.JAXB_CONTEXT_FACTORY));
- if( factoryClassName != null ) {
- return newInstance( contextPath, factoryClassName, classLoader, properties );
- } else { // leave this here to assure compatibility
- factoryClassName = AccessController.doPrivileged(new GetPropertyAction(jaxbContextFQCN));
- if( factoryClassName != null ) {
- return newInstance( contextPath, factoryClassName, classLoader, properties );
- }
- }
-
- // OSGi search
- Class jaxbContext = lookupJaxbContextUsingOsgiServiceLoader();
- if (jaxbContext != null) {
- logger.fine("OSGi environment detected");
- return newInstance(contextPath, jaxbContext, classLoader, properties);
+ Class ctxFactory = (Class) ServiceLoaderUtil.lookupUsingOSGiServiceLoader("javax.xml.bind.JAXBContext", logger);
+ if (ctxFactory != null) {
+ return newInstance(contextPath, ctxFactory, classLoader, properties);
}
- logger.fine("Searching META-INF/services");
- // search META-INF services next
- BufferedReader r = null;
- try {
- final StringBuilder resource = new StringBuilder().append("META-INF/services/").append(jaxbContextFQCN);
- final InputStream resourceStream =
- classLoader.getResourceAsStream(resource.toString());
+ // TODO: SPEC change required! This is supposed to be!
+ // JAXBContext obj = firstByServiceLoader(JAXBContext.class, EXCEPTION_HANDLER);
+ // if (obj != null) return obj;
- if (resourceStream != null) {
- r = new BufferedReader(new InputStreamReader(resourceStream, "UTF-8"));
- factoryClassName = r.readLine();
- if (factoryClassName != null) {
- factoryClassName = factoryClassName.trim();
- }
- r.close();
- return newInstance(contextPath, factoryClassName, classLoader, properties);
- } else {
- logger.log(Level.FINE, "Unable to load:{0}", resource.toString());
- }
- } catch (UnsupportedEncodingException e) {
- // should never happen
- throw new JAXBException(e);
- } catch (IOException e) {
- throw new JAXBException(e);
- } finally {
- try {
- if (r != null) {
- r.close();
- }
- } catch (IOException ex) {
- Logger.getLogger(ContextFinder.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
+ // TODO: Deprecated - SPEC change required!
+ factoryName = firstByServiceLoaderDeprecated(JAXBContext.class, classLoader);
+ if (factoryName != null) return newInstance(contextPath, factoryName, classLoader, properties);
// else no provider found
logger.fine("Trying to create the platform default provider");
return newInstance(contextPath, PLATFORM_DEFAULT_FACTORY_CLASS, classLoader, properties);
}
- static JAXBContext find( Class[] classes, Map properties ) throws JAXBException {
-
- final String jaxbContextFQCN = JAXBContext.class.getName();
- String factoryClassName;
+ static JAXBContext find(Class[] classes, Map properties) throws JAXBException {
// search for jaxb.properties in the class loader of each class first
+ logger.fine("Searching jaxb.properties");
for (final Class c : classes) {
// this classloader is used only to load jaxb.properties, so doing this should be safe.
- ClassLoader classLoader = getClassClassLoader(c);
- Package pkg = c.getPackage();
- if(pkg==null)
- continue; // this is possible for primitives, arrays, and classes that are loaded by poorly implemented ClassLoaders
- String packageName = pkg.getName().replace('.', '/');
+ if (c.getPackage() == null) continue; // this is possible for primitives, arrays, and classes that are loaded by poorly implemented ClassLoaders
// TODO: do we want to optimize away searching the same package? org.Foo, org.Bar, com.Baz
- // classes from the same package might come from different class loades, so it might be a bad idea
-
+ // classes from the same package might come from different class loades, so it might be a bad idea
// TODO: it's easier to look things up from the class
// c.getResourceAsStream("jaxb.properties");
- // build the resource name and use the property loader code
- String resourceName = packageName+"/jaxb.properties";
- logger.log(Level.FINE, "Trying to locate {0}", resourceName);
- Properties props = loadJAXBProperties(classLoader, resourceName);
- if (props == null) {
- logger.fine(" not found");
- } else {
- logger.fine(" found");
- if (props.containsKey(JAXB_CONTEXT_FACTORY)) {
- // trim() seems redundant, but adding to satisfy customer complaint
- factoryClassName = props.getProperty(JAXB_CONTEXT_FACTORY).trim();
- return newInstance(classes, properties, factoryClassName);
- } else {
- throw new JAXBException(Messages.format(Messages.MISSING_PROPERTY, packageName, JAXB_CONTEXT_FACTORY));
- }
- }
- }
-
- // search for a system property second (javax.xml.bind.JAXBContext)
- logger.log(Level.FINE, "Checking system property {0}", JAXBContext.JAXB_CONTEXT_FACTORY);
- factoryClassName = AccessController.doPrivileged(new GetPropertyAction(JAXBContext.JAXB_CONTEXT_FACTORY));
- if (factoryClassName != null) {
- logger.log(Level.FINE, " found {0}", factoryClassName);
- return newInstance( classes, properties, factoryClassName );
- } else { // leave it here for compatibility reasons
- logger.fine(" not found");
- logger.log(Level.FINE, "Checking system property {0}", jaxbContextFQCN);
- factoryClassName = AccessController.doPrivileged(new GetPropertyAction(jaxbContextFQCN));
- if (factoryClassName != null) {
- logger.log(Level.FINE, " found {0}", factoryClassName);
- return newInstance( classes, properties, factoryClassName );
- } else {
- logger.fine(" not found");
- }
+ String className = classNameFromPackageProperties(JAXBContext.JAXB_CONTEXT_FACTORY, getClassClassLoader(c), c.getPackage().getName().replace('.', '/'));
+ if (className != null) return newInstance(classes, properties, className);
}
- // OSGi search
- Class jaxbContext = lookupJaxbContextUsingOsgiServiceLoader();
- if (jaxbContext != null) {
- logger.fine("OSGi environment detected");
- return newInstance(classes, properties, jaxbContext);
+ String factoryName = classNameFromSystemProperties();
+ if (factoryName != null) return newInstance(classes, properties, factoryName);
+
+ Class ctxFactoryClass = (Class) ServiceLoaderUtil.lookupUsingOSGiServiceLoader("javax.xml.bind.JAXBContext", logger);
+ if (ctxFactoryClass != null) {
+ return newInstance(classes, properties, ctxFactoryClass);
}
- // search META-INF services next
- logger.fine("Checking META-INF/services");
- BufferedReader r = null;
- try {
- final String resource = new StringBuilder("META-INF/services/").append(jaxbContextFQCN).toString();
- ClassLoader classLoader = getContextClassLoader();
- URL resourceURL;
- if(classLoader==null)
- resourceURL = ClassLoader.getSystemResource(resource);
- else
- resourceURL = classLoader.getResource(resource);
+ // TODO: to be removed - deprecated!!! Requires SPEC change!!!
+ String className = firstByServiceLoaderDeprecated(JAXBContext.class, getContextClassLoader());
+ if (className != null) return newInstance(classes, properties, className);
- if (resourceURL != null) {
- logger.log(Level.FINE, "Reading {0}", resourceURL);
- r = new BufferedReader(new InputStreamReader(resourceURL.openStream(), "UTF-8"));
- factoryClassName = r.readLine();
- if (factoryClassName != null) {
- factoryClassName = factoryClassName.trim();
- }
- return newInstance(classes, properties, factoryClassName);
- } else {
- logger.log(Level.FINE, "Unable to find: {0}", resource);
- }
- } catch (UnsupportedEncodingException e) {
- // should never happen
- throw new JAXBException(e);
- } catch (IOException e) {
- throw new JAXBException(e);
- } finally {
- if (r != null) {
- try {
- r.close();
- } catch (IOException ex) {
- logger.log(Level.FINE, "Unable to close stream", ex);
- }
- }
- }
+ // // TODO: supposed to be:
+ // obj = firstByServiceLoader(JAXBContext.class, EXCEPTION_HANDLER);
+ // if (obj != null) return obj;
// else no provider found
logger.fine("Trying to create the platform default provider");
return newInstance(classes, properties, PLATFORM_DEFAULT_FACTORY_CLASS);
}
- private static Class lookupJaxbContextUsingOsgiServiceLoader() {
- try {
- // Use reflection to avoid having any dependency on ServiceLoader class
- Class target = Class.forName("com.sun.org.glassfish.hk2.osgiresourcelocator.ServiceLoader");
- Method m = target.getMethod("lookupProviderClasses", Class.class);
- Iterator iter = ((Iterable) m.invoke(null, JAXBContext.class)).iterator();
- return iter.hasNext() ? (Class)iter.next() : null;
- } catch(Exception e) {
- logger.log(Level.FINE, "Unable to find from OSGi: javax.xml.bind.JAXBContext");
- return null;
+
+ private static String classNameFromPackageProperties(String factoryId, ClassLoader classLoader, String packageName) throws JAXBException {
+ String resourceName = packageName + "/jaxb.properties";
+ logger.log(Level.FINE, "Trying to locate {0}", resourceName);
+ Properties props = loadJAXBProperties(classLoader, resourceName);
+ if (props != null) {
+ if (props.containsKey(factoryId)) {
+ return props.getProperty(factoryId);
+ } else {
+ throw new JAXBException(Messages.format(Messages.MISSING_PROPERTY, packageName, factoryId));
+ }
}
+ return null;
}
- private static Properties loadJAXBProperties( ClassLoader classLoader,
- String propFileName )
- throws JAXBException {
+ private static String classNameFromSystemProperties() throws JAXBException {
+ logger.log(Level.FINE, "Checking system property {0}", JAXBContext.JAXB_CONTEXT_FACTORY);
+ // search for a system property second (javax.xml.bind.JAXBContext)
+ String factoryClassName = AccessController.doPrivileged(new GetPropertyAction(JAXBContext.JAXB_CONTEXT_FACTORY));
+ if (factoryClassName != null) {
+ logger.log(Level.FINE, " found {0}", factoryClassName);
+ return factoryClassName;
+ } else { // leave this here to assure compatibility
+ logger.fine(" not found");
+ logger.log(Level.FINE, "Checking system property {0}", JAXBContext.class.getName());
+ factoryClassName = AccessController.doPrivileged(new GetPropertyAction(JAXBContext.class.getName()));
+ if (factoryClassName != null) {
+ logger.log(Level.FINE, " found {0}", factoryClassName);
+ return factoryClassName;
+ } else {
+ logger.fine(" not found");
+ }
+ }
+ return null;
+ }
+
+ private static Properties loadJAXBProperties(ClassLoader classLoader, String propFileName) throws JAXBException {
Properties props = null;
-
try {
URL url;
- if(classLoader==null)
+ if (classLoader == null)
url = ClassLoader.getSystemResource(propFileName);
else
- url = classLoader.getResource( propFileName );
+ url = classLoader.getResource(propFileName);
- if( url != null ) {
+ if (url != null) {
logger.log(Level.FINE, "loading props from {0}", url);
props = new Properties();
InputStream is = url.openStream();
- props.load( is );
+ props.load(is);
is.close();
}
- } catch( IOException ioe ) {
- logger.log(Level.FINE,"Unable to load "+propFileName,ioe);
- throw new JAXBException( ioe.toString(), ioe );
+ } catch (IOException ioe) {
+ logger.log(Level.FINE, "Unable to load " + propFileName, ioe);
+ throw new JAXBException(ioe.toString(), ioe);
}
return props;
@@ -520,7 +416,7 @@
String classnameAsResource = clazz.getName().replace('.', '/') + ".class";
- if(loader == null) {
+ if (loader == null) {
loader = getSystemClassLoader();
}
@@ -543,50 +439,7 @@
return which(clazz, getClassClassLoader(clazz));
}
- /**
- * When JAXB is in J2SE, rt.jar has to have a JAXB implementation.
- * However, rt.jar cannot have META-INF/services/javax.xml.bind.JAXBContext
- * because if it has, it will take precedence over any file that applications have
- * in their jar files.
- *
- * <p>
- * When the user bundles his own JAXB implementation, we'd like to use it, and we
- * want the platform default to be used only when there's no other JAXB provider.
- *
- * <p>
- * For this reason, we have to hard-code the class name into the API.
- */
- private static final String PLATFORM_DEFAULT_FACTORY_CLASS = "com.sun.xml.internal.bind.v2.ContextFactory";
-
- /**
- * Loads the class, provided that the calling thread has an access to the class being loaded.
- */
- private static Class safeLoadClass(String className, ClassLoader classLoader) throws ClassNotFoundException {
- logger.log(Level.FINE, "Trying to load {0}", className);
- try {
- // make sure that the current thread has an access to the package of the given name.
- SecurityManager s = System.getSecurityManager();
- if (s != null) {
- int i = className.lastIndexOf('.');
- if (i != -1) {
- s.checkPackageAccess(className.substring(0,i));
- }
- }
-
- if (classLoader == null) {
- return Class.forName(className);
- } else {
- return classLoader.loadClass(className);
- }
- } catch (SecurityException se) {
- // anyone can access the platform default factory class without permission
- if (PLATFORM_DEFAULT_FACTORY_CLASS.equals(className)) {
- return Class.forName(className);
- }
- throw se;
- }
- }
-
+ @SuppressWarnings("unchecked")
private static ClassLoader getContextClassLoader() {
if (System.getSecurityManager() == null) {
return Thread.currentThread().getContextClassLoader();
@@ -600,6 +453,7 @@
}
}
+ @SuppressWarnings("unchecked")
private static ClassLoader getClassClassLoader(final Class c) {
if (System.getSecurityManager() == null) {
return c.getClassLoader();
@@ -626,4 +480,50 @@
}
}
+ // TODO: to be removed - SPEC change required
+ // ServiceLoaderUtil.firstByServiceLoaderDeprecated should be used instead.
+ @Deprecated
+ static String firstByServiceLoaderDeprecated(Class spiClass, ClassLoader classLoader) throws JAXBException {
+ final String jaxbContextFQCN = spiClass.getName();
+
+ logger.fine("Searching META-INF/services");
+
+ // search META-INF services next
+ BufferedReader r = null;
+ final String resource = new StringBuilder().append("META-INF/services/").append(jaxbContextFQCN).toString();
+ try {
+ final InputStream resourceStream =
+ (classLoader == null) ?
+ ClassLoader.getSystemResourceAsStream(resource) :
+ classLoader.getResourceAsStream(resource);
+
+ if (resourceStream != null) {
+ r = new BufferedReader(new InputStreamReader(resourceStream, "UTF-8"));
+ String factoryClassName = r.readLine();
+ if (factoryClassName != null) {
+ factoryClassName = factoryClassName.trim();
+ }
+ r.close();
+ logger.log(Level.FINE, "Configured factorty class:{0}", factoryClassName);
+ return factoryClassName;
+ } else {
+ logger.log(Level.FINE, "Unable to load:{0}", resource);
+ return null;
+ }
+ } catch (UnsupportedEncodingException e) {
+ // should never happen
+ throw new JAXBException(e);
+ } catch (IOException e) {
+ throw new JAXBException(e);
+ } finally {
+ try {
+ if (r != null) {
+ r.close();
+ }
+ } catch (IOException ex) {
+ logger.log(Level.SEVERE, "Unable to close resource: " + resource, ex);
+ }
+ }
+ }
+
}
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/JAXBContext.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/JAXBContext.java Tue Apr 14 12:10:00 2015 -0700
@@ -63,10 +63,10 @@
* <i><B>SPEC REQUIREMENT:</B> the provider must supply an implementation
* class containing the following method signatures:</i>
*
- * <pre>
- * public static JAXBContext createContext( String contextPath, ClassLoader classLoader, Map<String,Object> properties ) throws JAXBException
- * public static JAXBContext createContext( Class[] classes, Map<String,Object> properties ) throws JAXBException
- * </pre>
+ * <pre>{@code
+ * public static JAXBContext createContext( String contextPath, ClassLoader classLoader, Map<String,Object> properties ) throws JAXBException
+ * public static JAXBContext createContext( Class[] classes, Map<String,Object> properties ) throws JAXBException
+ * }</pre>
*
* <p><i>
* The following JAXB 1.0 requirement is only required for schema to
@@ -352,7 +352,7 @@
* <p>
* To maintain compatibility with JAXB 1.0 schema to java
* interface/implementation binding, enabled by schema customization
- * <tt><jaxb:globalBindings valueClass="false"></tt>,
+ * <tt>{@literal <jaxb:globalBindings valueClass="false">}</tt>,
* the JAXB provider will ensure that each package on the context path
* has a <tt>jaxb.properties</tt> file which contains a value for the
* <tt>javax.xml.bind.context.factory</tt> property and that all values
@@ -526,7 +526,7 @@
* Not only the new context will recognize all the classes specified,
* but it will also recognize any classes that are directly/indirectly
* referenced statically from the specified classes. Subclasses of
- * referenced classes nor <tt>@XmlTransient</tt> referenced classes
+ * referenced classes nor <tt>@XmlTransient</tt> referenced classes
* are not registered with JAXBContext.
*
* For example, in the following Java code, if you do
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/JAXBIntrospector.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/JAXBIntrospector.java Tue Apr 14 12:10:00 2015 -0700
@@ -74,7 +74,7 @@
*
* <p>Convenience method to abstract whether working with either
* a javax.xml.bind.JAXBElement instance or an instance of
- * <tt>@XmlRootElement</tt> annotated Java class.</p>
+ * <tt>@XmlRootElement</tt> annotated Java class.</p>
*
* @param jaxbElement object that #isElement(Object) returns true.
*
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/SchemaOutputResolver.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/SchemaOutputResolver.java Tue Apr 14 12:10:00 2015 -0700
@@ -70,11 +70,11 @@
*
* If the {@link Result} object has a system ID, it must be an
* absolute system ID. Those system IDs are relativized by the caller and used
- * for <xs:import> statements.
+ * for {@literal <xs:import>} statements.
*
* If the {@link Result} object does not have a system ID, a schema
* for the namespace URI is generated but it won't be explicitly
- * <xs:import>ed from other schemas.
+ * {@literal <xs:import>}ed from other schemas.
*
* If {@code null} is returned, the schema generation for this
* namespace URI will be skipped.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/ServiceLoaderUtil.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package javax.xml.bind;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.ServiceLoader;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Shared ServiceLoader/FactoryFinder Utils shared among SAAJ, JAXB and JAXWS
+ * - this class must be duplicated to all those projects, but it's
+ * basically generic code and we want to have it everywhere same.
+ *
+ * @author Miroslav.Kos@oracle.com
+ */
+class ServiceLoaderUtil {
+
+ private static final String OSGI_SERVICE_LOADER_CLASS_NAME = "com.sun.org.glassfish.hk2.osgiresourcelocator.ServiceLoader";
+ private static final String OSGI_SERVICE_LOADER_METHOD_NAME = "lookupProviderClasses";
+
+ static <P> P firstByServiceLoader(Class<P> spiClass, Logger logger) {
+ // service discovery
+ ServiceLoader<P> serviceLoader = ServiceLoader.load(spiClass);
+ for (P impl : serviceLoader) {
+ logger.fine("ServiceProvider loading Facility used; returning object [" + impl.getClass().getName() + "]");
+ return impl;
+ }
+ return null;
+ }
+
+ static boolean isOsgi(Logger logger) {
+ try {
+ Class.forName(OSGI_SERVICE_LOADER_CLASS_NAME);
+ return true;
+ } catch (ClassNotFoundException ignored) {
+ logger.log(Level.FINE, "OSGi classes not found, OSGi not available.", ignored);
+ }
+ return false;
+ }
+
+ static Object lookupUsingOSGiServiceLoader(String factoryId, Logger logger) {
+ try {
+ // Use reflection to avoid having any dependendcy on ServiceLoader class
+ Class serviceClass = Class.forName(factoryId);
+ Class target = Class.forName(OSGI_SERVICE_LOADER_CLASS_NAME);
+ Method m = target.getMethod(OSGI_SERVICE_LOADER_METHOD_NAME, Class.class);
+ Iterator iter = ((Iterable) m.invoke(null, serviceClass)).iterator();
+ if (iter.hasNext()) {
+ Object next = iter.next();
+ logger.fine("Found implementation using OSGi facility; returning object [" + next.getClass().getName() + "].");
+ return next;
+ } else {
+ return null;
+ }
+ } catch (Exception ignored) {
+ logger.log(Level.FINE, "Unable to find from OSGi: [" + factoryId + "]", ignored);
+ return null;
+ }
+ }
+
+ static String propertyFileLookup(final String configFullPath, final String factoryId) throws IOException {
+ File f = new File(configFullPath);
+ String factoryClassName = null;
+ if (f.exists()) {
+ Properties props = new Properties();
+ FileInputStream stream = null;
+ try {
+ stream = new FileInputStream(f);
+ props.load(stream);
+ factoryClassName = props.getProperty(factoryId);
+ } finally {
+ if (stream != null) {
+ try {
+ stream.close();
+ } catch (IOException ignored) {
+ }
+ }
+ }
+ }
+ return factoryClassName;
+ }
+
+ static void checkPackageAccess(String className) {
+ // make sure that the current thread has an access to the package of the given name.
+ SecurityManager s = System.getSecurityManager();
+ if (s != null) {
+ int i = className.lastIndexOf('.');
+ if (i != -1) {
+ s.checkPackageAccess(className.substring(0, i));
+ }
+ }
+ }
+
+ static Class nullSafeLoadClass(String className, ClassLoader classLoader) throws ClassNotFoundException {
+ if (classLoader == null) {
+ return Class.forName(className);
+ } else {
+ return classLoader.loadClass(className);
+ }
+ }
+
+ /**
+ * Returns instance of required class. It checks package access (security) unless it is defaultClassname. It means if you
+ * are trying to instantiate default implementation (fallback), pass the class name to both first and second parameter.
+ *
+ * @param className class to be instantiated
+ * @param isDefaultClassname says whether default implementation class
+ * @param handler exception handler - necessary for wrapping exceptions and logging
+ * @param <T> Type of exception being thrown (necessary to distinguish between Runtime and checked exceptions)
+ * @return instantiated object or throws Runtime/checked exception, depending on ExceptionHandler's type
+ * @throws T
+ */
+ static <T extends Exception> Object newInstance(String className, String defaultImplClassName, final ExceptionHandler<T> handler) throws T {
+ try {
+ return safeLoadClass(className, defaultImplClassName, contextClassLoader(handler)).newInstance();
+ } catch (ClassNotFoundException x) {
+ throw handler.createException(x, "Provider " + className + " not found");
+ } catch (Exception x) {
+ throw handler.createException(x, "Provider " + className + " could not be instantiated: " + x);
+ }
+ }
+
+ static Class safeLoadClass(String className, String defaultImplClassName, ClassLoader classLoader) throws ClassNotFoundException {
+ try {
+ checkPackageAccess(className);
+ } catch (SecurityException se) {
+ // anyone can access the platform default factory class without permission
+ if (defaultImplClassName != null && defaultImplClassName.equals(className)) {
+ return Class.forName(className);
+ }
+ // not platform default implementation ...
+ throw se;
+ }
+ return nullSafeLoadClass(className, classLoader);
+ }
+
+ static String getJavaHomeLibConfigPath(String filename) {
+ String javah = AccessController.doPrivileged(new PrivilegedAction<String>() {
+ @Override
+ public String run() {
+ return System.getProperty("java.home");
+ }
+ });
+ return javah + File.separator + "lib" + File.separator + filename;
+ }
+
+ static ClassLoader contextClassLoader(ExceptionHandler exceptionHandler) throws Exception {
+ try {
+ return Thread.currentThread().getContextClassLoader();
+ } catch (Exception x) {
+ throw exceptionHandler.createException(x, x.toString());
+ }
+ }
+
+ static abstract class ExceptionHandler<T extends Exception> {
+
+ public abstract T createException(Throwable throwable, String message);
+
+ }
+
+}
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/Unmarshaller.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/Unmarshaller.java Tue Apr 14 12:10:00 2015 -0700
@@ -73,12 +73,12 @@
* Unmarshalling from a StringBuffer using a
* <tt>javax.xml.transform.stream.StreamSource</tt>:
* <blockquote>
- * <pre>
+ * <pre>{@code
* JAXBContext jc = JAXBContext.newInstance( "com.acme.foo" );
* Unmarshaller u = jc.createUnmarshaller();
- * StringBuffer xmlStr = new StringBuffer( "<?xml version="1.0"?>..." );
+ * StringBuffer xmlStr = new StringBuffer( "<?xml version="1.0"?>..." );
* Object o = u.unmarshal( new StreamSource( new StringReader( xmlStr.toString() ) ) );
- * </pre>
+ * }</pre>
* </blockquote>
*
* <p>
@@ -238,7 +238,7 @@
* to a JAXB mapped class by {@link JAXBContext}, that the root
* element's <tt>xsi:type</tt> attribute takes
* precedence over the unmarshal methods <tt>declaredType</tt> parameter.
- * These methods always return a <tt>JAXBElement<declaredType></tt>
+ * These methods always return a <tt>{@literal JAXBElement<declaredType>}</tt>
* instance. The table below shows how the properties of the returned JAXBElement
* instance are set.
*
@@ -281,21 +281,21 @@
* <p>
* Unmarshal by declaredType from a <tt>org.w3c.dom.Node</tt>:
* <blockquote>
- * <pre>
+ * <pre>{@code
* Schema fragment for example
- * <xs:schema>
- * <xs:complexType name="FooType">...<\xs:complexType>
- * <!-- global element declaration "PurchaseOrder" -->
- * <xs:element name="PurchaseOrder">
- * <xs:complexType>
- * <xs:sequence>
- * <!-- local element declaration "foo" -->
- * <xs:element name="foo" type="FooType"/>
+ * <xs:schema>
+ * <xs:complexType name="FooType">...<\xs:complexType>
+ * <!-- global element declaration "PurchaseOrder" -->
+ * <xs:element name="PurchaseOrder">
+ * <xs:complexType>
+ * <xs:sequence>
+ * <!-- local element declaration "foo" -->
+ * <xs:element name="foo" type="FooType"/>
* ...
- * </xs:sequence>
- * </xs:complexType>
- * </xs:element>
- * </xs:schema>
+ * </xs:sequence>
+ * </xs:complexType>
+ * </xs:element>
+ * </xs:schema>
*
* JAXBContext jc = JAXBContext.newInstance( "com.acme.foo" );
* Unmarshaller u = jc.createUnmarshaller();
@@ -308,8 +308,8 @@
* // local element declaration in schema.
*
* // FooType is the JAXB mapping of the type of local element declaration foo.
- * JAXBElement<FooType> foo = u.unmarshal( fooSubtree, FooType.class);
- * </pre>
+ * JAXBElement<FooType> foo = u.unmarshal( fooSubtree, FooType.class);
+ * }</pre>
* </blockquote>
*
* <p>
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlAnyElement.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlAnyElement.java Tue Apr 14 12:10:00 2015 -0700
@@ -94,15 +94,15 @@
* <h2>Schema To Java example</h2>
*
* The following schema would produce the following Java class:
- * <pre>
- * <xs:complexType name="foo">
- * <xs:sequence>
- * <xs:element name="a" type="xs:int" />
- * <xs:element name="b" type="xs:int" />
- * <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
- * </xs:sequence>
- * </xs:complexType>
- * </pre>
+ * <pre>{@code
+ * <xs:complexType name="foo">
+ * <xs:sequence>
+ * <xs:element name="a" type="xs:int" />
+ * <xs:element name="b" type="xs:int" />
+ * <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
+ * </xs:sequence>
+ * </xs:complexType>
+ * }</pre>
*
* <pre>
* class Foo {
@@ -115,30 +115,30 @@
*
* It can unmarshal instances like
*
- * <pre>
- * <foo xmlns:e="extra">
- * <a>1</a>
- * <e:other /> // this will be bound to DOM, because unmarshalling is orderless
- * <b>3</b>
- * <e:other />
- * <c>5</c> // this will be bound to DOM, because the annotation doesn't remember namespaces.
- * </foo>
- * </pre>
+ * <pre>{@code
+ * <foo xmlns:e="extra">
+ * <a>1</a>
+ * <e:other /> // this will be bound to DOM, because unmarshalling is orderless
+ * <b>3</b>
+ * <e:other />
+ * <c>5</c> // this will be bound to DOM, because the annotation doesn't remember namespaces.
+ * </foo>
+ * }</pre>
*
*
*
* The following schema would produce the following Java class:
- * <pre>
- * <xs:complexType name="bar">
- * <xs:complexContent>
- * <xs:extension base="foo">
- * <xs:sequence>
- * <xs:element name="c" type="xs:int" />
- * <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
- * </xs:sequence>
- * </xs:extension>
- * </xs:complexType>
- * </pre>
+ * <pre>{@code
+ * <xs:complexType name="bar">
+ * <xs:complexContent>
+ * <xs:extension base="foo">
+ * <xs:sequence>
+ * <xs:element name="c" type="xs:int" />
+ * <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
+ * </xs:sequence>
+ * </xs:extension>
+ * </xs:complexType>
+ * }</pre>
*
* <pre>
* class Bar extends Foo {
@@ -150,16 +150,16 @@
*
* It can unmarshal instances like
*
- * <pre>
- * <bar xmlns:e="extra">
- * <a>1</a>
- * <e:other /> // this will be bound to DOM, because unmarshalling is orderless
- * <b>3</b>
- * <e:other />
- * <c>5</c> // this now goes to Bar.c
- * <e:other /> // this will go to Foo.any
- * </bar>
- * </pre>
+ * <pre>{@code
+ * <bar xmlns:e="extra">
+ * <a>1</a>
+ * <e:other /> // this will be bound to DOM, because unmarshalling is orderless
+ * <b>3</b>
+ * <e:other />
+ * <c>5</c> // this now goes to Bar.c
+ * <e:other /> // this will go to Foo.any
+ * </bar>
+ * }</pre>
*
*
*
@@ -171,15 +171,15 @@
*
* <p>
* The following schema would produce the following Java class:
- * <pre>
- * <xs:complexType name="foo">
- * <xs:choice maxOccurs="unbounded" minOccurs="0">
- * <xs:element name="a" type="xs:int" />
- * <xs:element name="b" type="xs:int" />
- * <xs:any namespace="##other" processContents="lax" />
- * </xs:choice>
- * </xs:complexType>
- * </pre>
+ * <pre>{@code
+ * <xs:complexType name="foo">
+ * <xs:choice maxOccurs="unbounded" minOccurs="0">
+ * <xs:element name="a" type="xs:int" />
+ * <xs:element name="b" type="xs:int" />
+ * <xs:any namespace="##other" processContents="lax" />
+ * </xs:choice>
+ * </xs:complexType>
+ * }</pre>
*
* <pre>
* class Foo {
@@ -204,11 +204,11 @@
* It can unmarshal instances like
*
* <pre>
- * <foo xmlns:e="extra">
- * <a>1</a> // this will unmarshal to a {@link JAXBElement} instance whose value is 1.
- * <e:other /> // this will unmarshal to a DOM {@link Element}.
- * <b>3</b> // this will unmarshal to a {@link JAXBElement} instance whose value is 1.
- * </foo>
+ *{@code <foo xmlns:e="extra">}
+ *{@code <a>1</a>} // this will unmarshal to a {@link JAXBElement} instance whose value is 1.
+ *{@code <e:other />} // this will unmarshal to a DOM {@link Element}.
+ *{@code <b>3</b>} // this will unmarshal to a {@link JAXBElement} instance whose value is 1.
+ *{@code </foo>}
* </pre>
*
*
@@ -225,11 +225,11 @@
* }
* </pre>
* then the following document will unmarshal like this:
- * <pre>
- * <foo>
- * <unknown />
- * <foo />
- * </foo>
+ * <pre>{@code
+ * <foo>
+ * <unknown />
+ * <foo />
+ * </foo>
*
* Foo foo = unmarshal();
* // 1 for 'unknown', another for 'foo'
@@ -239,7 +239,7 @@
* // because of lax=true, the 'foo' element eagerly
* // unmarshals to a Foo object.
* assert foo.others[1] instanceof Foo;
- * </pre>
+ * }</pre>
*
* @author Kohsuke Kawaguchi
* @since 1.6, JAXB 2.0
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlAttachmentRef.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlAttachmentRef.java Tue Apr 14 12:10:00 2015 -0700
@@ -51,16 +51,16 @@
* }
* </pre>
* The above code maps to the following XML:
- * <pre>
- * <xs:element name="foo" xmlns:ref="http://ws-i.org/profiles/basic/1.1/xsd">
- * <xs:complexType>
- * <xs:sequence>
- * <xs:element name="body" type="ref:swaRef" minOccurs="0" />
- * </xs:sequence>
- * <xs:attribute name="data" type="ref:swaRef" use="optional" />
- * </xs:complexType>
- * </xs:element>
- * </pre>
+ * <pre>{@code
+ * <xs:element name="foo" xmlns:ref="http://ws-i.org/profiles/basic/1.1/xsd">
+ * <xs:complexType>
+ * <xs:sequence>
+ * <xs:element name="body" type="ref:swaRef" minOccurs="0" />
+ * </xs:sequence>
+ * <xs:attribute name="data" type="ref:swaRef" use="optional" />
+ * </xs:complexType>
+ * </xs:element>
+ * }</pre>
*
* <p>
* The above binding supports WS-I AP 1.0 <a href="http://www.ws-i.org/Profiles/AttachmentsProfile-1.0-2004-08-24.html#Referencing_Attachments_from_the_SOAP_Envelope">WS-I Attachments Profile Version 1.0.</a>
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlAttribute.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlAttribute.java Tue Apr 14 12:10:00 2015 -0700
@@ -89,14 +89,15 @@
* public java.math.BigDecimal getPrice() {...} ;
* public void setPrice(java.math.BigDecimal ) {...};
* }
+ * {@code
*
- * <!-- Example: XML Schema fragment -->
- * <xs:complexType name="USPrice">
- * <xs:sequence>
- * </xs:sequence>
- * <xs:attribute name="price" type="xs:decimal"/>
- * </xs:complexType>
- * </pre>
+ * <!-- Example: XML Schema fragment -->
+ * <xs:complexType name="USPrice">
+ * <xs:sequence>
+ * </xs:sequence>
+ * <xs:attribute name="price" type="xs:decimal"/>
+ * </xs:complexType>
+ * }</pre>
*
* <p> <b>Example 2: </b>Map a JavaBean property to an XML attribute with anonymous type.</p>
* See Example 7 in @{@link XmlType}.
@@ -108,17 +109,18 @@
* ...
* @XmlAttribute List<Integer> items;
* }
+ * {@code
*
- * <!-- Example: XML Schema fragment -->
- * <xs:complexType name="foo">
+ * <!-- Example: XML Schema fragment -->
+ * <xs:complexType name="foo">
* ...
- * <xs:attribute name="items">
- * <xs:simpleType>
- * <xs:list itemType="xs:int"/>
- * </xs:simpleType>
- * </xs:complexType>
+ * <xs:attribute name="items">
+ * <xs:simpleType>
+ * <xs:list itemType="xs:int"/>
+ * </xs:simpleType>
+ * </xs:complexType>
*
- * </pre>
+ * }</pre>
* @author Sekhar Vajjhala, Sun Microsystems, Inc.
* @see XmlType
* @since 1.6, JAXB 2.0
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElement.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElement.java Tue Apr 14 12:10:00 2015 -0700
@@ -82,14 +82,15 @@
* @XmlElement(name="itemprice")
* public java.math.BigDecimal price;
* }
+ * {@code
*
- * <!-- Example: Local XML Schema element -->
- * <xs:complexType name="USPrice"/>
- * <xs:sequence>
- * <xs:element name="itemprice" type="xs:decimal" minOccurs="0"/>
- * </sequence>
- * </xs:complexType>
- * </pre>
+ * <!-- Example: Local XML Schema element -->
+ * <xs:complexType name="USPrice"/>
+ * <xs:sequence>
+ * <xs:element name="itemprice" type="xs:decimal" minOccurs="0"/>
+ * </sequence>
+ * </xs:complexType>
+ * }</pre>
* <p>
*
* <b> Example 2: </b> Map a field to a nillable element.
@@ -100,14 +101,15 @@
* @XmlElement(nillable=true)
* public java.math.BigDecimal price;
* }
+ * {@code
*
- * <!-- Example: Local XML Schema element -->
- * <xs:complexType name="USPrice">
- * <xs:sequence>
- * <xs:element name="price" type="xs:decimal" nillable="true" minOccurs="0"/>
- * </sequence>
- * </xs:complexType>
- * </pre>
+ * <!-- Example: Local XML Schema element -->
+ * <xs:complexType name="USPrice">
+ * <xs:sequence>
+ * <xs:element name="price" type="xs:decimal" nillable="true" minOccurs="0"/>
+ * </sequence>
+ * </xs:complexType>
+ * }</pre>
* <p>
* <b> Example 3: </b> Map a field to a nillable, required element.
* <pre>
@@ -117,14 +119,15 @@
* @XmlElement(nillable=true, required=true)
* public java.math.BigDecimal price;
* }
+ * {@code
*
- * <!-- Example: Local XML Schema element -->
- * <xs:complexType name="USPrice">
- * <xs:sequence>
- * <xs:element name="price" type="xs:decimal" nillable="true" minOccurs="1"/>
- * </sequence>
- * </xs:complexType>
- * </pre>
+ * <!-- Example: Local XML Schema element -->
+ * <xs:complexType name="USPrice">
+ * <xs:sequence>
+ * <xs:element name="price" type="xs:decimal" nillable="true" minOccurs="1"/>
+ * </sequence>
+ * </xs:complexType>
+ * }</pre>
*
* <p> <b>Example 4: </b>Map a JavaBean property to an XML element
* with anonymous type.</p>
@@ -179,7 +182,7 @@
* the enclosing class.
*
* <li>
- * Otherwise '' (which produces unqualified element in the default
+ * Otherwise {@literal ''} (which produces unqualified element in the default
* namespace.
* </ol>
*/
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElementDecl.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElementDecl.java Tue Apr 14 12:10:00 2015 -0700
@@ -65,21 +65,22 @@
* JAXBElement<String> createFoo(String s) { ... }
* }
* </pre>
- * <pre>
- * <!-- XML input -->
- * <foo>string</foo>
+ * <pre> {@code
+ *
+ * <!-- XML input -->
+ * <foo>string</foo>
*
* // Example: code fragment corresponding to XML input
- * JAXBElement<String> o =
- * (JAXBElement<String>)unmarshaller.unmarshal(aboveDocument);
+ * JAXBElement<String> o =
+ * (JAXBElement<String>)unmarshaller.unmarshal(aboveDocument);
* // print JAXBElement instance to show values
* System.out.println(o.getName()); // prints "{}foo"
* System.out.println(o.getValue()); // prints "string"
* System.out.println(o.getValue().getClass()); // prints "java.lang.String"
*
- * <!-- Example: XML schema definition -->
- * <xs:element name="foo" type="xs:string"/>
- * </pre>
+ * <!-- Example: XML schema definition -->
+ * <xs:element name="foo" type="xs:string"/>
+ * }</pre>
*
* <p><b>Example 2: </b> Element declaration with non local scope
* <p>
@@ -90,18 +91,18 @@
* The following example may be replaced in a future revision of
* this javadoc.
*
- * <pre>
- * <!-- Example: XML schema definition -->
- * <xs:schema>
- * <xs:complexType name="pea">
- * <xs:choice maxOccurs="unbounded">
- * <xs:element name="foo" type="xs:string"/>
- * <xs:element name="bar" type="xs:string"/>
- * </xs:choice>
- * </xs:complexType>
- * <xs:element name="foo" type="xs:int"/>
- * </xs:schema>
- * </pre>
+ * <pre>{@code
+ * <!-- Example: XML schema definition -->
+ * <xs:schema>
+ * <xs:complexType name="pea">
+ * <xs:choice maxOccurs="unbounded">
+ * <xs:element name="foo" type="xs:string"/>
+ * <xs:element name="bar" type="xs:string"/>
+ * </xs:choice>
+ * </xs:complexType>
+ * <xs:element name="foo" type="xs:int"/>
+ * </xs:schema>
+ * }</pre>
* <pre>
* // Example: expected default binding
* class Pea {
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElementRef.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElementRef.java Tue Apr 14 12:10:00 2015 -0700
@@ -56,10 +56,10 @@
* support for substitution groups using an <i>element property</i>,
* (section 5.5.5, "Element Property" of JAXB 2.0 specification). An
* element property method signature is of the form:
- * <pre>
- * public void setTerm(JAXBElement<? extends Operator>);
- * public JAXBElement<? extends Operator> getTerm();
- * </pre>
+ * <pre>{@code
+ * public void setTerm(JAXBElement<? extends Operator>);
+ * public JAXBElement<? extends Operator> getTerm();
+ * }</pre>
* <p>
* An element factory method annotated with {@link XmlElementDecl} is
* used to create a <tt>JAXBElement</tt> instance, containing an XML
@@ -121,19 +121,20 @@
* class JavacTask extends Task {
* ...
* }
+ * {@code
*
- * <!-- XML Schema fragment -->
- * <xs:element name="target" type="Target">
- * <xs:complexType name="Target">
- * <xs:sequence>
- * <xs:choice maxOccurs="unbounded">
- * <xs:element ref="jar">
- * <xs:element ref="javac">
- * </xs:choice>
- * </xs:sequence>
- * </xs:complexType>
+ * <!-- XML Schema fragment -->
+ * <xs:element name="target" type="Target">
+ * <xs:complexType name="Target">
+ * <xs:sequence>
+ * <xs:choice maxOccurs="unbounded">
+ * <xs:element ref="jar">
+ * <xs:element ref="javac">
+ * </xs:choice>
+ * </xs:sequence>
+ * </xs:complexType>
*
- * </pre>
+ * }</pre>
* <p>
* Thus the following code fragment:
* <pre>
@@ -143,16 +144,16 @@
* marshal(target);
* </pre>
* will produce the following XML output:
- * <pre>
- * <target>
- * <jar>
+ * <pre>{@code
+ * <target>
+ * <jar>
* ....
- * </jar>
- * <javac>
+ * </jar>
+ * <javac>
* ....
- * </javac>
- * </target>
- * </pre>
+ * </javac>
+ * </target>
+ * }</pre>
* <p>
* It is not an error to have a class that extends <tt>Task</tt>
* that doesn't have {@link XmlRootElement}. But they can't show up in an
@@ -207,11 +208,11 @@
* marshal(m);
* </pre>
* will produce the following XML output:
- * <pre>
- * <math>
- * <add>...</add>
- * </math>
- * </pre>
+ * <pre>{@code
+ * <math>
+ * <add>...</add>
+ * </math>
+ * }</pre>
*
*
* @author <ul><li>Kohsuke Kawaguchi, Sun Microsystems,Inc. </li><li>Sekhar Vajjhala, Sun Microsystems, Inc.</li></ul>
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElementWrapper.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElementWrapper.java Tue Apr 14 12:10:00 2015 -0700
@@ -39,21 +39,21 @@
* XML element around collections. The annotation therefore supports
* two forms of serialization shown below.
*
- * <pre>
+ * <pre>{@code
* //Example: code fragment
* int[] names;
*
* // XML Serialization Form 1 (Unwrapped collection)
- * <names> ... </names>
- * <names> ... </names>
+ * <names> ... </names>
+ * <names> ... </names>
*
* // XML Serialization Form 2 ( Wrapped collection )
- * <wrapperElement>
- * <names> value-of-item </names>
- * <names> value-of-item </names>
+ * <wrapperElement>
+ * <names> value-of-item </names>
+ * <names> value-of-item </names>
* ....
- * </wrapperElement>
- * </pre>
+ * </wrapperElement>
+ * }</pre>
*
* <p> The two serialized XML forms allow a null collection to be
* represented either by absence or presence of an element with a
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElements.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElements.java Tue Apr 14 12:10:00 2015 -0700
@@ -44,7 +44,7 @@
* @XmlElements({ @XmlElement(...),@XmlElement(...) })
* </pre>
*
- * <p>The <tt>@XmlElements</tt> annnotation can be used with the
+ * <p>The <tt>@XmlElements</tt> annotation can be used with the
* following program elements: </p>
* <ul>
* <li> a JavaBean property </li>
@@ -78,28 +78,29 @@
* @XmlElements(
* @XmlElement(name="A", type=Integer.class),
* @XmlElement(name="B", type=Float.class)
- * }
+ * )
* public List items;
* }
+ * {@code
*
- * <!-- XML Representation for a List of {1,2.5}
- * XML output is not wrapped using another element -->
+ * <!-- XML Representation for a List of {1,2.5}
+ * XML output is not wrapped using another element -->
* ...
- * <A> 1 </A>
- * <B> 2.5 </B>
+ * <A> 1 </A>
+ * <B> 2.5 </B>
* ...
*
- * <!-- XML Schema fragment -->
- * <xs:complexType name="Foo">
- * <xs:sequence>
- * <xs:choice minOccurs="0" maxOccurs="unbounded">
- * <xs:element name="A" type="xs:int"/>
- * <xs:element name="B" type="xs:float"/>
- * <xs:choice>
- * </xs:sequence>
- * </xs:complexType>
+ * <!-- XML Schema fragment -->
+ * <xs:complexType name="Foo">
+ * <xs:sequence>
+ * <xs:choice minOccurs="0" maxOccurs="unbounded">
+ * <xs:element name="A" type="xs:int"/>
+ * <xs:element name="B" type="xs:float"/>
+ * <xs:choice>
+ * </xs:sequence>
+ * </xs:complexType>
*
- * </pre>
+ * }</pre>
*
* <p><b>Example 2:</b> Map to a list of elements wrapped with another element
* </p>
@@ -114,21 +115,22 @@
* }
* public List items;
* }
+ * {@code
*
- * <!-- XML Schema fragment -->
- * <xs:complexType name="Foo">
- * <xs:sequence>
- * <xs:element name="bar">
- * <xs:complexType>
- * <xs:choice minOccurs="0" maxOccurs="unbounded">
- * <xs:element name="A" type="xs:int"/>
- * <xs:element name="B" type="xs:float"/>
- * </xs:choice>
- * </xs:complexType>
- * </xs:element>
- * </xs:sequence>
- * </xs:complexType>
- * </pre>
+ * <!-- XML Schema fragment -->
+ * <xs:complexType name="Foo">
+ * <xs:sequence>
+ * <xs:element name="bar">
+ * <xs:complexType>
+ * <xs:choice minOccurs="0" maxOccurs="unbounded">
+ * <xs:element name="A" type="xs:int"/>
+ * <xs:element name="B" type="xs:float"/>
+ * </xs:choice>
+ * </xs:complexType>
+ * </xs:element>
+ * </xs:sequence>
+ * </xs:complexType>
+ * }</pre>
*
* <p><b>Example 3:</b> Change element name based on type using an adapter.
* </p>
@@ -145,21 +147,22 @@
* @XmlType abstract class P {...}
* @XmlType(name="PX") class PX extends P {...}
* @XmlType(name="PY") class PY extends P {...}
+ * {@code
*
- * <!-- XML Schema fragment -->
- * <xs:complexType name="Foo">
- * <xs:sequence>
- * <xs:element name="bar">
- * <xs:complexType>
- * <xs:choice minOccurs="0" maxOccurs="unbounded">
- * <xs:element name="A" type="PX"/>
- * <xs:element name="B" type="PY"/>
- * </xs:choice>
- * </xs:complexType>
- * </xs:element>
- * </xs:sequence>
- * </xs:complexType>
- * </pre>
+ * <!-- XML Schema fragment -->
+ * <xs:complexType name="Foo">
+ * <xs:sequence>
+ * <xs:element name="bar">
+ * <xs:complexType>
+ * <xs:choice minOccurs="0" maxOccurs="unbounded">
+ * <xs:element name="A" type="PX"/>
+ * <xs:element name="B" type="PY"/>
+ * </xs:choice>
+ * </xs:complexType>
+ * </xs:element>
+ * </xs:sequence>
+ * </xs:complexType>
+ * }</pre>
*
* @author <ul><li>Kohsuke Kawaguchi, Sun Microsystems, Inc.</li><li>Sekhar Vajjhala, Sun Microsystems, Inc.</li></ul>
* @see XmlElement
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlEnumValue.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlEnumValue.java Tue Apr 14 12:10:00 2015 -0700
@@ -56,23 +56,24 @@
* <p> In the absence of this annotation, {@link Enum#name()} is used
* as the XML representation.
*
- * <p> <b>Example 1: </b>Map enum constant name -> enumeration facet</p>
+ * <p> <b>Example 1: </b>Map enum constant name {@literal ->} enumeration facet</p>
* <pre>
* //Example: Code fragment
* @XmlEnum(String.class)
* public enum Card { CLUBS, DIAMONDS, HEARTS, SPADES }
+ * {@code
*
- * <!-- Example: XML Schema fragment -->
- * <xs:simpleType name="Card">
- * <xs:restriction base="xs:string"/>
- * <xs:enumeration value="CLUBS"/>
- * <xs:enumeration value="DIAMONDS"/>
- * <xs:enumeration value="HEARTS"/>
- * <xs:enumeration value="SPADES"/>
- * </xs:simpleType>
- * </pre>
+ * <!-- Example: XML Schema fragment -->
+ * <xs:simpleType name="Card">
+ * <xs:restriction base="xs:string"/>
+ * <xs:enumeration value="CLUBS"/>
+ * <xs:enumeration value="DIAMONDS"/>
+ * <xs:enumeration value="HEARTS"/>
+ * <xs:enumeration value="SPADES"/>
+ * </xs:simpleType>
+ * }</pre>
*
- * <p><b>Example 2: </b>Map enum constant name(value) -> enumeration facet </p>
+ * <p><b>Example 2: </b>Map enum constant name(value) {@literal ->} enumeration facet </p>
* <pre>
* //Example: code fragment
* @XmlType
@@ -82,19 +83,20 @@
* @XmlEnumValue("5") NICKEL(5),
* @XmlEnumValue("10") DIME(10),
* @XmlEnumValue("25") QUARTER(25) }
+ * {@code
*
- * <!-- Example: XML Schema fragment -->
- * <xs:simpleType name="Coin">
- * <xs:restriction base="xs:int">
- * <xs:enumeration value="1"/>
- * <xs:enumeration value="5"/>
- * <xs:enumeration value="10"/>
- * <xs:enumeration value="25"/>
- * </xs:restriction>
- * </xs:simpleType>
- * </pre>
+ * <!-- Example: XML Schema fragment -->
+ * <xs:simpleType name="Coin">
+ * <xs:restriction base="xs:int">
+ * <xs:enumeration value="1"/>
+ * <xs:enumeration value="5"/>
+ * <xs:enumeration value="10"/>
+ * <xs:enumeration value="25"/>
+ * </xs:restriction>
+ * </xs:simpleType>
+ * }</pre>
*
- * <p><b>Example 3: </b>Map enum constant name -> enumeration facet </p>
+ * <p><b>Example 3: </b>Map enum constant name {@literal ->} enumeration facet </p>
*
* <pre>
* //Code fragment
@@ -104,15 +106,16 @@
* @XmlEnumValue("1") ONE,
* @XmlEnumValue("2") TWO;
* }
+ * {@code
*
- * <!-- Example: XML Schema fragment -->
- * <xs:simpleType name="Code">
- * <xs:restriction base="xs:int">
- * <xs:enumeration value="1"/>
- * <xs:enumeration value="2"/>
- * </xs:restriction>
- * </xs:simpleType>
- * </pre>
+ * <!-- Example: XML Schema fragment -->
+ * <xs:simpleType name="Code">
+ * <xs:restriction base="xs:int">
+ * <xs:enumeration value="1"/>
+ * <xs:enumeration value="2"/>
+ * </xs:restriction>
+ * </xs:simpleType>
+ * }</pre>
*
* @since 1.6, JAXB 2.0
*/
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlID.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlID.java Tue Apr 14 12:10:00 2015 -0700
@@ -73,17 +73,18 @@
* public void setCustomerID(String id);
* .... other properties not shown
* }
+ * {@code
*
- * <!-- Example: XML Schema fragment -->
- * <xs:complexType name="Customer">
- * <xs:complexContent>
- * <xs:sequence>
+ * <!-- Example: XML Schema fragment -->
+ * <xs:complexType name="Customer">
+ * <xs:complexContent>
+ * <xs:sequence>
* ....
- * </xs:sequence>
- * <xs:attribute name="customerID" type="xs:ID"/>
- * </xs:complexContent>
- * </xs:complexType>
- * </pre>
+ * </xs:sequence>
+ * <xs:attribute name="customerID" type="xs:ID"/>
+ * </xs:complexContent>
+ * </xs:complexType>
+ * }</pre>
*
* @author Sekhar Vajjhala, Sun Microsystems, Inc.
* @see XmlIDREF
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlIDREF.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlIDREF.java Tue Apr 14 12:10:00 2015 -0700
@@ -37,7 +37,7 @@
* <p>
* To preserve referential integrity of an object graph across XML
* serialization followed by a XML deserialization, requires an object
- * reference to be marshalled by reference or containment
+ * reference to be marshaled by reference or containment
* appropriately. Annotations <tt>@XmlID</tt> and <tt>@XmlIDREF</tt>
* together allow a customized mapping of a JavaBean property's
* type by containment or reference.
@@ -82,18 +82,19 @@
* public void setCustomer(Customer customer);
* ....
* }
+ * {@code
*
- * <!-- Example: XML Schema fragment -->
- * <xs:complexType name="Shipping">
- * <xs:complexContent>
- * <xs:sequence>
- * <xs:element name="customer" type="xs:IDREF"/>
+ * <!-- Example: XML Schema fragment -->
+ * <xs:complexType name="Shipping">
+ * <xs:complexContent>
+ * <xs:sequence>
+ * <xs:element name="customer" type="xs:IDREF"/>
* ....
- * </xs:sequence>
- * </xs:complexContent>
- * </xs:complexType>
+ * </xs:sequence>
+ * </xs:complexContent>
+ * </xs:complexType>
*
- * </pre>
+ * }</pre>
*
*
* <p><b>Example 2: </b> The following is a complete example of
@@ -142,64 +143,65 @@
* // maps reference to Invoice by containment by default.
* public Invoice getInvoice();
* }
+ * {@code
*
- * <!-- XML Schema mapping for above code frament -->
+ * <!-- XML Schema mapping for above code frament -->
*
- * <xs:complexType name="Invoice">
- * <xs:complexContent>
- * <xs:sequence>
- * <xs:element name="customer" type="xs:IDREF"/>
+ * <xs:complexType name="Invoice">
+ * <xs:complexContent>
+ * <xs:sequence>
+ * <xs:element name="customer" type="xs:IDREF"/>
* ....
- * </xs:sequence>
- * </xs:complexContent>
- * </xs:complexType>
+ * </xs:sequence>
+ * </xs:complexContent>
+ * </xs:complexType>
*
- * <xs:complexType name="Shipping">
- * <xs:complexContent>
- * <xs:sequence>
- * <xs:element name="customer" type="xs:IDREF"/>
+ * <xs:complexType name="Shipping">
+ * <xs:complexContent>
+ * <xs:sequence>
+ * <xs:element name="customer" type="xs:IDREF"/>
* ....
- * </xs:sequence>
- * </xs:complexContent>
- * </xs:complexType>
+ * </xs:sequence>
+ * </xs:complexContent>
+ * </xs:complexType>
*
- * <xs:complexType name="Customer">
- * <xs:complexContent>
- * <xs:sequence>
+ * <xs:complexType name="Customer">
+ * <xs:complexContent>
+ * <xs:sequence>
* ....
- * </xs:sequence>
- * <xs:attribute name="CustomerID" type="xs:ID"/>
- * </xs:complexContent>
- * </xs:complexType>
+ * </xs:sequence>
+ * <xs:attribute name="CustomerID" type="xs:ID"/>
+ * </xs:complexContent>
+ * </xs:complexType>
*
- * <xs:complexType name="CustomerData">
- * <xs:complexContent>
- * <xs:sequence>
- * <xs:element name="customer" type="xs:Customer"/>
- * <xs:element name="shipping" type="xs:Shipping"/>
- * <xs:element name="invoice" type="xs:Invoice"/>
- * </xs:sequence>
- * </xs:complexContent>
- * </xs:complexType>
+ * <xs:complexType name="CustomerData">
+ * <xs:complexContent>
+ * <xs:sequence>
+ * <xs:element name="customer" type="xs:Customer"/>
+ * <xs:element name="shipping" type="xs:Shipping"/>
+ * <xs:element name="invoice" type="xs:Invoice"/>
+ * </xs:sequence>
+ * </xs:complexContent>
+ * </xs:complexType>
*
- * <xs:element name"customerData" type="xs:CustomerData"/>
+ * <xs:element name"customerData" type="xs:CustomerData"/>
*
- * <!-- Instance document conforming to the above XML Schema -->
- * <customerData>
- * <customer customerID="Alice">
+ * <!-- Instance document conforming to the above XML Schema -->
+ * <customerData>
+ * <customer customerID="Alice">
* ....
- * </customer>
+ * </customer>
*
- * <shipping customer="Alice">
+ * <shipping customer="Alice">
* ....
- * </shipping>
+ * </shipping>
*
- * <invoice customer="Alice">
+ * <invoice customer="Alice">
* ....
- * </invoice>
- * </customerData>
+ * </invoice>
+ * </customerData>
*
- * </pre>
+ * }</pre>
*
* <p><b>Example 3: </b> Mapping List to repeating element of type IDREF
* <pre>
@@ -209,16 +211,17 @@
* @XmlElement(name="Alice")
* public List customers;
* }
+ * {@code
*
- * <!-- XML schema fragment -->
- * <xs:complexType name="Shipping">
- * <xs:sequence>
- * <xs:choice minOccurs="0" maxOccurs="unbounded">
- * <xs:element name="Alice" type="xs:IDREF"/>
- * </xs:choice>
- * </xs:sequence>
- * </xs:complexType>
- * </pre>
+ * <!-- XML schema fragment -->
+ * <xs:complexType name="Shipping">
+ * <xs:sequence>
+ * <xs:choice minOccurs="0" maxOccurs="unbounded">
+ * <xs:element name="Alice" type="xs:IDREF"/>
+ * </xs:choice>
+ * </xs:sequence>
+ * </xs:complexType>
+ * }</pre>
*
* <p><b>Example 4: </b> Mapping a List to a list of elements of type IDREF.
* <pre>
@@ -230,17 +233,18 @@
* @XmlElement(name="John", type="InternationalCustomer.class")
* public List customers;
* }
+ * {@code
*
- * <!-- XML Schema fragment -->
- * <xs:complexType name="Shipping">
- * <xs:sequence>
- * <xs:choice minOccurs="0" maxOccurs="unbounded">
- * <xs:element name="Alice" type="xs:IDREF"/>
- * <xs:element name="John" type="xs:IDREF"/>
- * </xs:choice>
- * </xs:sequence>
- * </xs:complexType>
- * </pre>
+ * <!-- XML Schema fragment -->
+ * <xs:complexType name="Shipping">
+ * <xs:sequence>
+ * <xs:choice minOccurs="0" maxOccurs="unbounded">
+ * <xs:element name="Alice" type="xs:IDREF"/>
+ * <xs:element name="John" type="xs:IDREF"/>
+ * </xs:choice>
+ * </xs:sequence>
+ * </xs:complexType>
+ * }</pre>
* @author Sekhar Vajjhala, Sun Microsystems, Inc.
* @see XmlID
* @since 1.6, JAXB 2.0
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlList.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlList.java Tue Apr 14 12:10:00 2015 -0700
@@ -59,12 +59,12 @@
*
* would produce XML like this:
*
- * <pre>
- * <foo>
- * <data>abc</data>
- * <data>def</data>
- * </foo>
- * </pre>
+ * <pre>{@code
+ * <foo>
+ * <data>abc</data>
+ * <data>def</data>
+ * </foo>
+ * }</pre>
*
* @XmlList annotation, on the other hand, allows multiple values to be
* represented as whitespace-separated tokens in a single element. For example,
@@ -80,11 +80,11 @@
*
* the above code will produce XML like this:
*
- * <pre>
- * <foo>
- * <data>abc def</data>
- * </foo>
- * </pre>
+ * <pre>{@code
+ * <foo>
+ * <data>abc def</data>
+ * </foo>
+ * }</pre>
*
* <p>This annotation can be used with the following annotations:
* {@link XmlElement},
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlMixed.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlMixed.java Tue Apr 14 12:10:00 2015 -0700
@@ -56,32 +56,33 @@
* </ul>
*
* Below is an example of binding and creation of mixed content.
- * <pre>
- * <!-- schema fragment having mixed content -->
- * <xs:complexType name="letterBody" mixed="true">
- * <xs:sequence>
- * <xs:element name="name" type="xs:string"/>
- * <xs:element name="quantity" type="xs:positiveInteger"/>
- * <xs:element name="productName" type="xs:string"/>
- * <!-- etc. -->
- * </xs:sequence>
- * </xs:complexType>
- * <xs:element name="letterBody" type="letterBody"/>
+ * <pre>{@code
+ *
+ * <!-- schema fragment having mixed content -->
+ * <xs:complexType name="letterBody" mixed="true">
+ * <xs:sequence>
+ * <xs:element name="name" type="xs:string"/>
+ * <xs:element name="quantity" type="xs:positiveInteger"/>
+ * <xs:element name="productName" type="xs:string"/>
+ * <!-- etc. -->
+ * </xs:sequence>
+ * </xs:complexType>
+ * <xs:element name="letterBody" type="letterBody"/>
*
* // Schema-derived Java code:
* // (Only annotations relevant to mixed content are shown below,
- * // others are ommitted.)
+ * // others are omitted.)
* import java.math.BigInteger;
* public class ObjectFactory {
* // element instance factories
- * JAXBElement<LetterBody> createLetterBody(LetterBody value);
- * JAXBElement<String> createLetterBodyName(String value);
- * JAXBElement<BigInteger> createLetterBodyQuantity(BigInteger value);
- * JAXBElement<String> createLetterBodyProductName(String value);
+ * JAXBElement<LetterBody> createLetterBody(LetterBody value);
+ * JAXBElement<String> createLetterBodyName(String value);
+ * JAXBElement<BigInteger> createLetterBodyQuantity(BigInteger value);
+ * JAXBElement<String> createLetterBodyProductName(String value);
* // type instance factory
* LetterBody createLetterBody();
* }
- * </pre>
+ * }</pre>
* <pre>
* public class LetterBody {
* // Mixed content can contain instances of Element classes
@@ -96,17 +97,17 @@
* }
* </pre>
* The following is an XML instance document with mixed content
- * <pre>
- * <letterBody>
- * Dear Mr.<name>Robert Smith</name>
- * Your order of <quantity>1</quantity> <productName>Baby
- * Monitor</productName> shipped from our warehouse. ....
- * </letterBody>
- * </pre>
+ * <pre>{@code
+ * <letterBody>
+ * Dear Mr.<name>Robert Smith</name>
+ * Your order of <quantity>1</quantity> <productName>Baby
+ * Monitor</productName> shipped from our warehouse. ....
+ * </letterBody>
+ * }</pre>
* that can be constructed using following JAXB API calls.
- * <pre>
+ * <pre>{@code
* LetterBody lb = ObjectFactory.createLetterBody();
- * JAXBElement<LetterBody> lbe = ObjectFactory.createLetterBody(lb);
+ * JAXBElement<LetterBody> lbe = ObjectFactory.createLetterBody(lb);
* List gcl = lb.getContent(); //add mixed content to general content property.
* gcl.add("Dear Mr."); // add text information item as a String.
*
@@ -119,7 +120,7 @@
* createLetterBodyQuantity(new BigInteger("1")));
* gcl.add(ObjectFactory.createLetterBodyProductName("Baby Monitor"));
* gcl.add("shipped from our warehouse"); // add text information item
- * </pre>
+ * }</pre>
*
* <p>See "Package Specification" in javax.xml.bind.package javadoc for
* additional common information.</p>
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlRootElement.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlRootElement.java Tue Apr 14 12:10:00 2015 -0700
@@ -73,28 +73,30 @@
* marshal( new Point(3,5), System.out);
* </pre>
*
- * <pre>
- * <!-- Example: XML output -->
- * <point>
- * <x> 3 </x>
- * <y> 5 </y>
- * </point>
- * </pre>
+ * <pre>{@code
+ *
+ * <!-- Example: XML output -->
+ * <point>
+ * <x> 3 </x>
+ * <y> 5 </y>
+ * </point>
+ * }</pre>
*
* The annotation causes an global element declaration to be produced
* in the schema. The global element declaration is associated with
* the XML schema type to which the class is mapped.
*
- * <pre>
- * <!-- Example: XML schema definition -->
- * <xs:element name="point" type="point"/>
- * <xs:complexType name="point">
- * <xs:sequence>
- * <xs:element name="x" type="xs:int"/>
- * <xs:element name="y" type="xs:int"/>
- * </xs:sequence>
- * </xs:complexType>
- * </pre>
+ * <pre>{@code
+ *
+ * <!-- Example: XML schema definition -->
+ * <xs:element name="point" type="point"/>
+ * <xs:complexType name="point">
+ * <xs:sequence>
+ * <xs:element name="x" type="xs:int"/>
+ * <xs:element name="y" type="xs:int"/>
+ * </xs:sequence>
+ * </xs:complexType>
+ * }</pre>
*
* <p>
*
@@ -113,27 +115,28 @@
*
* //Example: Code fragment corresponding to XML output *
* marshal( new Point3D(3,5,0), System.out );
+ * {@code
*
- * <!-- Example: XML output -->
- * <!-- The element name is point3D not point -->
- * <point3D>
- * <x>3</x>
- * <y>5</y>
- * <z>0</z>
- * </point3D>
+ * <!-- Example: XML output -->
+ * <!-- The element name is point3D not point -->
+ * <point3D>
+ * <x>3</x>
+ * <y>5</y>
+ * <z>0</z>
+ * </point3D>
*
- * <!-- Example: XML schema definition -->
- * <xs:element name="point3D" type="point3D"/>
- * <xs:complexType name="point3D">
- * <xs:complexContent>
- * <xs:extension base="point">
- * <xs:sequence>
- * <xs:element name="z" type="xs:int"/>
- * </xs:sequence>
- * </xs:extension>
- * </xs:complexContent>
- * </xs:complexType>
- * </pre>
+ * <!-- Example: XML schema definition -->
+ * <xs:element name="point3D" type="point3D"/>
+ * <xs:complexType name="point3D">
+ * <xs:complexContent>
+ * <xs:extension base="point">
+ * <xs:sequence>
+ * <xs:element name="z" type="xs:int"/>
+ * </xs:sequence>
+ * </xs:extension>
+ * </xs:complexContent>
+ * </xs:complexType>
+ * }</pre>
*
* <b>Example 3: </b> Associate a global element with XML Schema type
* to which the class is mapped.
@@ -144,15 +147,16 @@
* @XmlElement
* public java.math.BigDecimal price;
* }
+ * {@code
*
- * <!-- Example: XML schema definition -->
- * <xs:element name="PriceElement" type="USPrice"/>
- * <xs:complexType name="USPrice">
- * <xs:sequence>
- * <xs:element name="price" type="xs:decimal"/>
- * </sequence>
- * </xs:complexType>
- * </pre>
+ * <!-- Example: XML schema definition -->
+ * <xs:element name="PriceElement" type="USPrice"/>
+ * <xs:complexType name="USPrice">
+ * <xs:sequence>
+ * <xs:element name="price" type="xs:decimal"/>
+ * </sequence>
+ * </xs:complexType>
+ * }</pre>
*
* @author Sekhar Vajjhala, Sun Microsystems, Inc.
* @since 1.6, JAXB 2.0
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlSchema.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlSchema.java Tue Apr 14 12:10:00 2015 -0700
@@ -63,16 +63,17 @@
* @javax.xml.bind.annotation.XmlSchema (
* namespace = "http://www.example.com/MYPO1"
* )
+ * {@code
*
- * <!-- XML Schema fragment -->
- * <schema
+ * <!-- XML Schema fragment -->
+ * <schema
* xmlns=...
* xmlns:po=....
* targetNamespace="http://www.example.com/MYPO1"
- * >
- * <!-- prefixes generated by default are implementation
- * depedenent -->
- * </pre>
+ * >
+ * <!-- prefixes generated by default are implementation
+ * depedenent -->
+ * }</pre>
*
* <p><b>Example 2:</b> Customize namespace prefix, namespace URI
* mapping</p>
@@ -86,16 +87,17 @@
*
* @javax.xml.bind.annotation.XmlNs(prefix="xs",
* namespaceURI="http://www.w3.org/2001/XMLSchema")
- * )
+ * }
* )
+ * {@code
*
- * <!-- XML Schema fragment -->
- * <schema
+ * <!-- XML Schema fragment -->
+ * <schema
* xmlns:xs="http://www.w3.org/2001/XMLSchema"
* xmlns:po="http://www.example.com/PO1"
- * targetNamespace="http://www.example.com/PO1">
+ * targetNamespace="http://www.example.com/PO1">
*
- * </pre>
+ * }</pre>
*
* <p><b>Example 3:</b> Customize elementFormDefault</p>
* <pre>
@@ -103,14 +105,15 @@
* elementFormDefault=XmlNsForm.UNQUALIFIED
* ...
* )
+ * {@code
*
- * <!-- XML Schema fragment -->
- * <schema
+ * <!-- XML Schema fragment -->
+ * <schema
* xmlns="http://www.w3.org/2001/XMLSchema"
* xmlns:po="http://www.example.com/PO1"
- * elementFormDefault="unqualified">
+ * elementFormDefault="unqualified">
*
- * </pre>
+ * }</pre>
* @author Sekhar Vajjhala, Sun Microsystems, Inc.
* @since 1.6, JAXB 2.0
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlSchemaType.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlSchemaType.java Tue Apr 14 12:10:00 2015 -0700
@@ -65,14 +65,15 @@
* @XmlSchemaType(name="date")
* public XMLGregorianCalendar date;
* }
+ * {@code
*
- * <!-- Example: Local XML Schema element -->
- * <xs:complexType name="USPrice"/>
- * <xs:sequence>
- * <xs:element name="date" type="xs:date"/>
- * </sequence>
- * </xs:complexType>
- * </pre>
+ * <!-- Example: Local XML Schema element -->
+ * <xs:complexType name="USPrice"/>
+ * <xs:sequence>
+ * <xs:element name="date" type="xs:date"/>
+ * </sequence>
+ * </xs:complexType>
+ * }</pre>
*
* <p> <b> Example 2: </b> Customize mapping of XMLGregorianCalendar at package
* level </p>
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlTransient.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlTransient.java Tue Apr 14 12:10:00 2015 -0700
@@ -78,14 +78,15 @@
* String setName() {..};
* }
*
+ * {@code
*
- * <!-- Example: XML Schema fragment -->
- * <xs:complexType name="USAddress">
- * <xs:sequence>
- * <xs:element name="name" type="xs:string"/>
- * </xs:sequence>
- * </xs:complexType>
- * </pre>
+ * <!-- Example: XML Schema fragment -->
+ * <xs:complexType name="USAddress">
+ * <xs:sequence>
+ * <xs:element name="name" type="xs:string"/>
+ * </xs:sequence>
+ * </xs:complexType>
+ * }</pre>
*
* @author Sekhar Vajjhala, Sun Microsystems, Inc.
* @since 1.6, JAXB 2.0
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlType.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlType.java Tue Apr 14 12:10:00 2015 -0700
@@ -112,7 +112,7 @@
* The following table shows the mapping of the class to a XML Schema
* complex type or simple type. The notational symbols used in the table are:
* <ul>
- * <li> -> : represents a mapping </li>
+ * <li> {@literal ->} : represents a mapping </li>
* <li> [x]+ : one or more occurances of x </li>
* <li> [ <tt>@XmlValue</tt> property ]: JavaBean property annotated with
* <tt>@XmlValue</tt></li>
@@ -132,7 +132,7 @@
* <tr valign="top">
* <td>Class</td>
* <td>{}</td>
- * <td>[property]+ -> elements</td>
+ * <td>[property]+ {@literal ->} elements</td>
* <td>complexcontent<br>xs:all</td>
* <td> </td>
* </tr>
@@ -140,7 +140,7 @@
* <tr valign="top">
* <td>Class</td>
* <td>non empty</td>
- * <td>[property]+ -> elements</td>
+ * <td>[property]+ {@literal ->} elements</td>
* <td>complexcontent<br>xs:sequence</td>
* <td> </td>
* </tr>
@@ -148,7 +148,7 @@
* <tr valign="top">
* <td>Class</td>
* <td>X</td>
- * <td>no property -> element</td>
+ * <td>no property {@literal ->} element</td>
* <td>complexcontent<br>empty sequence</td>
* <td> </td>
* </tr>
@@ -156,7 +156,7 @@
* <tr valign="top">
* <td>Class</td>
* <td>X</td>
- * <td>1 [<tt>@XmlValue</tt> property] {@literal &&} <br> [property]+ -> attributes</td>
+ * <td>1 [<tt>@XmlValue</tt> property] {@literal &&} <br> [property]+ {@literal ->} attributes</td>
* <td>simplecontent</td>
* <td> </td>
* </tr>
@@ -164,7 +164,7 @@
* <tr valign="top">
* <td>Class</td>
* <td>X</td>
- * <td>1 [<tt>@XmlValue</tt> property] {@literal &&} <br> no properties -> attribute</td>
+ * <td>1 [<tt>@XmlValue</tt> property] {@literal &&} <br> no properties {@literal ->} attribute</td>
* <td> </td>
* <td>simpletype</td>
* </tr>
@@ -208,35 +208,37 @@
* java.math.BigDecimal getZip() {..};
* void setZip(java.math.BigDecimal) {..};
* }
+ * {@code
*
- * <!-- XML Schema mapping for USAddress -->
- * <xs:complexType name="USAddress">
- * <xs:sequence>
- * <xs:element name="street" type="xs:string"/>
- * <xs:element name="city" type="xs:string"/>
- * <xs:element name="state" type="xs:string"/>
- * <xs:element name="zip" type="xs:decimal"/>
- * <xs:element name="name" type="xs:string"/>
- * </xs:all>
- * </xs:complexType>
- * </pre>
+ * <!-- XML Schema mapping for USAddress -->
+ * <xs:complexType name="USAddress">
+ * <xs:sequence>
+ * <xs:element name="street" type="xs:string"/>
+ * <xs:element name="city" type="xs:string"/>
+ * <xs:element name="state" type="xs:string"/>
+ * <xs:element name="zip" type="xs:decimal"/>
+ * <xs:element name="name" type="xs:string"/>
+ * </xs:all>
+ * </xs:complexType>
+ * }</pre>
* <p> <b> Example 2: </b> Map a class to a complex type with
* xs:all </p>
* <pre>
* @XmlType(propOrder={})
* public class USAddress { ...}
+ * {@code
*
- * <!-- XML Schema mapping for USAddress -->
- * <xs:complexType name="USAddress">
- * <xs:all>
- * <xs:element name="name" type="xs:string"/>
- * <xs:element name="street" type="xs:string"/>
- * <xs:element name="city" type="xs:string"/>
- * <xs:element name="state" type="xs:string"/>
- * <xs:element name="zip" type="xs:decimal"/>
- * </xs:sequence>
- * </xs:complexType>
- *</pre>
+ * <!-- XML Schema mapping for USAddress -->
+ * <xs:complexType name="USAddress">
+ * <xs:all>
+ * <xs:element name="name" type="xs:string"/>
+ * <xs:element name="street" type="xs:string"/>
+ * <xs:element name="city" type="xs:string"/>
+ * <xs:element name="state" type="xs:string"/>
+ * <xs:element name="zip" type="xs:decimal"/>
+ * </xs:sequence>
+ * </xs:complexType>
+ *}</pre>
* <p> <b> Example 3: </b> Map a class to a global element with an
* anonymous type.
* </p>
@@ -244,20 +246,21 @@
* @XmlRootElement
* @XmlType(name="")
* public class USAddress { ...}
+ * {@code
*
- * <!-- XML Schema mapping for USAddress -->
- * <xs:element name="USAddress">
- * <xs:complexType>
- * <xs:sequence>
- * <xs:element name="name" type="xs:string"/>
- * <xs:element name="street" type="xs:string"/>
- * <xs:element name="city" type="xs:string"/>
- * <xs:element name="state" type="xs:string"/>
- * <xs:element name="zip" type="xs:decimal"/>
- * </xs:sequence>
- * </xs:complexType>
- * </xs:element>
- * </pre>
+ * <!-- XML Schema mapping for USAddress -->
+ * <xs:element name="USAddress">
+ * <xs:complexType>
+ * <xs:sequence>
+ * <xs:element name="name" type="xs:string"/>
+ * <xs:element name="street" type="xs:string"/>
+ * <xs:element name="city" type="xs:string"/>
+ * <xs:element name="state" type="xs:string"/>
+ * <xs:element name="zip" type="xs:decimal"/>
+ * </xs:sequence>
+ * </xs:complexType>
+ * </xs:element>
+ * }</pre>
*
* <p> <b> Example 4: </b> Map a property to a local element with
* anonymous type.
@@ -271,22 +274,23 @@
* @XmlType(name="")
* public class USAddress { ... }
* }
+ * {@code
*
- * <!-- XML Schema mapping for USAddress -->
- * <xs:complexType name="Invoice">
- * <xs:sequence>
- * <xs:element name="addr">
- * <xs:complexType>
- * <xs:element name="name", type="xs:string"/>
- * <xs:element name="city", type="xs:string"/>
- * <xs:element name="city" type="xs:string"/>
- * <xs:element name="state" type="xs:string"/>
- * <xs:element name="zip" type="xs:decimal"/>
- * </xs:complexType>
+ * <!-- XML Schema mapping for USAddress -->
+ * <xs:complexType name="Invoice">
+ * <xs:sequence>
+ * <xs:element name="addr">
+ * <xs:complexType>
+ * <xs:element name="name", type="xs:string"/>
+ * <xs:element name="city", type="xs:string"/>
+ * <xs:element name="city" type="xs:string"/>
+ * <xs:element name="state" type="xs:string"/>
+ * <xs:element name="zip" type="xs:decimal"/>
+ * </xs:complexType>
* ...
- * </xs:sequence>
- * </xs:complexType>
- * </pre>
+ * </xs:sequence>
+ * </xs:complexType>
+ * }</pre>
*
* <p> <b> Example 5: </b> Map a property to an attribute with
* anonymous type.
@@ -306,19 +310,20 @@
* @XmlValue
* public java.math.BigDecimal price;
* }
+ * {@code
*
- * <!-- Example: XML Schema fragment -->
- * <xs:complexType name="Item">
- * <xs:sequence>
- * <xs:element name="name" type="xs:string"/>
- * <xs:attribute name="price">
- * <xs:simpleType>
- * <xs:restriction base="xs:decimal"/>
- * </xs:simpleType>
- * </xs:attribute>
- * </xs:sequence>
- * </xs:complexType>
- * </pre>
+ * <!-- Example: XML Schema fragment -->
+ * <xs:complexType name="Item">
+ * <xs:sequence>
+ * <xs:element name="name" type="xs:string"/>
+ * <xs:attribute name="price">
+ * <xs:simpleType>
+ * <xs:restriction base="xs:decimal"/>
+ * </xs:simpleType>
+ * </xs:attribute>
+ * </xs:sequence>
+ * </xs:complexType>
+ * }</pre>
*
* <p> <b> Example 6: </b> Define a factoryClass and factoryMethod
*
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlValue.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlValue.java Tue Apr 14 12:10:00 2015 -0700
@@ -87,13 +87,14 @@
* @XmlValue
* public java.math.BigDecimal price;
* }
+ * {@code
*
- * <!-- Example 1: XML Schema fragment -->
- * <xs:simpleType name="USPrice">
- * <xs:restriction base="xs:decimal"/>
- * </xs:simpleType>
+ * <!-- Example 1: XML Schema fragment -->
+ * <xs:simpleType name="USPrice">
+ * <xs:restriction base="xs:decimal"/>
+ * </xs:simpleType>
*
- * </pre>
+ * }</pre>
*
* <p><b> Example 2: </b> Map a class to XML Schema complexType with
* with simpleContent.</p>
@@ -108,17 +109,18 @@
* @XmlAttribute
* public String currency;
* }
+ * {@code
*
- * <!-- Example 2: XML Schema fragment -->
- * <xs:complexType name="InternationalPrice">
- * <xs:simpleContent>
- * <xs:extension base="xs:decimal">
- * <xs:attribute name="currency" type="xs:string"/>
- * </xs:extension>
- * </xs:simpleContent>
- * </xs:complexType>
+ * <!-- Example 2: XML Schema fragment -->
+ * <xs:complexType name="InternationalPrice">
+ * <xs:simpleContent>
+ * <xs:extension base="xs:decimal">
+ * <xs:attribute name="currency" type="xs:string"/>
+ * </xs:extension>
+ * </xs:simpleContent>
+ * </xs:complexType>
*
- * </pre>
+ * }</pre>
*
* @author Sekhar Vajjhala, Sun Microsystems, Inc.
* @see XmlType
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/CollapsedStringAdapter.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/CollapsedStringAdapter.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,7 @@
*
* <p>
* This adapter removes leading and trailing whitespaces, then truncate any
- * sequnce of tab, CR, LF, and SP by a single whitespace character ' '.
+ * sequence of tab, CR, LF, and SP by a single whitespace character ' '.
*
* @author Kohsuke Kawaguchi
* @since 1.6, JAXB 2.0
@@ -41,7 +41,7 @@
/**
* Removes leading and trailing whitespaces of the string
* given as the parameter, then truncate any
- * sequnce of tab, CR, LF, and SP by a single whitespace character ' '.
+ * sequence of tab, CR, LF, and SP by a single whitespace character ' '.
*/
public String unmarshal(String text) {
if(text==null) return null; // be defensive
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/XmlAdapter.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/XmlAdapter.java Tue Apr 14 12:10:00 2015 -0700
@@ -75,35 +75,35 @@
*
* <p> <b> Step 1: </b> Determine the desired XML representation for HashMap.
*
- * <pre>
- * <hashmap>
- * <entry key="id123">this is a value</entry>
- * <entry key="id312">this is another value</entry>
+ * <pre>{@code
+ * <hashmap>
+ * <entry key="id123">this is a value</entry>
+ * <entry key="id312">this is another value</entry>
* ...
- * </hashmap>
- * </pre>
+ * </hashmap>
+ * }</pre>
*
* <p> <b> Step 2: </b> Determine the schema definition that the
* desired XML representation shown above should follow.
*
- * <pre>
+ * <pre>{@code
*
- * <xs:complexType name="myHashMapType">
- * <xs:sequence>
- * <xs:element name="entry" type="myHashMapEntryType"
- * minOccurs = "0" maxOccurs="unbounded"/>
- * </xs:sequence>
- * </xs:complexType>
+ * <xs:complexType name="myHashMapType">
+ * <xs:sequence>
+ * <xs:element name="entry" type="myHashMapEntryType"
+ * minOccurs = "0" maxOccurs="unbounded"/>
+ * </xs:sequence>
+ * </xs:complexType>
*
- * <xs:complexType name="myHashMapEntryType">
- * <xs:simpleContent>
- * <xs:extension base="xs:string">
- * <xs:attribute name="key" type="xs:int"/>
- * </xs:extension>
- * </xs:simpleContent>
- * </xs:complexType>
+ * <xs:complexType name="myHashMapEntryType">
+ * <xs:simpleContent>
+ * <xs:extension base="xs:string">
+ * <xs:attribute name="key" type="xs:int"/>
+ * </xs:extension>
+ * </xs:simpleContent>
+ * </xs:complexType>
*
- * </pre>
+ * }</pre>
*
* <p> <b> Step 3: </b> Write value types that can generate the above
* schema definition.
@@ -125,11 +125,11 @@
* <p> <b> Step 4: </b> Write the adapter that adapts the value type,
* MyHashMapType to a bound type, HashMap, used by the application.
*
- * <pre>
+ * <pre>{@code
* public final class MyHashMapAdapter extends
- * XmlAdapter<MyHashMapType,HashMap> { ... }
+ * XmlAdapter<MyHashMapType,HashMap> { ... }
*
- * </pre>
+ * }</pre>
*
* <p> <b> Step 5: </b> Use the adapter.
*
@@ -143,13 +143,13 @@
*
* The above code fragment will map to the following schema:
*
- * <pre>
- * <xs:complexType name="Foo">
- * <xs:sequence>
- * <xs:element name="hashmap" type="myHashMapType">
- * </xs:sequence>
- * </xs:complexType>
- * </pre>
+ * <pre>{@code
+ * <xs:complexType name="Foo">
+ * <xs:sequence>
+ * <xs:element name="hashmap" type="myHashMapType">
+ * </xs:sequence>
+ * </xs:complexType>
+ * }</pre>
*
* @param <BoundType>
* The type that JAXB doesn't know how to handle. An adapter is written
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/XmlJavaTypeAdapters.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/XmlJavaTypeAdapters.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -42,7 +42,7 @@
* @XmlJavaTypeAdapters ({ @XmlJavaTypeAdapter(...),@XmlJavaTypeAdapter(...) })
* </pre>
*
- * <p>The <tt>@XmlJavaTypeAdapters</tt> annnotation is useful for
+ * <p>The <tt>@XmlJavaTypeAdapters</tt> annotation is useful for
* defining {@link XmlJavaTypeAdapter} annotations for different types
* at the package level.
*
--- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/api/addressing/EPRHeader.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/api/addressing/EPRHeader.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -119,7 +119,7 @@
epr.writeTo(localName, w);
w.flush();
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- DocumentBuilderFactory fac = DocumentBuilderFactory.newInstance();
+ DocumentBuilderFactory fac = XmlUtil.newDocumentBuilderFactory(false);
fac.setNamespaceAware(true);
Node eprNode = fac.newDocumentBuilder().parse(bais).getDocumentElement();
Node eprNodeToAdd = header.getOwnerDocument().importNode(eprNode, true);
--- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/message/stream/StreamHeader.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/message/stream/StreamHeader.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -194,7 +194,7 @@
// TODO what about in-scope namespaces
// Not very efficient consider implementing a stream buffer
// processor that produces a DOM node from the buffer.
- TransformerFactory tf = XmlUtil.newTransformerFactory();
+ TransformerFactory tf = XmlUtil.newTransformerFactory(true);
Transformer t = tf.newTransformer();
XMLStreamBufferSource source = new XMLStreamBufferSource(_mark);
DOMResult result = new DOMResult();
--- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/spi/db/BindingHelper.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/spi/db/BindingHelper.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -36,6 +36,9 @@
//TODO DOMHeader DOMMessage SAAJMessage StatefulInstanceResolver
import com.sun.xml.internal.bind.unmarshaller.DOMScanner;
+//TODO MtomCodec
+import com.sun.xml.internal.bind.v2.runtime.output.Encoded;
+
//TODO ExceptionBean
import com.sun.xml.internal.bind.marshaller.NamespacePrefixMapper;
--- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/DOMUtil.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/DOMUtil.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -56,7 +56,7 @@
synchronized (DOMUtil.class) {
if (db == null) {
try {
- DocumentBuilderFactory dbf = XmlUtil.newDocumentBuilderFactory();
+ DocumentBuilderFactory dbf = XmlUtil.newDocumentBuilderFactory(true);
dbf.setNamespaceAware(true);
db = dbf.newDocumentBuilder();
} catch (ParserConfigurationException e) {
--- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/pipe/AbstractSchemaValidationTube.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/pipe/AbstractSchemaValidationTube.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -92,7 +92,7 @@
super(next);
this.binding = binding;
feature = binding.getFeature(SchemaValidationFeature.class);
- sf = allowExternalAccess(SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI), "file", false);
+ sf = allowExternalAccess(SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI), "all", false);
}
protected AbstractSchemaValidationTube(AbstractSchemaValidationTube that, TubeCloner cloner) {
--- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/version.properties Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/version.properties Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
# questions.
#
-build-id=2.2.11-b150127.1410
-build-version=JAX-WS RI 2.2.11-b150127.1410
+build-id=2.2.11-b150402.1412
+build-version=JAX-WS RI 2.2.11-b150402.1412
major-version=2.2.11
-svn-revision=28121d09ed8ac02b76788709ccb4cdb66e03bbfa
+svn-revision=f923291dedcf386c5f408263984a99d7cedf0012
--- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/xml/XMLStreamReaderToXMLStreamWriter.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/xml/XMLStreamReaderToXMLStreamWriter.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -187,14 +187,11 @@
protected void handleStartElement() throws XMLStreamException {
String nsUri = in.getNamespaceURI();
- if(nsUri==null)
- out.writeStartElement(in.getLocalName());
- else
- out.writeStartElement(
- fixNull(in.getPrefix()),
- in.getLocalName(),
- nsUri
- );
+ out.writeStartElement(
+ fixNull(in.getPrefix()),
+ in.getLocalName(),
+ fixNull(nsUri)
+ );
// start namespace bindings
int nsCount = in.getNamespaceCount();
--- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/xml/XmlUtil.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/xml/XmlUtil.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -231,7 +231,7 @@
static final ContextClassloaderLocal<SAXParserFactory> saxParserFactory = new ContextClassloaderLocal<SAXParserFactory>() {
@Override
protected SAXParserFactory initialValue() throws Exception {
- SAXParserFactory factory = SAXParserFactory.newInstance();
+ SAXParserFactory factory = newSAXParserFactory(true);
factory.setNamespaceAware(true);
return factory;
}
@@ -371,57 +371,49 @@
}
};
- public static DocumentBuilderFactory newDocumentBuilderFactory() {
- return newDocumentBuilderFactory(true);
- }
-
- public static DocumentBuilderFactory newDocumentBuilderFactory(boolean secureXmlProcessing) {
+ public static DocumentBuilderFactory newDocumentBuilderFactory(boolean disableSecurity) {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
try {
- factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, isXMLSecurityDisabled(secureXmlProcessing));
+ factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, !xmlSecurityDisabled(disableSecurity));
} catch (ParserConfigurationException e) {
LOGGER.log(Level.WARNING, "Factory [{0}] doesn't support secure xml processing!", new Object[] { factory.getClass().getName() } );
}
return factory;
}
- public static TransformerFactory newTransformerFactory(boolean secureXmlProcessingEnabled) {
+ public static TransformerFactory newTransformerFactory(boolean disableSecurity) {
TransformerFactory factory = TransformerFactory.newInstance();
try {
- factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, isXMLSecurityDisabled(secureXmlProcessingEnabled));
+ factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, !xmlSecurityDisabled(disableSecurity));
} catch (TransformerConfigurationException e) {
LOGGER.log(Level.WARNING, "Factory [{0}] doesn't support secure xml processing!", new Object[]{factory.getClass().getName()});
}
return factory;
}
- public static TransformerFactory newTransformerFactory() {
- return newTransformerFactory(true);
- }
-
- public static SAXParserFactory newSAXParserFactory(boolean secureXmlProcessingEnabled) {
+ public static SAXParserFactory newSAXParserFactory(boolean disableSecurity) {
SAXParserFactory factory = SAXParserFactory.newInstance();
try {
- factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, isXMLSecurityDisabled(secureXmlProcessingEnabled));
+ factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, !xmlSecurityDisabled(disableSecurity));
} catch (Exception e) {
LOGGER.log(Level.WARNING, "Factory [{0}] doesn't support secure xml processing!", new Object[]{factory.getClass().getName()});
}
return factory;
}
- public static XPathFactory newXPathFactory(boolean secureXmlProcessingEnabled) {
+ public static XPathFactory newXPathFactory(boolean disableSecurity) {
XPathFactory factory = XPathFactory.newInstance();
try {
- factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, isXMLSecurityDisabled(secureXmlProcessingEnabled));
+ factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, !xmlSecurityDisabled(disableSecurity));
} catch (XPathFactoryConfigurationException e) {
LOGGER.log(Level.WARNING, "Factory [{0}] doesn't support secure xml processing!", new Object[] { factory.getClass().getName() } );
}
return factory;
}
- public static XMLInputFactory newXMLInputFactory(boolean secureXmlProcessingEnabled) {
+ public static XMLInputFactory newXMLInputFactory(boolean disableSecurity) {
XMLInputFactory factory = XMLInputFactory.newInstance();
- if (isXMLSecurityDisabled(secureXmlProcessingEnabled)) {
+ if (xmlSecurityDisabled(disableSecurity)) {
// TODO-Miran: are those apppropriate defaults?
factory.setProperty(XMLInputFactory.SUPPORT_DTD, false);
factory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false);
@@ -429,14 +421,14 @@
return factory;
}
- private static boolean isXMLSecurityDisabled(boolean runtimeDisabled) {
+ private static boolean xmlSecurityDisabled(boolean runtimeDisabled) {
return XML_SECURITY_DISABLED || runtimeDisabled;
}
- public static SchemaFactory allowExternalAccess(SchemaFactory sf, String value, boolean disableSecureProcessing) {
+ public static SchemaFactory allowExternalAccess(SchemaFactory sf, String value, boolean disableSecurity) {
// if xml security (feature secure processing) disabled, nothing to do, no restrictions applied
- if (isXMLSecurityDisabled(disableSecureProcessing)) {
+ if (xmlSecurityDisabled(disableSecurity)) {
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE, "Xml Security disabled, no JAXP xsd external access configuration necessary.");
}
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle.properties Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle.properties Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -30,10 +30,10 @@
Non-existent directory: {0}
VERSION = \
- schemagen 2.2.12-b150126.1924
+ schemagen 2.2.12-b150331.1824
FULLVERSION = \
- schemagen full version "2.2.12-b150126.1924"
+ schemagen full version "2.2.12-b150331.1824"
USAGE = \
Usage: schemagen [-options ...] <java files> \n\
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_de.properties Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_de.properties Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -27,8 +27,8 @@
BASEDIR_DOESNT_EXIST = Nicht vorhandenes Verzeichnis: {0}
-VERSION = schemagen 2.2.12-b150126.1924
+VERSION = schemagen 2.2.12-b150331.1824
-FULLVERSION = schemagen vollst\u00E4ndige Version "2.2.12-b150126.1924"
+FULLVERSION = schemagen vollst\u00E4ndige Version "2.2.12-b150331.1824"
USAGE = Verwendung: schemagen [-options ...] <java files> \nOptionen: \n\\ \\ \\ \\ -d <path> : Gibt an, wo die von Prozessor und javac generierten Klassendateien gespeichert werden sollen\n\\ \\ \\ \\ -cp <path> : Gibt an, wo die vom Benutzer angegebenen Dateien gespeichert sind\n\\ \\ \\ \\ -classpath <path> : Gibt an, wo die vom Benutzer angegebenen Dateien gespeichert sind\n\\ \\ \\ \\ -encoding <encoding> : Gibt die Codierung f\u00FCr die Annotationsverarbeitung/den javac-Aufruf an \n\\ \\ \\ \\ -episode <file> : Generiert Episodendatei f\u00FCr separate Kompilierung\n\\ \\ \\ \\ -version : Zeigt Versionsinformation an\n\\ \\ \\ \\ -fullversion : Zeigt vollst\u00E4ndige Versionsinformationen an\n\\ \\ \\ \\ -help : Zeigt diese Verwendungsmeldung an
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_es.properties Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_es.properties Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -27,8 +27,8 @@
BASEDIR_DOESNT_EXIST = Directorio no existente: {0}
-VERSION = schemagen 2.2.12-b150126.1924
+VERSION = schemagen 2.2.12-b150331.1824
-FULLVERSION = versi\u00F3n completa de schemagen "2.2.12-b150126.1924"
+FULLVERSION = versi\u00F3n completa de schemagen "2.2.12-b150331.1824"
USAGE = Sintaxis: schemagen [-options ...] <archivos java> \nOpciones: \n\\ \\ \\ \\ -d <ruta de acceso> : especifique d\u00F3nde se colocan los archivos de clase generados por javac y el procesador\n\\ \\ \\ \\ -cp <ruta de acceso> : especifique d\u00F3nde se encuentran los archivos especificados por el usuario\n\\ \\ \\ \\ -encoding <codificaci\u00F3n> : especifique la codificaci\u00F3n que se va a utilizar para el procesamiento de anotaciones/llamada de javac\n\\ \\ \\ \\ -episode <archivo> : genera un archivo de episodio para una compilaci\u00F3n diferente\n\\ \\ \\ \\ -version : muestra la informaci\u00F3n de la versi\u00F3n\n\\ \\ \\ \\ -fullversion : muestra la informaci\u00F3n completa de la versi\u00F3n\n\\ \\ \\ \\ -help : muestra este mensaje de sintaxis
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_fr.properties Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_fr.properties Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -27,8 +27,8 @@
BASEDIR_DOESNT_EXIST = R\u00E9pertoire {0} inexistant
-VERSION = schemagen 2.2.12-b150126.1924
+VERSION = schemagen 2.2.12-b150331.1824
-FULLVERSION = version compl\u00E8te de schemagen "2.2.12-b150126.1924"
+FULLVERSION = version compl\u00E8te de schemagen "2.2.12-b150331.1824"
USAGE = Syntaxe : schemagen [-options ...] <java files> \nOptions : \n\ \ \ \ -d <path> : indiquez o\u00F9 placer les fichiers de classe g\u00E9n\u00E9r\u00E9s par le processeur et le compilateur javac\n\ \ \ \ -cp <path> : indiquez o\u00F9 trouver les fichiers sp\u00E9cifi\u00E9s par l'utilisateur\n\ \ \ \ -classpath <path> : indiquez o\u00F9 trouver les fichiers sp\u00E9cifi\u00E9s par l'utilisateur\n\ \ \ \ -encoding <encoding> : indiquez l'encodage \u00E0 utiliser pour l'appel de javac/traitement de l'annotation \n\ \ \ \ -episode <file> : g\u00E9n\u00E9rez un fichier d'\u00E9pisode pour la compilation s\u00E9par\u00E9e\n\ \ \ \ -version : affichez les informations de version\n\ \ \ \ -fullversion : affichez les informations compl\u00E8tes de version\n\ \ \ \ -help : affichez ce message de syntaxe
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_it.properties Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_it.properties Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -27,8 +27,8 @@
BASEDIR_DOESNT_EXIST = Directory non esistente: {0}
-VERSION = schemagen 2.2.12-b150126.1924
+VERSION = schemagen 2.2.12-b150331.1824
-FULLVERSION = versione completa schemagen "2.2.12-b150126.1924"
+FULLVERSION = versione completa schemagen "2.2.12-b150331.1824"
USAGE = Uso: schemagen [-options ...] <java files> \nOpzioni: \n\ \ \ \ -d <path> : specifica dove posizionare il processore e i file della classe generata javac\n\ \ \ \ -cp <path> : specifica dove trovare i file specificati dall'utente\n\ \ \ \ -classpath <path> : specifica dove trovare i file specificati dall'utente\n\ \ \ \ -encoding <encoding> : specifica la codifica da usare per l'elaborazione dell'annotazione/richiamo javac \n\ \ \ \ -episode <file> : genera il file di episodio per la compilazione separata\n\ \ \ \ -version : visualizza le informazioni sulla versione\n\ \ \ \ -fullversion : visualizza le informazioni sulla versione completa\n\ \ \ \ -help : visualizza questo messaggio sull'uso
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_ja.properties Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_ja.properties Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -27,8 +27,8 @@
BASEDIR_DOESNT_EXIST = \u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u304C\u5B58\u5728\u3057\u307E\u305B\u3093: {0}
-VERSION = schemagen 2.2.12-b150126.1924
+VERSION = schemagen 2.2.12-b150331.1824
-FULLVERSION = schemagen\u30D5\u30EB\u30FB\u30D0\u30FC\u30B8\u30E7\u30F3"2.2.12-b150126.1924"
+FULLVERSION = schemagen\u30D5\u30EB\u30FB\u30D0\u30FC\u30B8\u30E7\u30F3"2.2.12-b150331.1824"
USAGE = \u4F7F\u7528\u65B9\u6CD5: schemagen [-options ...] <java files> \n\u30AA\u30D7\u30B7\u30E7\u30F3: \n\ \ \ \ -d <path> : \u30D7\u30ED\u30BB\u30C3\u30B5\u304A\u3088\u3073javac\u304C\u751F\u6210\u3057\u305F\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u7F6E\u304F\u4F4D\u7F6E\u3092\u6307\u5B9A\u3057\u307E\u3059\n\ \ \ \ -cp <path> : \u30E6\u30FC\u30B6\u30FC\u304C\u6307\u5B9A\u3057\u305F\u30D5\u30A1\u30A4\u30EB\u3092\u691C\u7D22\u3059\u308B\u4F4D\u7F6E\u3092\u6307\u5B9A\u3057\u307E\u3059\n\ \ \ \ -classpath <path> : \u30E6\u30FC\u30B6\u30FC\u304C\u6307\u5B9A\u3057\u305F\u30D5\u30A1\u30A4\u30EB\u3092\u691C\u7D22\u3059\u308B\u4F4D\u7F6E\u3092\u6307\u5B9A\u3057\u307E\u3059\n\ \ \ \ -encoding <encoding> : \u6CE8\u91C8\u51E6\u7406/javac\u547C\u51FA\u3057\u306B\u4F7F\u7528\u3059\u308B\u30A8\u30F3\u30B3\u30FC\u30C7\u30A3\u30F3\u30B0\u3092\u6307\u5B9A\u3057\u307E\u3059\n\ \ \ \ -episode <file> : \u30B3\u30F3\u30D1\u30A4\u30EB\u3054\u3068\u306B\u30A8\u30D4\u30BD\u30FC\u30C9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u751F\u6210\u3057\u307E\u3059\n\ \ \ \ -version : \u30D0\u30FC\u30B8\u30E7\u30F3\u60C5\u5831\u3092\u8868\u793A\u3057\u307E\u3059\n\ \ \ \ -fullversion : \u30D5\u30EB\u30FB\u30D0\u30FC\u30B8\u30E7\u30F3\u60C5\u5831\u3092\u8868\u793A\u3057\u307E\u3059\n\ \ \ \ -help : \u3053\u306E\u4F7F\u7528\u4F8B\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u8868\u793A\u3057\u307E\u3059
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_ko.properties Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_ko.properties Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -27,8 +27,8 @@
BASEDIR_DOESNT_EXIST = \uC874\uC7AC\uD558\uC9C0 \uC54A\uB294 \uB514\uB809\uD1A0\uB9AC: {0}
-VERSION = schemagen 2.2.12-b150126.1924
+VERSION = schemagen 2.2.12-b150331.1824
-FULLVERSION = schemagen \uC815\uC2DD \uBC84\uC804 "2.2.12-b150126.1924"
+FULLVERSION = schemagen \uC815\uC2DD \uBC84\uC804 "2.2.12-b150331.1824"
USAGE = \uC0AC\uC6A9\uBC95: schemagen [-options ...] <java files> \n\uC635\uC158: \n\ \ \ \ -d <path> : \uD504\uB85C\uC138\uC11C \uBC0F javac\uC5D0\uC11C \uC0DD\uC131\uD55C \uD074\uB798\uC2A4 \uD30C\uC77C\uC744 \uBC30\uCE58\uD560 \uC704\uCE58\uB97C \uC9C0\uC815\uD569\uB2C8\uB2E4.\n\ \ \ \ -cp <path> : \uC0AC\uC6A9\uC790\uAC00 \uC9C0\uC815\uD55C \uD30C\uC77C\uC744 \uCC3E\uC744 \uC704\uCE58\uB97C \uC9C0\uC815\uD569\uB2C8\uB2E4.\n\ \ \ \ -classpath <path> : \uC0AC\uC6A9\uC790\uAC00 \uC9C0\uC815\uD55C \uD30C\uC77C\uC744 \uCC3E\uC744 \uC704\uCE58\uB97C \uC9C0\uC815\uD569\uB2C8\uB2E4.\n\ \ \ \ -encoding <encoding> : \uC8FC\uC11D \uCC98\uB9AC/javac \uD638\uCD9C\uC5D0 \uC0AC\uC6A9\uD560 \uC778\uCF54\uB529\uC744 \uC9C0\uC815\uD569\uB2C8\uB2E4. \n\ \ \ \ -episode <file> : \uBCC4\uB3C4 \uCEF4\uD30C\uC77C\uC744 \uC704\uD574 episode \uD30C\uC77C\uC744 \uC0DD\uC131\uD569\uB2C8\uB2E4.\n\ \ \ \ -version : \uBC84\uC804 \uC815\uBCF4\uB97C \uD45C\uC2DC\uD569\uB2C8\uB2E4.\n\ \ \ \ -fullversion : \uC815\uC2DD \uBC84\uC804 \uC815\uBCF4\uB97C \uD45C\uC2DC\uD569\uB2C8\uB2E4.\n\ \ \ \ -help : \uC774 \uC0AC\uC6A9\uBC95 \uBA54\uC2DC\uC9C0\uB97C \uD45C\uC2DC\uD569\uB2C8\uB2E4.
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_pt_BR.properties Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_pt_BR.properties Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -27,8 +27,8 @@
BASEDIR_DOESNT_EXIST = Diret\u00F3rio n\u00E3o existente: {0}
-VERSION = gera\u00E7\u00E3o do esquema 2.2.12-b150126.1924
+VERSION = gera\u00E7\u00E3o do esquema 2.2.12-b150331.1824
-FULLVERSION = vers\u00E3o completa da gera\u00E7\u00E3o do esquema "2.2.12-b150126.1924"
+FULLVERSION = vers\u00E3o completa da gera\u00E7\u00E3o do esquema "2.2.12-b150331.1824"
USAGE = Uso: gera\u00E7\u00E3o do esquema [-options ...] <java files> \nOp\u00E7\u00F5es: \n\\ \\ \\ \\ -d <path> : especificar onde colocar o processador e os arquivos da classe gerados por javac\n\\ \\ \\ \\ -cp <path> : especificar onde localizar arquivos especificados pelo usu\u00E1rio\n\\ \\ \\ \\ -classpath <path> : especificar onde localizar os arquivos especificados pelo usu\u00E1rio\n\\ \\ \\ \\ -encoding <encoding> : especificar codifica\u00E7\u00E3o a ser usada para processamento de anota\u00E7\u00E3o/chamada javac \n\\ \\ \\ \\ -episode <file> : gerar arquivo do epis\u00F3dio para compila\u00E7\u00E3o separada\n\\ \\ \\ \\ -version : exibir informa\u00E7\u00F5es da vers\u00E3o\n\\ \\ \\ \\ -fullversion : exibir informa\u00E7\u00F5es da vers\u00E3o completa\n\\ \\ \\ \\ -help : exibir esta mensagem de uso
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_zh_CN.properties Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_zh_CN.properties Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -27,8 +27,8 @@
BASEDIR_DOESNT_EXIST = \u4E0D\u5B58\u5728\u7684\u76EE\u5F55: {0}
-VERSION = schemagen 2.2.12-b150126.1924
+VERSION = schemagen 2.2.12-b150331.1824
-FULLVERSION = schemagen \u5B8C\u6574\u7248\u672C "2.2.12-b150126.1924"
+FULLVERSION = schemagen \u5B8C\u6574\u7248\u672C "2.2.12-b150331.1824"
USAGE = \u7528\u6CD5: schemagen [-options ...] <java files> \n\u9009\u9879: \n\ \ \ \ -d <path> : \u6307\u5B9A\u653E\u7F6E\u5904\u7406\u7A0B\u5E8F\u548C javac \u751F\u6210\u7684\u7C7B\u6587\u4EF6\u7684\u4F4D\u7F6E\n\ \ \ \ -cp <path> : \u6307\u5B9A\u67E5\u627E\u7528\u6237\u6307\u5B9A\u6587\u4EF6\u7684\u4F4D\u7F6E\n\ \ \ \ -classpath <path> : \u6307\u5B9A\u67E5\u627E\u7528\u6237\u6307\u5B9A\u6587\u4EF6\u7684\u4F4D\u7F6E\n\ \ \ \ -encoding <encoding> : \u6307\u5B9A\u7528\u4E8E\u6CE8\u91CA\u5904\u7406/javac \u8C03\u7528\u7684\u7F16\u7801\n\ \ \ \ -episode <file> : \u751F\u6210\u7247\u6BB5\u6587\u4EF6\u4EE5\u4F9B\u5355\u72EC\u7F16\u8BD1\n\ \ \ \ -version : \u663E\u793A\u7248\u672C\u4FE1\u606F\n\ \ \ \ -fullversion : \u663E\u793A\u5B8C\u6574\u7684\u7248\u672C\u4FE1\u606F\n\ \ \ \ -help : \u663E\u793A\u6B64\u7528\u6CD5\u6D88\u606F
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_zh_TW.properties Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_zh_TW.properties Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -27,8 +27,8 @@
BASEDIR_DOESNT_EXIST = \u4E0D\u5B58\u5728\u7684\u76EE\u9304: {0}
-VERSION = schemagen 2.2.12-b150126.1924
+VERSION = schemagen 2.2.12-b150331.1824
-FULLVERSION = schemagen \u5B8C\u6574\u7248\u672C "2.2.12-b150126.1924"
+FULLVERSION = schemagen \u5B8C\u6574\u7248\u672C "2.2.12-b150331.1824"
USAGE = \u7528\u6CD5: schemagen [-options ...] <java files> \n\u9078\u9805: \n\\ \\ \\ \\ -d <path> : \u6307\u5B9A\u8655\u7406\u5668\u4EE5\u53CA javac \u7522\u751F\u7684\u985E\u5225\u6A94\u6848\u653E\u7F6E\u4F4D\u7F6E\n\\ \\ \\ \\ -cp <path> : \u6307\u5B9A\u8981\u5C0B\u627E\u4F7F\u7528\u8005\u6307\u5B9A\u6A94\u6848\u7684\u4F4D\u7F6E\n\\ \\ \\ \\ -classpath <path> : \u6307\u5B9A\u8981\u5C0B\u627E\u4F7F\u7528\u8005\u6307\u5B9A\u6A94\u6848\u7684\u4F4D\u7F6E\n\\ \\ \\ \\ -encoding <encoding> : \u6307\u5B9A\u8981\u7528\u65BC\u8A3B\u89E3\u8655\u7406/javac \u547C\u53EB\u7684\u7DE8\u78BC \n\\ \\ \\ \\ -episode <file> : \u7522\u751F\u7368\u7ACB\u7DE8\u8B6F\u7684\u4E8B\u4EF6 (episode) \u6A94\u6848\n\\ \\ \\ \\ -version : \u986F\u793A\u7248\u672C\u8CC7\u8A0A\n\\ \\ \\ \\ -fullversion : \u986F\u793A\u5B8C\u6574\u7248\u672C\u8CC7\u8A0A\n\\ \\ \\ \\ -help : \u986F\u793A\u6B64\u7528\u6CD5\u8A0A\u606F
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/SchemaGenerator.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/SchemaGenerator.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -158,7 +158,12 @@
while (cl != null) {
if (cl instanceof URLClassLoader) {
for (URL url : ((URLClassLoader) cl).getURLs()) {
- appendPath(cp, url.getPath());
+ try {
+ appendPath(cp,new File(url.toURI()).getPath());
+ } catch(URISyntaxException ex) {
+ /*If the URL is not properly formated - skip it*/
+ LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
+ }
}
}
cl = cl.getParent();
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/ap/SchemaGenerator.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/ap/SchemaGenerator.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,8 +23,6 @@
* questions.
*/
-
-
package com.sun.tools.internal.jxc.ap;
import com.sun.tools.internal.jxc.api.JXC;
@@ -89,12 +87,12 @@
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
final ErrorReceiverImpl errorListener = new ErrorReceiverImpl(processingEnv);
- List<Reference> classes = new ArrayList<Reference>();
+ List<Reference> classesToBeBound = new ArrayList<Reference>();
// simply ignore all the interface definitions,
// so that users won't have to manually exclude interfaces, which is silly.
- filterClass(classes, roundEnv.getRootElements());
+ filterClass(classesToBeBound, roundEnv.getRootElements());
- J2SJAXBModel model = JXC.createJavaCompiler().bind(classes, Collections.<QName, Reference>emptyMap(), null, processingEnv);
+ J2SJAXBModel model = JXC.createJavaCompiler().bind(classesToBeBound, Collections.<QName, Reference>emptyMap(), null, processingEnv);
if (model == null)
return false; // error
@@ -133,11 +131,17 @@
return false;
}
- private void filterClass(List<Reference> classes, Collection<? extends Element> elements) {
+ /**
+ * Filter classes (note that enum is kind of class) from elements tree
+ * @param result list of found classes
+ * @param elements tree to be filtered
+ */
+ private void filterClass(List<Reference> result, Collection<? extends Element> elements) {
for (Element element : elements) {
- if (element.getKind().equals(ElementKind.CLASS) || element.getKind().equals(ElementKind.ENUM)) {
- classes.add(new Reference((TypeElement) element, processingEnv));
- filterClass(classes, ElementFilter.typesIn(element.getEnclosedElements()));
+ final ElementKind kind = element.getKind();
+ if (ElementKind.CLASS.equals(kind) || ElementKind.ENUM.equals(kind)) {
+ result.add(new Reference((TypeElement) element, processingEnv));
+ filterClass(result, ElementFilter.typesIn(element.getEnclosedElements()));
}
}
}
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/model/nav/ApNavigator.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/model/nav/ApNavigator.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,12 @@
import com.sun.source.util.Trees;
import com.sun.xml.internal.bind.v2.model.nav.Navigator;
import com.sun.xml.internal.bind.v2.runtime.Location;
-
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
@@ -52,12 +57,6 @@
import javax.lang.model.util.Elements;
import javax.lang.model.util.SimpleTypeVisitor6;
import javax.lang.model.util.Types;
-import java.lang.annotation.Annotation;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
/**
* {@link Navigator} implementation for annotation processing.
@@ -241,7 +240,7 @@
public VariableElement[] getEnumConstants(TypeElement clazz) {
List<? extends Element> elements = env.getElementUtils().getAllMembers(clazz);
- Collection<VariableElement> constants = new HashSet<VariableElement>();
+ Collection<VariableElement> constants = new ArrayList<VariableElement>();
for (Element element : elements) {
if (element.getKind().equals(ElementKind.ENUM_CONSTANT)) {
constants.add((VariableElement) element);
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle.properties Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle.properties Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -171,20 +171,20 @@
Driver.FailedToGenerateCode = \
Failed to produce code.
-# DO NOT localize the 2.2.12-b150126.1924 string - it is a token for an mvn <properties filter>
+# DO NOT localize the 2.2.12-b150331.1824 string - it is a token for an mvn <properties filter>
Driver.FilePrologComment = \
- This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.12-b150126.1924 \n\
+ This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.12-b150331.1824 \n\
See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> \n\
Any modifications to this file will be lost upon recompilation of the source schema. \n\
Generated on: {0} \n
Driver.Version = \
- xjc 2.2.12-b150126.1924
+ xjc 2.2.12-b150331.1824
Driver.FullVersion = \
- xjc full version "2.2.12-b150126.1924"
+ xjc full version "2.2.12-b150331.1824"
-Driver.BuildID = 2.2.12-b150126.1924
+Driver.BuildID = 2.2.12-b150331.1824
# for JDK integration - include version in source zip
jaxb.jdk.version=@@JAXB_JDK_VERSION@@
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_de.properties Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_de.properties Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -96,14 +96,14 @@
Driver.FailedToGenerateCode = Code konnte nicht erzeugt werden.
-# DO NOT localize the 2.2.12-b150126.1924 string - it is a token for an mvn <properties filter>
-Driver.FilePrologComment = Diese Datei wurde mit der JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.12-b150126.1924 generiert \nSiehe <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> \n\u00c4nderungen an dieser Datei gehen bei einer Neukompilierung des Quellschemas verloren. \nGeneriert: {0} \n
+# DO NOT localize the 2.2.12-b150331.1824 string - it is a token for an mvn <properties filter>
+Driver.FilePrologComment = Diese Datei wurde mit der JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.12-b150331.1824 generiert \nSiehe <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> \n\u00c4nderungen an dieser Datei gehen bei einer Neukompilierung des Quellschemas verloren. \nGeneriert: {0} \n
-Driver.Version = xjc 2.2.12-b150126.1924
+Driver.Version = xjc 2.2.12-b150331.1824
-Driver.FullVersion = xjc vollst\u00E4ndige Version "2.2.12-b150126.1924"
+Driver.FullVersion = xjc vollst\u00E4ndige Version "2.2.12-b150331.1824"
-Driver.BuildID = 2.2.12-b150126.1924
+Driver.BuildID = 2.2.12-b150331.1824
# for JDK integration - include version in source zip
jaxb.jdk.version=@@JAXB_JDK_VERSION@@
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_es.properties Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_es.properties Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -96,14 +96,14 @@
Driver.FailedToGenerateCode = Fallo al producir c\u00f3digo.
-# DO NOT localize the 2.2.12-b150126.1924 string - it is a token for an mvn <properties filter>
-Driver.FilePrologComment = Este archivo ha sido generado por la arquitectura JavaTM para la implantaci\u00f3n de la referencia de enlace (JAXB) XML v2.2.12-b150126.1924 \nVisite <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> \nTodas las modificaciones realizadas en este archivo se perder\u00e1n si se vuelve a compilar el esquema de origen. \nGenerado el: {0} \n
+# DO NOT localize the 2.2.12-b150331.1824 string - it is a token for an mvn <properties filter>
+Driver.FilePrologComment = Este archivo ha sido generado por la arquitectura JavaTM para la implantaci\u00f3n de la referencia de enlace (JAXB) XML v2.2.12-b150331.1824 \nVisite <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> \nTodas las modificaciones realizadas en este archivo se perder\u00e1n si se vuelve a compilar el esquema de origen. \nGenerado el: {0} \n
-Driver.Version = xjc 2.2.12-b150126.1924
+Driver.Version = xjc 2.2.12-b150331.1824
-Driver.FullVersion = versi\u00F3n completa de xjc "2.2.12-b150126.1924"
+Driver.FullVersion = versi\u00F3n completa de xjc "2.2.12-b150331.1824"
-Driver.BuildID = 2.2.12-b150126.1924
+Driver.BuildID = 2.2.12-b150331.1824
# for JDK integration - include version in source zip
jaxb.jdk.version=@@JAXB_JDK_VERSION@@
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_fr.properties Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_fr.properties Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -96,14 +96,14 @@
Driver.FailedToGenerateCode = Echec de la production du code.
-# DO NOT localize the 2.2.12-b150126.1924 string - it is a token for an mvn <properties filter>
-Driver.FilePrologComment = Ce fichier a \u00e9t\u00e9 g\u00e9n\u00e9r\u00e9 par l''impl\u00e9mentation de r\u00e9f\u00e9rence JavaTM Architecture for XML Binding (JAXB), v2.2.12-b150126.1924 \nVoir <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> \nToute modification apport\u00e9e \u00e0 ce fichier sera perdue lors de la recompilation du sch\u00e9ma source. \nG\u00e9n\u00e9r\u00e9 le : {0} \n
+# DO NOT localize the 2.2.12-b150331.1824 string - it is a token for an mvn <properties filter>
+Driver.FilePrologComment = Ce fichier a \u00e9t\u00e9 g\u00e9n\u00e9r\u00e9 par l''impl\u00e9mentation de r\u00e9f\u00e9rence JavaTM Architecture for XML Binding (JAXB), v2.2.12-b150331.1824 \nVoir <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> \nToute modification apport\u00e9e \u00e0 ce fichier sera perdue lors de la recompilation du sch\u00e9ma source. \nG\u00e9n\u00e9r\u00e9 le : {0} \n
-Driver.Version = xjc 2.2.12-b150126.1924
+Driver.Version = xjc 2.2.12-b150331.1824
-Driver.FullVersion = version compl\u00E8te xjc "2.2.12-b150126.1924"
+Driver.FullVersion = version compl\u00E8te xjc "2.2.12-b150331.1824"
-Driver.BuildID = 2.2.12-b150126.1924
+Driver.BuildID = 2.2.12-b150331.1824
# for JDK integration - include version in source zip
jaxb.jdk.version=@@JAXB_JDK_VERSION@@
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_it.properties Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_it.properties Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -96,14 +96,14 @@
Driver.FailedToGenerateCode = Produzione del codice non riuscita.
-# DO NOT localize the 2.2.12-b150126.1924 string - it is a token for an mvn <properties filter>
-Driver.FilePrologComment = Questo file \u00e8 stato generato dall''architettura JavaTM per XML Binding (JAXB) Reference Implementation, v2.2.12-b150126.1924 \nVedere <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> \nQualsiasi modifica a questo file andr\u00e0 persa durante la ricompilazione dello schema di origine. \nGenerato il: {0} \n
+# DO NOT localize the 2.2.12-b150331.1824 string - it is a token for an mvn <properties filter>
+Driver.FilePrologComment = Questo file \u00e8 stato generato dall''architettura JavaTM per XML Binding (JAXB) Reference Implementation, v2.2.12-b150331.1824 \nVedere <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> \nQualsiasi modifica a questo file andr\u00e0 persa durante la ricompilazione dello schema di origine. \nGenerato il: {0} \n
-Driver.Version = xjc 2.2.12-b150126.1924
+Driver.Version = xjc 2.2.12-b150331.1824
-Driver.FullVersion = versione completa xjc "2.2.12-b150126.1924"
+Driver.FullVersion = versione completa xjc "2.2.12-b150331.1824"
-Driver.BuildID = 2.2.12-b150126.1924
+Driver.BuildID = 2.2.12-b150331.1824
# for JDK integration - include version in source zip
jaxb.jdk.version=@@JAXB_JDK_VERSION@@
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_ja.properties Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_ja.properties Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -96,14 +96,14 @@
Driver.FailedToGenerateCode = \u30b3\u30fc\u30c9\u306e\u751f\u6210\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002
-# DO NOT localize the 2.2.12-b150126.1924 string - it is a token for an mvn <properties filter>
-Driver.FilePrologComment = \u3053\u306e\u30d5\u30a1\u30a4\u30eb\u306f\u3001JavaTM Architecture for XML Binding(JAXB) Reference Implementation\u3001v2.2.12-b150126.1924\u306b\u3088\u3063\u3066\u751f\u6210\u3055\u308c\u307e\u3057\u305f \n<a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044 \n\u30bd\u30fc\u30b9\u30fb\u30b9\u30ad\u30fc\u30de\u306e\u518d\u30b3\u30f3\u30d1\u30a4\u30eb\u6642\u306b\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u306e\u5909\u66f4\u306f\u5931\u308f\u308c\u307e\u3059\u3002 \n\u751f\u6210\u65e5: {0} \n
+# DO NOT localize the 2.2.12-b150331.1824 string - it is a token for an mvn <properties filter>
+Driver.FilePrologComment = \u3053\u306e\u30d5\u30a1\u30a4\u30eb\u306f\u3001JavaTM Architecture for XML Binding(JAXB) Reference Implementation\u3001v2.2.12-b150331.1824\u306b\u3088\u3063\u3066\u751f\u6210\u3055\u308c\u307e\u3057\u305f \n<a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044 \n\u30bd\u30fc\u30b9\u30fb\u30b9\u30ad\u30fc\u30de\u306e\u518d\u30b3\u30f3\u30d1\u30a4\u30eb\u6642\u306b\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u306e\u5909\u66f4\u306f\u5931\u308f\u308c\u307e\u3059\u3002 \n\u751f\u6210\u65e5: {0} \n
-Driver.Version = xjc 2.2.12-b150126.1924
+Driver.Version = xjc 2.2.12-b150331.1824
-Driver.FullVersion = xjc\u30D5\u30EB\u30FB\u30D0\u30FC\u30B8\u30E7\u30F3"2.2.12-b150126.1924"
+Driver.FullVersion = xjc\u30D5\u30EB\u30FB\u30D0\u30FC\u30B8\u30E7\u30F3"2.2.12-b150331.1824"
-Driver.BuildID = 2.2.12-b150126.1924
+Driver.BuildID = 2.2.12-b150331.1824
# for JDK integration - include version in source zip
jaxb.jdk.version=@@JAXB_JDK_VERSION@@
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_ko.properties Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_ko.properties Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -96,14 +96,14 @@
Driver.FailedToGenerateCode = \ucf54\ub4dc \uc0dd\uc131\uc744 \uc2e4\ud328\ud588\uc2b5\ub2c8\ub2e4.
-# DO NOT localize the 2.2.12-b150126.1924 string - it is a token for an mvn <properties filter>
-Driver.FilePrologComment = \uc774 \ud30c\uc77c\uc740 JAXB(JavaTM Architecture for XML Binding) \ucc38\uc870 \uad6c\ud604 2.2.12-b150126.1924 \ubc84\uc804\uc744 \ud1b5\ud574 \uc0dd\uc131\ub418\uc5c8\uc2b5\ub2c8\ub2e4. \n<a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>\ub97c \ucc38\uc870\ud558\uc2ed\uc2dc\uc624. \n\uc774 \ud30c\uc77c\uc744 \uc218\uc815\ud558\uba74 \uc18c\uc2a4 \uc2a4\ud0a4\ub9c8\ub97c \uc7ac\ucef4\ud30c\uc77c\ud560 \ub54c \uc218\uc815 \uc0ac\ud56d\uc774 \uc190\uc2e4\ub429\ub2c8\ub2e4. \n\uc0dd\uc131 \ub0a0\uc9dc: {0} \n
+# DO NOT localize the 2.2.12-b150331.1824 string - it is a token for an mvn <properties filter>
+Driver.FilePrologComment = \uc774 \ud30c\uc77c\uc740 JAXB(JavaTM Architecture for XML Binding) \ucc38\uc870 \uad6c\ud604 2.2.12-b150331.1824 \ubc84\uc804\uc744 \ud1b5\ud574 \uc0dd\uc131\ub418\uc5c8\uc2b5\ub2c8\ub2e4. \n<a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>\ub97c \ucc38\uc870\ud558\uc2ed\uc2dc\uc624. \n\uc774 \ud30c\uc77c\uc744 \uc218\uc815\ud558\uba74 \uc18c\uc2a4 \uc2a4\ud0a4\ub9c8\ub97c \uc7ac\ucef4\ud30c\uc77c\ud560 \ub54c \uc218\uc815 \uc0ac\ud56d\uc774 \uc190\uc2e4\ub429\ub2c8\ub2e4. \n\uc0dd\uc131 \ub0a0\uc9dc: {0} \n
-Driver.Version = XJC 2.2.12-b150126.1924
+Driver.Version = XJC 2.2.12-b150331.1824
-Driver.FullVersion = XJC \uC815\uC2DD \uBC84\uC804 "2.2.12-b150126.1924"
+Driver.FullVersion = XJC \uC815\uC2DD \uBC84\uC804 "2.2.12-b150331.1824"
-Driver.BuildID = 2.2.12-b150126.1924
+Driver.BuildID = 2.2.12-b150331.1824
# for JDK integration - include version in source zip
jaxb.jdk.version=@@JAXB_JDK_VERSION@@
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_pt_BR.properties Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_pt_BR.properties Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -96,14 +96,14 @@
Driver.FailedToGenerateCode = Falha ao produzir o c\u00f3digo.
-# DO NOT localize the 2.2.12-b150126.1924 string - it is a token for an mvn <properties filter>
-Driver.FilePrologComment = Este arquivo foi gerado pela Arquitetura JavaTM para Implementa\u00e7\u00e3o de Refer\u00eancia (JAXB) de Bind XML, v2.2.12-b150126.1924 \nConsulte <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> \nTodas as modifica\u00e7\u00f5es neste arquivo ser\u00e3o perdidas ap\u00f3s a recompila\u00e7\u00e3o do esquema de origem. \nGerado em: {0} \n
+# DO NOT localize the 2.2.12-b150331.1824 string - it is a token for an mvn <properties filter>
+Driver.FilePrologComment = Este arquivo foi gerado pela Arquitetura JavaTM para Implementa\u00e7\u00e3o de Refer\u00eancia (JAXB) de Bind XML, v2.2.12-b150331.1824 \nConsulte <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> \nTodas as modifica\u00e7\u00f5es neste arquivo ser\u00e3o perdidas ap\u00f3s a recompila\u00e7\u00e3o do esquema de origem. \nGerado em: {0} \n
-Driver.Version = xjc 2.2.12-b150126.1924
+Driver.Version = xjc 2.2.12-b150331.1824
-Driver.FullVersion = vers\u00E3o completa de xjc "2.2.12-b150126.1924"
+Driver.FullVersion = vers\u00E3o completa de xjc "2.2.12-b150331.1824"
-Driver.BuildID = 2.2.12-b150126.1924
+Driver.BuildID = 2.2.12-b150331.1824
# for JDK integration - include version in source zip
jaxb.jdk.version=@@JAXB_JDK_VERSION@@
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_zh_CN.properties Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_zh_CN.properties Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -96,14 +96,14 @@
Driver.FailedToGenerateCode = \u65e0\u6cd5\u751f\u6210\u4ee3\u7801\u3002
-# DO NOT localize the 2.2.12-b150126.1924 string - it is a token for an mvn <properties filter>
-Driver.FilePrologComment = \u6b64\u6587\u4ef6\u662f\u7531 JavaTM Architecture for XML Binding (JAXB) \u5f15\u7528\u5b9e\u73b0 v2.2.12-b150126.1924 \u751f\u6210\u7684\n\u8bf7\u8bbf\u95ee <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> \n\u5728\u91cd\u65b0\u7f16\u8bd1\u6e90\u6a21\u5f0f\u65f6, \u5bf9\u6b64\u6587\u4ef6\u7684\u6240\u6709\u4fee\u6539\u90fd\u5c06\u4e22\u5931\u3002\n\u751f\u6210\u65f6\u95f4: {0} \n
+# DO NOT localize the 2.2.12-b150331.1824 string - it is a token for an mvn <properties filter>
+Driver.FilePrologComment = \u6b64\u6587\u4ef6\u662f\u7531 JavaTM Architecture for XML Binding (JAXB) \u5f15\u7528\u5b9e\u73b0 v2.2.12-b150331.1824 \u751f\u6210\u7684\n\u8bf7\u8bbf\u95ee <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> \n\u5728\u91cd\u65b0\u7f16\u8bd1\u6e90\u6a21\u5f0f\u65f6, \u5bf9\u6b64\u6587\u4ef6\u7684\u6240\u6709\u4fee\u6539\u90fd\u5c06\u4e22\u5931\u3002\n\u751f\u6210\u65f6\u95f4: {0} \n
-Driver.Version = xjc 2.2.12-b150126.1924
+Driver.Version = xjc 2.2.12-b150331.1824
-Driver.FullVersion = xjc \u5B8C\u6574\u7248\u672C "2.2.12-b150126.1924"
+Driver.FullVersion = xjc \u5B8C\u6574\u7248\u672C "2.2.12-b150331.1824"
-Driver.BuildID = 2.2.12-b150126.1924
+Driver.BuildID = 2.2.12-b150331.1824
# for JDK integration - include version in source zip
jaxb.jdk.version=@@JAXB_JDK_VERSION@@
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_zh_TW.properties Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_zh_TW.properties Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -96,14 +96,14 @@
Driver.FailedToGenerateCode = \u7121\u6cd5\u7522\u751f\u7a0b\u5f0f\u78bc.
-# DO NOT localize the 2.2.12-b150126.1924 string - it is a token for an mvn <properties filter>
-Driver.FilePrologComment = \u6b64\u6a94\u6848\u662f\u7531 JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.12-b150126.1924 \u6240\u7522\u751f \n\u8acb\u53c3\u95b1 <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> \n\u4e00\u65e6\u91cd\u65b0\u7de8\u8b6f\u4f86\u6e90\u7db1\u8981, \u5c0d\u6b64\u6a94\u6848\u6240\u505a\u7684\u4efb\u4f55\u4fee\u6539\u90fd\u5c07\u6703\u907a\u5931. \n\u7522\u751f\u6642\u9593: {0} \n
+# DO NOT localize the 2.2.12-b150331.1824 string - it is a token for an mvn <properties filter>
+Driver.FilePrologComment = \u6b64\u6a94\u6848\u662f\u7531 JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.12-b150331.1824 \u6240\u7522\u751f \n\u8acb\u53c3\u95b1 <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> \n\u4e00\u65e6\u91cd\u65b0\u7de8\u8b6f\u4f86\u6e90\u7db1\u8981, \u5c0d\u6b64\u6a94\u6848\u6240\u505a\u7684\u4efb\u4f55\u4fee\u6539\u90fd\u5c07\u6703\u907a\u5931. \n\u7522\u751f\u6642\u9593: {0} \n
-Driver.Version = xjc 2.2.12-b150126.1924
+Driver.Version = xjc 2.2.12-b150331.1824
-Driver.FullVersion = xjc \u5B8C\u6574\u7248\u672C "2.2.12-b150126.1924"
+Driver.FullVersion = xjc \u5B8C\u6574\u7248\u672C "2.2.12-b150331.1824"
-Driver.BuildID = 2.2.12-b150126.1924
+Driver.BuildID = 2.2.12-b150331.1824
# for JDK integration - include version in source zip
jaxb.jdk.version=@@JAXB_JDK_VERSION@@
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/addon/code_injector/PluginImpl.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/addon/code_injector/PluginImpl.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,13 +25,15 @@
package com.sun.tools.internal.xjc.addon.code_injector;
+import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import com.sun.istack.internal.NotNull;
import com.sun.tools.internal.xjc.Options;
import com.sun.tools.internal.xjc.Plugin;
import com.sun.tools.internal.xjc.model.CPluginCustomization;
-import com.sun.tools.internal.xjc.outline.ClassOutline;
+import com.sun.tools.internal.xjc.outline.CustomizableOutline;
import com.sun.tools.internal.xjc.outline.Outline;
import com.sun.tools.internal.xjc.util.DOMUtils;
@@ -54,7 +56,7 @@
}
public boolean isCustomizationTagName(String nsUri, String localName) {
- return nsUri.equals(Const.NS) && localName.equals("code");
+ return Const.NS.equals(nsUri) && "code".equals(localName);
}
public String getUsage() {
@@ -62,9 +64,15 @@
}
// meat of the processing
- public boolean run(Outline model, Options opt, ErrorHandler errorHandler) {
- for( ClassOutline co : model.getClasses() ) {
- CPluginCustomization c = co.target.getCustomizations().find(Const.NS,"code");
+ public boolean run(@NotNull Outline model, Options opt, ErrorHandler errorHandler) {
+ checkAndInject(model.getClasses());
+ checkAndInject(model.getEnums());
+ return true;
+ }
+
+ private static void checkAndInject(Collection<? extends CustomizableOutline> outlines) {
+ for (CustomizableOutline co : outlines) {
+ CPluginCustomization c = co.getTarget().getCustomizations().find(Const.NS, "code");
if(c==null)
continue; // no customization --- nothing to inject here
@@ -74,9 +82,7 @@
String codeFragment = DOMUtils.getElementText(c.element);
// inject the specified code fragment into the implementation class.
- co.implClass.direct(codeFragment);
+ co.getImplClass().direct(codeFragment);
}
-
- return true;
}
}
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/outline/ClassOutline.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/outline/ClassOutline.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -33,6 +33,7 @@
import com.sun.codemodel.internal.JClass;
import com.sun.codemodel.internal.JDefinedClass;
import com.sun.tools.internal.xjc.model.CClassInfo;
+import com.sun.tools.internal.xjc.model.CCustomizable;
import com.sun.tools.internal.xjc.model.CPropertyInfo;
import com.sun.istack.internal.NotNull;
@@ -44,7 +45,7 @@
*
* @author Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
*/
-public abstract class ClassOutline {
+public abstract class ClassOutline implements CustomizableOutline {
/**
* A {@link Outline} that encloses all the class outlines.
@@ -122,4 +123,14 @@
if(s==null) return null;
return parent().getClazz(s);
}
+
+ @Override
+ public JDefinedClass getImplClass() {
+ return implClass;
+ }
+
+ @Override
+ public CCustomizable getTarget() {
+ return target;
+ }
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/outline/CustomizableOutline.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.internal.xjc.outline;
+
+import com.sun.codemodel.internal.JDefinedClass;
+import com.sun.istack.internal.NotNull;
+import com.sun.tools.internal.xjc.model.CCustomizable;
+
+/**
+ * This interface describes that outline class could be customized.
+ * It provides the bound info from {@link CCustomizable} target. And
+ * customization output - implementation class.
+ *
+ * @author yaroska
+ * @since 2.2.12
+ */
+public interface CustomizableOutline {
+
+ /**
+ * Provides bound information about customizable target.
+ * @return customizable target
+ */
+ @NotNull CCustomizable getTarget();
+
+ /**
+ * Provides customization output.
+ * @return Implementation class
+ */
+ @NotNull JDefinedClass getImplClass();
+}
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/outline/ElementOutline.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/outline/ElementOutline.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
package com.sun.tools.internal.xjc.outline;
import com.sun.codemodel.internal.JDefinedClass;
+import com.sun.tools.internal.xjc.model.CCustomizable;
import com.sun.tools.internal.xjc.model.CElementInfo;
/**
@@ -39,7 +40,7 @@
*
* @author Kohsuke Kawaguchi
*/
-public abstract class ElementOutline {
+public abstract class ElementOutline implements CustomizableOutline {
/**
* A {@link Outline} that encloses all the class outlines.
@@ -69,4 +70,14 @@
this.target = target;
this.implClass = implClass;
}
+
+ @Override
+ public CCustomizable getTarget() {
+ return target;
+ }
+
+ @Override
+ public JDefinedClass getImplClass() {
+ return implClass;
+ }
}
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/outline/EnumOutline.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/outline/EnumOutline.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,7 @@
import java.util.List;
import com.sun.codemodel.internal.JDefinedClass;
+import com.sun.tools.internal.xjc.model.CCustomizable;
import com.sun.tools.internal.xjc.model.CEnumLeafInfo;
import com.sun.istack.internal.NotNull;
@@ -40,7 +41,7 @@
*
* @author Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
*/
-public abstract class EnumOutline {
+public abstract class EnumOutline implements CustomizableOutline {
/**
* This {@link EnumOutline} holds information about this {@link CEnumLeafInfo}.
@@ -74,4 +75,14 @@
this.target = target;
this.clazz = clazz;
}
+
+ @Override
+ public JDefinedClass getImplClass() {
+ return clazz;
+ }
+
+ @Override
+ public CCustomizable getTarget() {
+ return target;
+ }
}
--- a/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/version.properties Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/version.properties Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
# questions.
#
-build-id=2.2.11-b150127.1410
-build-version=JAX-WS RI 2.2.11-b150127.1410
+build-id=2.2.11-b150402.1412
+build-version=JAX-WS RI 2.2.11-b150402.1412
major-version=2.2.11
-svn-revision=28121d09ed8ac02b76788709ccb4cdb66e03bbfa
+svn-revision=f923291dedcf386c5f408263984a99d7cedf0012
--- a/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wsdl/document/soap/SOAPConstants.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wsdl/document/soap/SOAPConstants.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
package com.sun.tools.internal.ws.wsdl.document.soap;
+import com.sun.xml.internal.ws.encoding.soap.streaming.SOAPNamespaceConstants;
+
import javax.xml.namespace.QName;
/**
@@ -35,9 +37,7 @@
public interface SOAPConstants {
// namespace URIs
- public static final String URI_ENVELOPE =
- "http://schemas.xmlsoap.org/soap/envelope/";
-
+ public static final String URI_ENVELOPE = SOAPNamespaceConstants.ENVELOPE;
public static final String NS_WSDL_SOAP =
"http://schemas.xmlsoap.org/wsdl/soap/";
public static final String NS_SOAP_ENCODING = "http://schemas.xmlsoap.org/soap/encoding/";
--- a/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wsdl/parser/Internalizer.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wsdl/parser/Internalizer.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -78,7 +78,7 @@
private static final ContextClassloaderLocal<XPathFactory> xpf = new ContextClassloaderLocal<XPathFactory>() {
@Override
protected XPathFactory initialValue() throws Exception {
- return XPathFactory.newInstance();
+ return XmlUtil.newXPathFactory(true);
}
};
/**
--- a/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wsdl/parser/JAXWSBindingExtensionHandler.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wsdl/parser/JAXWSBindingExtensionHandler.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,10 +25,10 @@
package com.sun.tools.internal.ws.wsdl.parser;
+import com.sun.tools.internal.ws.util.xml.XmlUtil;
import com.sun.tools.internal.ws.api.wsdl.TWSDLExtensible;
import com.sun.tools.internal.ws.api.wsdl.TWSDLExtension;
import com.sun.tools.internal.ws.api.wsdl.TWSDLParserContext;
-import com.sun.tools.internal.ws.util.xml.XmlUtil;
import com.sun.tools.internal.ws.wsdl.document.*;
import com.sun.tools.internal.ws.wsdl.document.jaxws.CustomName;
import com.sun.tools.internal.ws.wsdl.document.jaxws.JAXWSBinding;
@@ -57,7 +57,7 @@
private static final ContextClassloaderLocal<XPathFactory> xpf = new ContextClassloaderLocal<XPathFactory>() {
@Override
protected XPathFactory initialValue() throws Exception {
- return XPathFactory.newInstance();
+ return XmlUtil.newXPathFactory(false);
}
};
--- a/jdk/.hgtags Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/.hgtags Tue Apr 14 12:10:00 2015 -0700
@@ -300,3 +300,5 @@
d49e247dade61f29f771f09b2105857492241156 jdk9-b55
7969f7b6465e47ce4afa77670ca600b04c1d746c jdk9-b56
c76339e86ea7da5d9ac7856f3fae9ef73eef04a2 jdk9-b57
+36fc65e80d811ee43aedfc69284224b86a403662 jdk9-b58
+48ee960f29df93a9b2a895621321358a86909086 jdk9-b59
--- a/jdk/make/Makefile Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-#
-# Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation. Oracle designates this
-# particular file as subject to the "Classpath" exception as provided
-# by Oracle in the LICENSE file that accompanied this code.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# Locate this Makefile
-ifeq ($(filter /%, $(lastword $(MAKEFILE_LIST))), )
- makefile_path := $(CURDIR)/$(lastword $(MAKEFILE_LIST))
-else
- makefile_path := $(lastword $(MAKEFILE_LIST))
-endif
-repo_dir := $(patsubst %/make/Makefile, %, $(makefile_path))
-
-# What is the name of this subsystem (langtools, corba, etc)?
-subsystem_name := $(notdir $(repo_dir))
-
-# Try to locate top-level makefile
-top_level_makefile := $(repo_dir)/../Makefile
-ifneq ($(wildcard $(top_level_makefile)), )
- $(info Will run $(subsystem_name) target on top-level Makefile)
- $(info WARNING: This is a non-recommended way of building!)
- $(info ===================================================)
-else
- $(info Cannot locate top-level Makefile. Is this repo not checked out as part of a complete forest?)
- $(error Build from top-level Makefile instead)
-endif
-
-all:
- @$(MAKE) -f $(top_level_makefile) $(subsystem_name)
--- a/jdk/make/copy/Copy-java.base.gmk Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/make/copy/Copy-java.base.gmk Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -98,6 +98,8 @@
JVMCFG_SRC := $(JDK_TOPDIR)/src/java.base/macosx/conf/$(JVMCFG_ARCH)/jvm.cfg
else
JVMCFG_SRC := $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/conf/$(JVMCFG_ARCH)/jvm.cfg
+ # Allow override by ALT_JVMCFG_SRC if it exists
+ JVMCFG_SRC := $(if $(wildcard $(ALT_JVMCFG_SRC)),$(ALT_JVMCFG_SRC),$(JVMCFG_SRC))
endif
JVMCFG_DIR := $(LIB_DST_DIR)$(OPENJDK_TARGET_CPU_LIBDIR)
JVMCFG := $(JVMCFG_DIR)/jvm.cfg
--- a/jdk/make/data/tzdata/VERSION Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/make/data/tzdata/VERSION Tue Apr 14 12:10:00 2015 -0700
@@ -21,4 +21,4 @@
# or visit www.oracle.com if you need additional information or have any
# questions.
#
-tzdata2015a
+tzdata2015b
--- a/jdk/make/data/tzdata/asia Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/make/data/tzdata/asia Tue Apr 14 12:10:00 2015 -0700
@@ -1927,6 +1927,13 @@
# was at the start of 2008-03-31 (the day of Steffen Thorsen's report);
# this is almost surely wrong.
+# From Ganbold Tsagaankhuu (2015-03-10):
+# It seems like yesterday Mongolian Government meeting has concluded to use
+# daylight saving time in Mongolia.... Starting at 2:00AM of last Saturday of
+# March 2015, daylight saving time starts. And 00:00AM of last Saturday of
+# September daylight saving time ends. Source:
+# http://zasag.mn/news/view/8969
+
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Mongol 1983 1984 - Apr 1 0:00 1:00 S
Rule Mongol 1983 only - Oct 1 0:00 0 -
@@ -1947,6 +1954,8 @@
Rule Mongol 2001 only - Apr lastSat 2:00 1:00 S
Rule Mongol 2001 2006 - Sep lastSat 2:00 0 -
Rule Mongol 2002 2006 - Mar lastSat 2:00 1:00 S
+Rule Mongol 2015 max - Mar lastSat 2:00 1:00 S
+Rule Mongol 2015 max - Sep lastSat 0:00 0 -
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
# Hovd, a.k.a. Chovd, Dund-Us, Dzhargalant, Khovd, Jirgalanta
@@ -2365,13 +2374,19 @@
# official source...:
# http://www.palestinecabinet.gov.ps/ar/Views/ViewDetails.aspx?pid=1252
-# From Paul Eggert (2013-09-24):
-# For future dates, guess the last Thursday in March at 24:00 through
-# the first Friday on or after September 21 at 00:00. This is consistent with
-# the predictions in today's editions of the following URLs,
-# which are for Gaza and Hebron respectively:
-# http://www.timeanddate.com/worldclock/timezone.html?n=702
-# http://www.timeanddate.com/worldclock/timezone.html?n=2364
+# From Steffen Thorsen (2015-03-03):
+# Sources such as http://www.alquds.com/news/article/view/id/548257
+# and http://www.raya.ps/ar/news/890705.html say Palestine areas will
+# start DST on 2015-03-28 00:00 which is one day later than expected.
+#
+# From Paul Eggert (2015-03-03):
+# http://www.timeanddate.com/time/change/west-bank/ramallah?year=2014
+# says that the fall 2014 transition was Oct 23 at 24:00.
+# For future dates, guess the last Friday in March at 24:00 through
+# the first Friday on or after October 21 at 00:00. This is consistent with
+# the predictions in today's editions of the following URLs:
+# http://www.timeanddate.com/time/change/gaza-strip/gaza
+# http://www.timeanddate.com/time/change/west-bank/hebron
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule EgyptAsia 1957 only - May 10 0:00 1:00 S
@@ -2397,9 +2412,11 @@
Rule Palestine 2011 only - Aug 1 0:00 0 -
Rule Palestine 2011 only - Aug 30 0:00 1:00 S
Rule Palestine 2011 only - Sep 30 0:00 0 -
-Rule Palestine 2012 max - Mar lastThu 24:00 1:00 S
+Rule Palestine 2012 2014 - Mar lastThu 24:00 1:00 S
Rule Palestine 2012 only - Sep 21 1:00 0 -
-Rule Palestine 2013 max - Sep Fri>=21 0:00 0 -
+Rule Palestine 2013 only - Sep Fri>=21 0:00 0 -
+Rule Palestine 2014 max - Oct Fri>=21 0:00 0 -
+Rule Palestine 2015 max - Mar lastFri 24:00 1:00 S
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Asia/Gaza 2:17:52 - LMT 1900 Oct
--- a/jdk/make/data/tzdata/australasia Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/make/data/tzdata/australasia Tue Apr 14 12:10:00 2015 -0700
@@ -396,6 +396,7 @@
9:39:00 - LMT 1901 # Agana
10:00 - GST 2000 Dec 23 # Guam
10:00 - ChST # Chamorro Standard Time
+Link Pacific/Guam Pacific/Saipan # N Mariana Is
# Kiribati
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
@@ -411,12 +412,7 @@
14:00 - LINT
# N Mariana Is
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Pacific/Saipan -14:17:00 - LMT 1844 Dec 31
- 9:43:00 - LMT 1901
- 9:00 - MPT 1969 Oct # N Mariana Is Time
- 10:00 - MPT 2000 Dec 23
- 10:00 - ChST # Chamorro Standard Time
+# See Pacific/Guam.
# Marshall Is
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
@@ -586,6 +582,7 @@
-11:00 - NST 1967 Apr # N=Nome
-11:00 - BST 1983 Nov 30 # B=Bering
-11:00 - SST # S=Samoa
+Link Pacific/Pago_Pago Pacific/Midway # in US minor outlying islands
# Samoa (formerly and also known as Western Samoa)
@@ -767,23 +764,7 @@
# uninhabited
# Midway
-#
-# From Mark Brader (2005-01-23):
-# [Fallacies and Fantasies of Air Transport History, by R.E.G. Davies,
-# published 1994 by Paladwr Press, McLean, VA, USA; ISBN 0-9626483-5-3]
-# reproduced a Pan American Airways timetable from 1936, for their weekly
-# "Orient Express" flights between San Francisco and Manila, and connecting
-# flights to Chicago and the US East Coast. As it uses some time zone
-# designations that I've never seen before:....
-# Fri. 6:30A Lv. HONOLOLU (Pearl Harbor), H.I. H.L.T. Ar. 5:30P Sun.
-# " 3:00P Ar. MIDWAY ISLAND . . . . . . . . . M.L.T. Lv. 6:00A "
-#
-Zone Pacific/Midway -11:49:28 - LMT 1901
- -11:00 - NST 1956 Jun 3
- -11:00 1:00 NDT 1956 Sep 2
- -11:00 - NST 1967 Apr # N=Nome
- -11:00 - BST 1983 Nov 30 # B=Bering
- -11:00 - SST # S=Samoa
+# See Pacific/Pago_Pago.
# Palmyra
# uninhabited since World War II; was probably like Pacific/Kiritimati
--- a/jdk/make/data/tzdata/europe Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/make/data/tzdata/europe Tue Apr 14 12:10:00 2015 -0700
@@ -2423,7 +2423,7 @@
4:00 Russia VOL%sT 1989 Mar 26 2:00s # Volgograd T
3:00 Russia VOL%sT 1991 Mar 31 2:00s
4:00 - VOLT 1992 Mar 29 2:00s
- 3:00 Russia MSK 2011 Mar 27 2:00s
+ 3:00 Russia MSK/MSD 2011 Mar 27 2:00s
4:00 - MSK 2014 Oct 26 2:00s
3:00 - MSK
--- a/jdk/make/data/tzdata/northamerica Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/make/data/tzdata/northamerica Tue Apr 14 12:10:00 2015 -0700
@@ -2335,8 +2335,24 @@
# "...the new time zone will come into effect at two o'clock on the first Sunday
# of February, when we will have to advance the clock one hour from its current
# time..."
+# Also, the new zone will not use DST.
#
-# Also, the new zone will not use DST.
+# From Carlos Raúl Perasso (2015-02-02):
+# The decree that modifies the Mexican Hour System Law has finally
+# been published at the Diario Oficial de la Federación
+# http://www.dof.gob.mx/nota_detalle.php?codigo=5380123&fecha=31/01/2015
+# It establishes 5 zones for Mexico:
+# 1- Zona Centro (Central Zone): Corresponds to longitude 90 W,
+# includes most of Mexico, excluding what's mentioned below.
+# 2- Zona PacÃfico (Pacific Zone): Longitude 105 W, includes the
+# states of Baja California Sur; Chihuahua; Nayarit (excluding BahÃa
+# de Banderas which lies in Central Zone); Sinaloa and Sonora.
+# 3- Zona Noroeste (Northwest Zone): Longitude 120 W, includes the
+# state of Baja California.
+# 4- Zona Sureste (Southeast Zone): Longitude 75 W, includes the state
+# of Quintana Roo.
+# 5- The islands, reefs and keys shall take their timezone from the
+# longitude they are located at.
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Mexico 1939 only - Feb 5 0:00 1:00 D
@@ -2531,14 +2547,9 @@
###############################################################################
# Anguilla
+# Antigua and Barbuda
# See America/Port_of_Spain.
-# Antigua and Barbuda
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone America/Antigua -4:07:12 - LMT 1912 Mar 2
- -5:00 - EST 1951
- -4:00 - AST
-
# Bahamas
#
# For 1899 Milne gives -5:09:29.5; round that.
@@ -2604,10 +2615,7 @@
-4:00 US A%sT
# Cayman Is
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone America/Cayman -5:25:32 - LMT 1890 # Georgetown
- -5:07:11 - KMT 1912 Feb # Kingston Mean Time
- -5:00 - EST
+# See America/Panama.
# Costa Rica
@@ -3130,6 +3138,7 @@
Zone America/Panama -5:18:08 - LMT 1890
-5:19:36 - CMT 1908 Apr 22 # Colón Mean Time
-5:00 - EST
+Link America/Panama America/Cayman
# Puerto Rico
# There are too many San Juans elsewhere, so we'll use 'Puerto_Rico'.
--- a/jdk/make/data/tzdata/southamerica Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/make/data/tzdata/southamerica Tue Apr 14 12:10:00 2015 -0700
@@ -1229,10 +1229,13 @@
# DST Start: first Saturday of September 2014 (Sun 07 Sep 2014 04:00 UTC)
# http://www.diariooficial.interior.gob.cl//media/2014/02/19/do-20140219.pdf
-# From Juan Correa (2015-01-28):
-# ... today the Ministry of Energy announced that Chile will drop DST, will keep
-# "summer time" (UTC -3 / UTC -5) all year round....
-# http://www.minenergia.cl/ministerio/noticias/generales/ministerio-de-energia-anuncia.html
+# From Eduardo Romero Urra (2015-03-03):
+# Today has been published officially that Chile will use the DST time
+# permanently until March 25 of 2017
+# http://www.diariooficial.interior.gob.cl/media/2015/03/03/1-large.jpg
+#
+# From Paul Eggert (2015-03-03):
+# For now, assume that the extension will persist indefinitely.
# NOTE: ChileAQ rules for Antarctic bases are stored separately in the
# 'antarctica' file.
@@ -1291,7 +1294,7 @@
-3:00 - CLT
Zone Pacific/Easter -7:17:44 - LMT 1890
-7:17:28 - EMT 1932 Sep # Easter Mean Time
- -7:00 Chile EAS%sT 1982 Mar 13 3:00u # Easter Time
+ -7:00 Chile EAS%sT 1982 Mar 14 3:00u # Easter Time
-6:00 Chile EAS%sT 2015 Apr 26 3:00u
-5:00 - EAST
#
@@ -1626,6 +1629,7 @@
# These all agree with Trinidad and Tobago since 1970.
Link America/Port_of_Spain America/Anguilla
+Link America/Port_of_Spain America/Antigua
Link America/Port_of_Spain America/Dominica
Link America/Port_of_Spain America/Grenada
Link America/Port_of_Spain America/Guadeloupe
--- a/jdk/make/lib/Awt2dLibraries.gmk Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/make/lib/Awt2dLibraries.gmk Tue Apr 14 12:10:00 2015 -0700
@@ -236,10 +236,6 @@
LIBAWT_VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/java.desktop/windows/native/libawt/windows/awt.rc
endif
-ifeq ($(MILESTONE), internal)
- LIBAWT_CFLAGS += -DINTERNAL_BUILD
-endif
-
LIBAWT_MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libawt/mapfile-vers
ifeq ($(OPENJDK_TARGET_OS), linux)
LIBAWT_MAPFILE :=
@@ -347,10 +343,6 @@
endif
endif
- ifeq ($(MILESTONE), internal)
- LIBAWT_XAWT_CFLAGS += -DINTERNAL_BUILD
- endif
-
LIBAWT_XAWT_LDFLAGS_SUFFIX := $(LIBM) -lawt -lXext -lX11 -lXrender $(LIBDL) -lXtst -lXi -ljava -ljvm -lc
ifeq ($(OPENJDK_TARGET_OS), linux)
--- a/jdk/make/lib/CoreLibraries.gmk Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/make/lib/CoreLibraries.gmk Tue Apr 14 12:10:00 2015 -0700
@@ -269,7 +269,7 @@
LIBJLI_EXCLUDE_FILES += $(notdir $(LIBJLI_EXCLUDE_ERGO))
ifeq ($(OPENJDK_TARGET_OS), macosx)
- LIBJLI_EXCLUDE_FILES += java_md_solinux.c ergo.c
+ LIBJLI_EXCLUDE_FILES += java_md_solinux.c ergo.c ergo_i586.c
BUILD_LIBJLI_java_md_macosx.c_CFLAGS := -x objective-c
BUILD_LIBJLI_STATIC_java_md_macosx.c_CFLAGS := -x objective-c
@@ -317,12 +317,7 @@
LANG := C, \
OPTIMIZATION := HIGH, \
CFLAGS := $(LIBJLI_CFLAGS), \
- DISABLED_WARNINGS_gcc := pointer-to-int-cast sign-compare format-nonliteral \
- parentheses, \
- DISABLED_WARNINGS_clang := implicit-function-declaration parentheses \
- int-conversion, \
- DISABLED_WARNINGS_solstudio := E_ASM_DISABLES_OPTIMIZATION E_NEWLINE_NOT_LAST, \
- DISABLED_WARNINGS_microsoft := 4244 4047 4267, \
+ DISABLED_WARNINGS_solstudio := E_ASM_DISABLES_OPTIMIZATION, \
MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjli/mapfile-vers, \
LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
@@ -371,7 +366,6 @@
LANG := C, \
OPTIMIZATION := HIGH, \
CFLAGS := $(STATIC_LIBRARY_FLAGS) $(LIBJLI_CFLAGS), \
- DISABLED_WARNINGS_microsoft := 4244 4047 4267, \
ARFLAGS := $(ARFLAGS), \
OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjli_static, \
DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES)))
@@ -392,8 +386,6 @@
LANG := C, \
OPTIMIZATION := HIGH, \
CFLAGS := $(CFLAGS_JDKLIB) $(LIBJLI_CFLAGS), \
- DISABLED_WARNINGS_clang := implicit-function-declaration parentheses \
- int-conversion, \
LDFLAGS := -nostdlib -r, \
OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjli_static, \
DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES)))
--- a/jdk/make/lib/Lib-java.management.gmk Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/make/lib/Lib-java.management.gmk Tue Apr 14 12:10:00 2015 -0700
@@ -38,6 +38,11 @@
$(LIBJAVA_HEADER_FLAGS) \
#
+# In (at least) VS2013 and later, -DPSAPI_VERSION=1 is needed to generate
+# a binary that is compatible with windows versions older than 7/2008R2.
+# See MSDN documentation for GetProcessMemoryInfo for more information.
+BUILD_LIBMANAGEMENT_CFLAGS += -DPSAPI_VERSION=1
+
BUILD_LIBMANAGEMENT_EXCLUDES :=
ifneq ($(OPENJDK_TARGET_OS), solaris)
--- a/jdk/make/mapfiles/libjava/reorder-sparc Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/make/mapfiles/libjava/reorder-sparc Tue Apr 14 12:10:00 2015 -0700
@@ -1,7 +1,6 @@
data = R0x2000;
text = LOAD ?RXO;
# Test Null
-text: .text%init64IO: OUTPUTDIR/UnixFileSystem_md.o;
text: .text%JNI_OnLoad;
text: .text%Canonicalize;
text: .text%canonicalize;
@@ -38,10 +37,9 @@
text: .text%Java_java_lang_System_identityHashCode;
text: .text%Java_sun_misc_Signal_findSignal;
text: .text%Java_sun_misc_Signal_handle0;
-text: .text%Java_java_io_FileSystem_getFileSystem;
text: .text%JNU_NewObjectByName;
text: .text%Java_java_io_UnixFileSystem_initIDs;
-text: .text%Java_java_io_UnixFileSystem_canonicalize;
+text: .text%Java_java_io_UnixFileSystem_canonicalize0;
text: .text%JNU_GetStringPlatformChars;
text: .text%JNU_ReleaseStringPlatformChars;
text: .text%Java_java_io_FileInputStream_open0;
@@ -52,27 +50,25 @@
text: .text%Java_java_io_FileInputStream_close0;
text: .text%Java_java_lang_System_mapLibraryName;
text: .text%Java_java_io_UnixFileSystem_getBooleanAttributes0;
-text: .text%statMode: OUTPUTDIR/UnixFileSystem_md.o;
text: .text%Java_java_lang_ClassLoader_00024NativeLibrary_load;
-text: .text%Java_java_lang_Compiler_registerNatives;
text: .text%Java_java_lang_ClassLoader_00024NativeLibrary_find;
text: .text%Java_java_security_AccessController_doPrivileged__Ljava_security_PrivilegedExceptionAction_2;
text: .text%Java_java_io_UnixFileSystem_list;
text: .text%JNU_ClassString;
text: .text%JNU_CopyObjectArray;
text: .text%Java_java_lang_String_intern;
-text: .text%Java_java_lang_ClassLoader_findLoadedClass;
+text: .text%Java_java_lang_ClassLoader_findLoadedClass0;
text: .text%Java_java_lang_ClassLoader_findBootstrapClass;
text: .text%Java_java_lang_Throwable_fillInStackTrace;
text: .text%Java_java_security_AccessController_doPrivileged__Ljava_security_PrivilegedExceptionAction_2Ljava_security_AccessControlContext_2;
text: .text%Java_java_io_UnixFileSystem_getLastModifiedTime;
-text: .text%Java_java_lang_Float_floatToIntBits;
-text: .text%Java_java_lang_Double_doubleToLongBits;
+text: .text%Java_java_lang_Float_floatToRawIntBits;
+text: .text%Java_java_lang_Double_doubleToRawLongBits;
text: .text%Java_java_io_UnixFileSystem_getLength;
text: .text%Java_java_lang_ClassLoader_defineClass0;
text: .text%VerifyClassCodes;
# Test Exit
-text: .text%Java_java_lang_Shutdown_halt;
+text: .text%Java_java_lang_Shutdown_halt0;
# Test Hello
text: .text%Java_java_io_FileOutputStream_writeBytes;
text: .text%writeBytes;
@@ -91,9 +87,7 @@
text: .text%JNU_CallMethodByName;
text: .text%JNU_CallMethodByNameV;
text: .text%Java_java_io_UnixFileSystem_createDirectory;
-text: .text%Java_java_util_prefs_FileSystemPreferences_lockFile0;
text: .text%Java_java_io_UnixFileSystem_setLastModifiedTime;
-text: .text%Java_java_util_prefs_FileSystemPreferences_unlockFile0;
# Test LoadJFrame
text: .text%Java_sun_reflect_NativeMethodAccessorImpl_invoke0;
text: .text%Java_java_lang_Class_isInstance;
--- a/jdk/make/mapfiles/libjava/reorder-sparcv9 Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/make/mapfiles/libjava/reorder-sparcv9 Tue Apr 14 12:10:00 2015 -0700
@@ -1,7 +1,6 @@
data = R0x2000;
text = LOAD ?RXO;
# Test Null
-text: .text%init64IO: OUTPUTDIR/UnixFileSystem_md.o;
text: .text%JNI_OnLoad;
text: .text%Canonicalize;
text: .text%canonicalize;
@@ -30,9 +29,9 @@
text: .text%Java_sun_reflect_Reflection_getCallerClass__I;
text: .text%Java_java_lang_Class_forName0;
text: .text%Java_java_lang_String_intern;
-text: .text%Java_java_lang_Float_floatToIntBits;
-text: .text%Java_java_lang_Double_doubleToLongBits;
-text: .text%Java_java_lang_ClassLoader_findLoadedClass;
+text: .text%Java_java_lang_Float_floatToRawIntBits;
+text: .text%Java_java_lang_Double_doubleToRawLongBits;
+text: .text%Java_java_lang_ClassLoader_findLoadedClass0;
text: .text%Java_java_lang_ClassLoader_findBootstrapClass;
text: .text%VerifyClassCodes;
text: .text%Java_java_lang_Throwable_fillInStackTrace;
@@ -41,10 +40,9 @@
text: .text%Java_java_lang_System_identityHashCode;
text: .text%Java_sun_misc_Signal_findSignal;
text: .text%Java_sun_misc_Signal_handle0;
-text: .text%Java_java_io_FileSystem_getFileSystem;
text: .text%JNU_NewObjectByName;
text: .text%Java_java_io_UnixFileSystem_initIDs;
-text: .text%Java_java_io_UnixFileSystem_canonicalize;
+text: .text%Java_java_io_UnixFileSystem_canonicalize0;
text: .text%JNU_GetStringPlatformChars;
text: .text%JNU_ReleaseStringPlatformChars;
text: .text%Java_java_io_FileInputStream_open0;
@@ -53,13 +51,11 @@
text: .text%readBytes;
text: .text%Java_java_io_FileInputStream_available;
text: .text%Java_java_io_FileInputStream_close0;
-text: .text%Java_java_lang_Compiler_registerNatives;
text: .text%Java_java_security_AccessController_doPrivileged__Ljava_security_PrivilegedExceptionAction_2;
text: .text%Java_java_io_UnixFileSystem_list;
text: .text%JNU_ClassString;
text: .text%JNU_CopyObjectArray;
text: .text%Java_java_io_UnixFileSystem_getBooleanAttributes0;
-text: .text%statMode: OUTPUTDIR/UnixFileSystem_md.o;
text: .text%Java_java_security_AccessController_doPrivileged__Ljava_security_PrivilegedExceptionAction_2Ljava_security_AccessControlContext_2;
text: .text%Java_java_lang_System_mapLibraryName;
text: .text%Java_java_lang_ClassLoader_00024NativeLibrary_load;
@@ -68,7 +64,7 @@
text: .text%Java_java_lang_Object_getClass;
text: .text%Java_java_lang_ClassLoader_defineClass0;
# Test Exit
-text: .text%Java_java_lang_Shutdown_halt;
+text: .text%Java_java_lang_Shutdown_halt0;
# Test Hello
text: .text%Java_java_io_FileOutputStream_writeBytes;
text: .text%writeBytes;
@@ -88,9 +84,7 @@
text: .text%JNU_CallMethodByNameV;
text: .text%Java_java_io_UnixFileSystem_createDirectory;
text: .text%Java_java_io_UnixFileSystem_getLastModifiedTime;
-text: .text%Java_java_util_prefs_FileSystemPreferences_lockFile0;
text: .text%Java_java_io_UnixFileSystem_setLastModifiedTime;
-text: .text%Java_java_util_prefs_FileSystemPreferences_unlockFile0;
# Test LoadJFrame
text: .text%Java_java_lang_Class_isAssignableFrom;
text: .text%Java_java_lang_Class_isInstance;
--- a/jdk/make/mapfiles/libjava/reorder-x86 Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/make/mapfiles/libjava/reorder-x86 Tue Apr 14 12:10:00 2015 -0700
@@ -2,7 +2,6 @@
text = LOAD ?RXO;
# Test Null
text: .text%_init;
-text: .text%init64IO: OUTPUTDIR/UnixFileSystem_md.o;
text: .text%JNI_OnLoad;
text: .text%Canonicalize;
text: .text%canonicalize;
@@ -36,8 +35,6 @@
text: .text%Java_java_lang_Throwable_fillInStackTrace;
text: .text%Java_java_lang_System_setOut0;
text: .text%Java_java_lang_System_setErr0;
-text: .text%Java_java_lang_Compiler_registerNatives;
-text: .text%Java_java_io_FileSystem_getFileSystem;
text: .text%JNU_NewObjectByName;
text: .text%Java_java_io_UnixFileSystem_initIDs;
text: .text%Java_java_security_AccessController_doPrivileged__Ljava_security_PrivilegedExceptionAction_2;
@@ -46,17 +43,17 @@
text: .text%JNU_ReleaseStringPlatformChars;
text: .text%JNU_ClassString;
text: .text%JNU_CopyObjectArray;
-text: .text%Java_java_io_UnixFileSystem_canonicalize;
+text: .text%Java_java_io_UnixFileSystem_canonicalize0;
text: .text%Java_java_io_UnixFileSystem_getBooleanAttributes0;
-text: .text%Java_java_lang_ClassLoader_findLoadedClass;
+text: .text%Java_java_lang_ClassLoader_findLoadedClass0;
text: .text%Java_java_lang_ClassLoader_findBootstrapClass;
text: .text%Java_java_security_AccessController_doPrivileged__Ljava_security_PrivilegedExceptionAction_2Ljava_security_AccessControlContext_2;
text: .text%Java_java_lang_System_mapLibraryName;
text: .text%cpchars: OUTPUTDIR/System.o;
text: .text%Java_java_lang_ClassLoader_00024NativeLibrary_load;
text: .text%Java_java_lang_ClassLoader_00024NativeLibrary_find;
-text: .text%Java_java_lang_Float_floatToIntBits;
-text: .text%Java_java_lang_Double_doubleToLongBits;
+text: .text%Java_java_lang_Float_floatToRawIntBits;
+text: .text%Java_java_lang_Double_doubleToRawLongBits;
text: .text%Java_java_io_FileInputStream_open0;
text: .text%fileOpen;
text: .text%Java_java_io_UnixFileSystem_getLength;
@@ -67,7 +64,7 @@
text: .text%Java_java_lang_ClassLoader_defineClass0;
text: .text%VerifyClassCodes;
# Test Exit
-text: .text%Java_java_lang_Shutdown_halt;
+text: .text%Java_java_lang_Shutdown_halt0;
# Test Hello
text: .text%Java_java_io_FileOutputStream_writeBytes;
text: .text%writeBytes;
@@ -93,9 +90,7 @@
text: .text%Java_java_io_FileOutputStream_open0;
text: .text%Java_java_io_UnixFileSystem_createDirectory;
text: .text%Java_java_io_UnixFileSystem_getLastModifiedTime;
-text: .text%Java_java_util_prefs_FileSystemPreferences_lockFile0;
text: .text%Java_java_io_UnixFileSystem_setLastModifiedTime;
-text: .text%Java_java_util_prefs_FileSystemPreferences_unlockFile0;
text: .text%Java_java_io_FileOutputStream_close0;
text: .text%Java_java_util_logging_FileHandler_unlockFile;
# Test LoadJFrame
--- a/jdk/make/mapfiles/libzip/reorder-sparcv9 Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/make/mapfiles/libzip/reorder-sparcv9 Tue Apr 14 12:10:00 2015 -0700
@@ -12,7 +12,6 @@
text: .text%ZIP_FindEntry;
text: .text%ZIP_GetEntry;
text: .text%ZIP_Lock;
-text: .text%readLOC: OUTPUTDIR/zip_util.o;
text: .text%ZIP_Unlock;
text: .text%ZIP_FreeEntry;
text: .text%Java_java_util_zip_ZipFile_initIDs;
@@ -37,7 +36,6 @@
text: .text%inflate;
text: .text%Java_java_util_zip_ZipFile_read;
text: .text%ZIP_Read;
-text: .text%huft_build: OUTPUTDIR/inftrees.o;
text: .text%zcfree;
text: .text%Java_java_util_jar_JarFile_getMetaInfEntryNames;
text: .text%ZIP_ReadEntry;
--- a/jdk/make/mapfiles/libzip/reorder-x86 Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/make/mapfiles/libzip/reorder-x86 Tue Apr 14 12:10:00 2015 -0700
@@ -13,7 +13,6 @@
text: .text%ZIP_FindEntry;
text: .text%ZIP_GetEntry;
text: .text%ZIP_Lock;
-text: .text%readLOC: OUTPUTDIR/zip_util.o;
text: .text%ZIP_Unlock;
text: .text%ZIP_FreeEntry;
text: .text%Java_java_util_zip_ZipFile_initIDs;
@@ -38,7 +37,6 @@
text: .text%inflate;
text: .text%Java_java_util_zip_ZipFile_read;
text: .text%ZIP_Read;
-text: .text%huft_build: OUTPUTDIR/inftrees.o;
text: .text%zcfree;
text: .text%Java_java_util_jar_JarFile_getMetaInfEntryNames;
text: .text%ZIP_ReadEntry;
--- a/jdk/src/java.base/macosx/native/libjli/java_md_macosx.c Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.base/macosx/native/libjli/java_md_macosx.c Tue Apr 14 12:10:00 2015 -0700
@@ -852,7 +852,7 @@
if (pthread_create(&tid, &attr, (void *(*)(void*))continuation, (void*)args) == 0) {
void * tmp;
pthread_join(tid, &tmp);
- rslt = (int)tmp;
+ rslt = (int)(intptr_t)tmp;
} else {
/*
* Continue execution in current thread if for some reason (e.g. out of
--- a/jdk/src/java.base/share/classes/java/io/ObjectStreamException.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.base/share/classes/java/io/ObjectStreamException.java Tue Apr 14 12:10:00 2015 -0700
@@ -38,10 +38,10 @@
/**
* Create an ObjectStreamException with the specified argument.
*
- * @param classname the detailed message for the exception
+ * @param message the detailed message for the exception
*/
- protected ObjectStreamException(String classname) {
- super(classname);
+ protected ObjectStreamException(String message) {
+ super(message);
}
/**
--- a/jdk/src/java.base/share/classes/java/net/ProtocolException.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.base/share/classes/java/net/ProtocolException.java Tue Apr 14 12:10:00 2015 -0700
@@ -42,10 +42,10 @@
* Constructs a new {@code ProtocolException} with the
* specified detail message.
*
- * @param host the detail message.
+ * @param message the detail message.
*/
- public ProtocolException(String host) {
- super(host);
+ public ProtocolException(String message) {
+ super(message);
}
/**
--- a/jdk/src/java.base/share/classes/java/net/UnknownHostException.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.base/share/classes/java/net/UnknownHostException.java Tue Apr 14 12:10:00 2015 -0700
@@ -41,10 +41,10 @@
* Constructs a new {@code UnknownHostException} with the
* specified detail message.
*
- * @param host the detail message.
+ * @param message the detail message.
*/
- public UnknownHostException(String host) {
- super(host);
+ public UnknownHostException(String message) {
+ super(message);
}
/**
--- a/jdk/src/java.base/share/classes/java/time/chrono/HijrahChronology.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.base/share/classes/java/time/chrono/HijrahChronology.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -478,7 +478,6 @@
if (prolepticYear < getMinimumYear() || prolepticYear > getMaximumYear()) {
return false;
}
- int epochMonth = yearToEpochMonth((int) prolepticYear);
int len = getYearLength((int) prolepticYear);
return (len > 354);
}
@@ -659,7 +658,7 @@
}
/**
- * Return the maximum supported Hijrah ear.
+ * Return the maximum supported Hijrah year.
*
* @return the minimum
*/
--- a/jdk/src/java.base/share/classes/java/util/BitSet.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.base/share/classes/java/util/BitSet.java Tue Apr 14 12:10:00 2015 -0700
@@ -1229,7 +1229,7 @@
public int nextInt() {
if (next != -1) {
int ret = next;
- next = nextSetBit(next+1);
+ next = (next == Integer.MAX_VALUE) ? -1 : nextSetBit(next+1);
return ret;
} else {
throw new NoSuchElementException();
--- a/jdk/src/java.base/share/classes/java/util/Calendar.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.base/share/classes/java/util/Calendar.java Tue Apr 14 12:10:00 2015 -0700
@@ -2083,17 +2083,33 @@
return null;
}
+ String calendarType = getCalendarType();
+ int fieldValue = get(field);
// the standalone and narrow styles are supported only through CalendarDataProviders.
- if (isStandaloneStyle(style) || isNarrowStyle(style)) {
- return CalendarDataUtility.retrieveFieldValueName(getCalendarType(),
- field, get(field),
- style, locale);
+ if (isStandaloneStyle(style) || isNarrowFormatStyle(style)) {
+ String val = CalendarDataUtility.retrieveFieldValueName(calendarType,
+ field, fieldValue,
+ style, locale);
+ // Perform fallback here to follow the CLDR rules
+ if (val == null) {
+ if (isNarrowFormatStyle(style)) {
+ val = CalendarDataUtility.retrieveFieldValueName(calendarType,
+ field, fieldValue,
+ toStandaloneStyle(style),
+ locale);
+ } else if (isStandaloneStyle(style)) {
+ val = CalendarDataUtility.retrieveFieldValueName(calendarType,
+ field, fieldValue,
+ getBaseStyle(style),
+ locale);
+ }
+ }
+ return val;
}
DateFormatSymbols symbols = DateFormatSymbols.getInstance(locale);
String[] strings = getFieldStrings(field, style, symbols);
if (strings != null) {
- int fieldValue = get(field);
if (fieldValue < strings.length) {
return strings[fieldValue];
}
@@ -2155,10 +2171,26 @@
ERA_MASK|MONTH_MASK|DAY_OF_WEEK_MASK|AM_PM_MASK)) {
return null;
}
- if (style == ALL_STYLES || isStandaloneStyle(style)) {
- return CalendarDataUtility.retrieveFieldValueNames(getCalendarType(), field, style, locale);
+
+ String calendarType = getCalendarType();
+ if (style == ALL_STYLES || isStandaloneStyle(style) || isNarrowFormatStyle(style)) {
+ Map<String, Integer> map;
+ map = CalendarDataUtility.retrieveFieldValueNames(calendarType, field, style, locale);
+
+ // Perform fallback here to follow the CLDR rules
+ if (map == null) {
+ if (isNarrowFormatStyle(style)) {
+ map = CalendarDataUtility.retrieveFieldValueNames(calendarType, field,
+ toStandaloneStyle(style), locale);
+ } else if (style != ALL_STYLES) {
+ map = CalendarDataUtility.retrieveFieldValueNames(calendarType, field,
+ getBaseStyle(style), locale);
+ }
+ }
+ return map;
}
- // SHORT, LONG, or NARROW
+
+ // SHORT or LONG
return getDisplayNamesImpl(field, style, locale);
}
@@ -2544,14 +2576,22 @@
return style & ~STANDALONE_MASK;
}
- boolean isStandaloneStyle(int style) {
+ private int toStandaloneStyle(int style) {
+ return style | STANDALONE_MASK;
+ }
+
+ private boolean isStandaloneStyle(int style) {
return (style & STANDALONE_MASK) != 0;
}
- boolean isNarrowStyle(int style) {
+ private boolean isNarrowStyle(int style) {
return style == NARROW_FORMAT || style == NARROW_STANDALONE;
}
+ private boolean isNarrowFormatStyle(int style) {
+ return style == NARROW_FORMAT;
+ }
+
/**
* Returns the pseudo-time-stamp for two fields, given their
* individual pseudo-time-stamps. If either of the fields
--- a/jdk/src/java.base/share/classes/java/util/HashMap.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.base/share/classes/java/util/HashMap.java Tue Apr 14 12:10:00 2015 -0700
@@ -1082,6 +1082,16 @@
return null;
}
+ /**
+ * {@inheritDoc}
+ *
+ * <p>This method will, on a best-effort basis, throw a
+ * {@link ConcurrentModificationException} if it is detected that the
+ * mapping function modifies this map during computation.
+ *
+ * @throws ConcurrentModificationException if it is detected that the
+ * mapping function modified this map
+ */
@Override
public V computeIfAbsent(K key,
Function<? super K, ? extends V> mappingFunction) {
@@ -1115,7 +1125,9 @@
return oldValue;
}
}
+ int mc = modCount;
V v = mappingFunction.apply(key);
+ if (mc != modCount) { throw new ConcurrentModificationException(); }
if (v == null) {
return null;
} else if (old != null) {
@@ -1130,12 +1142,23 @@
if (binCount >= TREEIFY_THRESHOLD - 1)
treeifyBin(tab, hash);
}
- ++modCount;
+ modCount = mc + 1;
++size;
afterNodeInsertion(true);
return v;
}
+ /**
+ * {@inheritDoc}
+ *
+ * <p>This method will, on a best-effort basis, throw a
+ * {@link ConcurrentModificationException} if it is detected that the
+ * remapping function modifies this map during computation.
+ *
+ * @throws ConcurrentModificationException if it is detected that the
+ * remapping function modified this map
+ */
+ @Override
public V computeIfPresent(K key,
BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
if (remappingFunction == null)
@@ -1144,7 +1167,9 @@
int hash = hash(key);
if ((e = getNode(hash, key)) != null &&
(oldValue = e.value) != null) {
+ int mc = modCount;
V v = remappingFunction.apply(key, oldValue);
+ if (mc != modCount) { throw new ConcurrentModificationException(); }
if (v != null) {
e.value = v;
afterNodeAccess(e);
@@ -1156,6 +1181,16 @@
return null;
}
+ /**
+ * {@inheritDoc}
+ *
+ * <p>This method will, on a best-effort basis, throw a
+ * {@link ConcurrentModificationException} if it is detected that the
+ * remapping function modifies this map during computation.
+ *
+ * @throws ConcurrentModificationException if it is detected that the
+ * remapping function modified this map
+ */
@Override
public V compute(K key,
BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
@@ -1185,7 +1220,9 @@
}
}
V oldValue = (old == null) ? null : old.value;
+ int mc = modCount;
V v = remappingFunction.apply(key, oldValue);
+ if (mc != modCount) { throw new ConcurrentModificationException(); }
if (old != null) {
if (v != null) {
old.value = v;
@@ -1202,13 +1239,23 @@
if (binCount >= TREEIFY_THRESHOLD - 1)
treeifyBin(tab, hash);
}
- ++modCount;
+ modCount = mc + 1;
++size;
afterNodeInsertion(true);
}
return v;
}
+ /**
+ * {@inheritDoc}
+ *
+ * <p>This method will, on a best-effort basis, throw a
+ * {@link ConcurrentModificationException} if it is detected that the
+ * remapping function modifies this map during computation.
+ *
+ * @throws ConcurrentModificationException if it is detected that the
+ * remapping function modified this map
+ */
@Override
public V merge(K key, V value,
BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
@@ -1241,10 +1288,15 @@
}
if (old != null) {
V v;
- if (old.value != null)
+ if (old.value != null) {
+ int mc = modCount;
v = remappingFunction.apply(old.value, value);
- else
+ if (mc != modCount) {
+ throw new ConcurrentModificationException();
+ }
+ } else {
v = value;
+ }
if (v != null) {
old.value = v;
afterNodeAccess(old);
--- a/jdk/src/java.base/share/classes/java/util/Hashtable.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.base/share/classes/java/util/Hashtable.java Tue Apr 14 12:10:00 2015 -0700
@@ -1000,6 +1000,16 @@
return null;
}
+ /**
+ * {@inheritDoc}
+ *
+ * <p>This method will, on a best-effort basis, throw a
+ * {@link java.util.ConcurrentModificationException} if the mapping
+ * function modified this map during computation.
+ *
+ * @throws ConcurrentModificationException if it is detected that the
+ * mapping function modified this map
+ */
@Override
public synchronized V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -1016,7 +1026,9 @@
}
}
+ int mc = modCount;
V newValue = mappingFunction.apply(key);
+ if (mc != modCount) { throw new ConcurrentModificationException(); }
if (newValue != null) {
addEntry(hash, key, newValue, index);
}
@@ -1024,6 +1036,16 @@
return newValue;
}
+ /**
+ * {@inheritDoc}
+ *
+ * <p>This method will, on a best-effort basis, throw a
+ * {@link java.util.ConcurrentModificationException} if the remapping
+ * function modified this map during computation.
+ *
+ * @throws ConcurrentModificationException if it is detected that the
+ * remapping function modified this map
+ */
@Override
public synchronized V computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
Objects.requireNonNull(remappingFunction);
@@ -1035,14 +1057,18 @@
Entry<K,V> e = (Entry<K,V>)tab[index];
for (Entry<K,V> prev = null; e != null; prev = e, e = e.next) {
if (e.hash == hash && e.key.equals(key)) {
+ int mc = modCount;
V newValue = remappingFunction.apply(key, e.value);
+ if (mc != modCount) {
+ throw new ConcurrentModificationException();
+ }
if (newValue == null) {
if (prev != null) {
prev.next = e.next;
} else {
tab[index] = e.next;
}
- modCount++;
+ modCount = mc + 1;
count--;
} else {
e.value = newValue;
@@ -1052,7 +1078,16 @@
}
return null;
}
-
+ /**
+ * {@inheritDoc}
+ *
+ * <p>This method will, on a best-effort basis, throw a
+ * {@link java.util.ConcurrentModificationException} if the remapping
+ * function modified this map during computation.
+ *
+ * @throws ConcurrentModificationException if it is detected that the
+ * remapping function modified this map
+ */
@Override
public synchronized V compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
Objects.requireNonNull(remappingFunction);
@@ -1064,14 +1099,18 @@
Entry<K,V> e = (Entry<K,V>)tab[index];
for (Entry<K,V> prev = null; e != null; prev = e, e = e.next) {
if (e.hash == hash && Objects.equals(e.key, key)) {
+ int mc = modCount;
V newValue = remappingFunction.apply(key, e.value);
+ if (mc != modCount) {
+ throw new ConcurrentModificationException();
+ }
if (newValue == null) {
if (prev != null) {
prev.next = e.next;
} else {
tab[index] = e.next;
}
- modCount++;
+ modCount = mc + 1;
count--;
} else {
e.value = newValue;
@@ -1080,7 +1119,9 @@
}
}
+ int mc = modCount;
V newValue = remappingFunction.apply(key, null);
+ if (mc != modCount) { throw new ConcurrentModificationException(); }
if (newValue != null) {
addEntry(hash, key, newValue, index);
}
@@ -1088,6 +1129,16 @@
return newValue;
}
+ /**
+ * {@inheritDoc}
+ *
+ * <p>This method will, on a best-effort basis, throw a
+ * {@link java.util.ConcurrentModificationException} if the remapping
+ * function modified this map during computation.
+ *
+ * @throws ConcurrentModificationException if it is detected that the
+ * remapping function modified this map
+ */
@Override
public synchronized V merge(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
Objects.requireNonNull(remappingFunction);
@@ -1099,14 +1150,18 @@
Entry<K,V> e = (Entry<K,V>)tab[index];
for (Entry<K,V> prev = null; e != null; prev = e, e = e.next) {
if (e.hash == hash && e.key.equals(key)) {
+ int mc = modCount;
V newValue = remappingFunction.apply(e.value, value);
+ if (mc != modCount) {
+ throw new ConcurrentModificationException();
+ }
if (newValue == null) {
if (prev != null) {
prev.next = e.next;
} else {
tab[index] = e.next;
}
- modCount++;
+ modCount = mc + 1;
count--;
} else {
e.value = newValue;
--- a/jdk/src/java.base/share/classes/java/util/Map.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.base/share/classes/java/util/Map.java Tue Apr 14 12:10:00 2015 -0700
@@ -894,8 +894,8 @@
* to {@code null}), attempts to compute its value using the given mapping
* function and enters it into this map unless {@code null}.
*
- * <p>If the function returns {@code null} no mapping is recorded. If
- * the function itself throws an (unchecked) exception, the
+ * <p>If the mapping function returns {@code null}, no mapping is recorded.
+ * If the mapping function itself throws an (unchecked) exception, the
* exception is rethrown, and no mapping is recorded. The most
* common usage is to construct a new object serving as an initial
* mapped value or memoized result, as in:
@@ -911,6 +911,7 @@
* map.computeIfAbsent(key, k -> new HashSet<V>()).add(v);
* }</pre>
*
+ * <p>The mapping function should not modify this map during computation.
*
* @implSpec
* The default implementation is equivalent to the following steps for this
@@ -925,16 +926,27 @@
* }
* }</pre>
*
+ * <p>The default implementation makes no guarantees about detecting if the
+ * mapping function modifies this map during computation and, if
+ * appropriate, reporting an error. Non-concurrent implementations should
+ * override this method and, on a best-effort basis, throw a
+ * {@code ConcurrentModificationException} if it is detected that the
+ * mapping function modifies this map during computation. Concurrent
+ * implementations should override this method and, on a best-effort basis,
+ * throw an {@code IllegalStateException} if it is detected that the
+ * mapping function modifies this map during computation and as a result
+ * computation would never complete.
+ *
* <p>The default implementation makes no guarantees about synchronization
* or atomicity properties of this method. Any implementation providing
* atomicity guarantees must override this method and document its
* concurrency properties. In particular, all implementations of
* subinterface {@link java.util.concurrent.ConcurrentMap} must document
- * whether the function is applied once atomically only if the value is not
- * present.
+ * whether the mapping function is applied once atomically only if the value
+ * is not present.
*
* @param key key with which the specified value is to be associated
- * @param mappingFunction the function to compute a value
+ * @param mappingFunction the mapping function to compute a value
* @return the current (existing or computed) value associated with
* the specified key, or null if the computed value is null
* @throws NullPointerException if the specified key is null and
@@ -967,10 +979,12 @@
* If the value for the specified key is present and non-null, attempts to
* compute a new mapping given the key and its current mapped value.
*
- * <p>If the function returns {@code null}, the mapping is removed. If the
- * function itself throws an (unchecked) exception, the exception is
- * rethrown, and the current mapping is left unchanged.
- *
+ * <p>If the remapping function returns {@code null}, the mapping is removed.
+ * If the remapping function itself throws an (unchecked) exception, the
+ * exception is rethrown, and the current mapping is left unchanged.
+ *
+ * <p>The remapping function should not modify this map during computation.
+ *
* @implSpec
* The default implementation is equivalent to performing the following
* steps for this {@code map}, then returning the current value or
@@ -987,16 +1001,27 @@
* }
* }</pre>
*
+ * <p>The default implementation makes no guarantees about detecting if the
+ * remapping function modifies this map during computation and, if
+ * appropriate, reporting an error. Non-concurrent implementations should
+ * override this method and, on a best-effort basis, throw a
+ * {@code ConcurrentModificationException} if it is detected that the
+ * remapping function modifies this map during computation. Concurrent
+ * implementations should override this method and, on a best-effort basis,
+ * throw an {@code IllegalStateException} if it is detected that the
+ * remapping function modifies this map during computation and as a result
+ * computation would never complete.
+ *
* <p>The default implementation makes no guarantees about synchronization
* or atomicity properties of this method. Any implementation providing
* atomicity guarantees must override this method and document its
* concurrency properties. In particular, all implementations of
* subinterface {@link java.util.concurrent.ConcurrentMap} must document
- * whether the function is applied once atomically only if the value is not
- * present.
+ * whether the remapping function is applied once atomically only if the
+ * value is not present.
*
* @param key key with which the specified value is to be associated
- * @param remappingFunction the function to compute a value
+ * @param remappingFunction the remapping function to compute a value
* @return the new value associated with the specified key, or null if none
* @throws NullPointerException if the specified key is null and
* this map does not support null keys, or the
@@ -1037,10 +1062,12 @@
* map.compute(key, (k, v) -> (v == null) ? msg : v.concat(msg))}</pre>
* (Method {@link #merge merge()} is often simpler to use for such purposes.)
*
- * <p>If the function returns {@code null}, the mapping is removed (or
- * remains absent if initially absent). If the function itself throws an
- * (unchecked) exception, the exception is rethrown, and the current mapping
- * is left unchanged.
+ * <p>If the remapping function returns {@code null}, the mapping is removed
+ * (or remains absent if initially absent). If the remapping function
+ * itself throws an (unchecked) exception, the exception is rethrown, and
+ * the current mapping is left unchanged.
+ *
+ * <p>The remapping function should not modify this map during computation.
*
* @implSpec
* The default implementation is equivalent to performing the following
@@ -1063,16 +1090,27 @@
* }
* }</pre>
*
+ * <p>The default implementation makes no guarantees about detecting if the
+ * remapping function modifies this map during computation and, if
+ * appropriate, reporting an error. Non-concurrent implementations should
+ * override this method and, on a best-effort basis, throw a
+ * {@code ConcurrentModificationException} if it is detected that the
+ * remapping function modifies this map during computation. Concurrent
+ * implementations should override this method and, on a best-effort basis,
+ * throw an {@code IllegalStateException} if it is detected that the
+ * remapping function modifies this map during computation and as a result
+ * computation would never complete.
+ *
* <p>The default implementation makes no guarantees about synchronization
* or atomicity properties of this method. Any implementation providing
* atomicity guarantees must override this method and document its
* concurrency properties. In particular, all implementations of
* subinterface {@link java.util.concurrent.ConcurrentMap} must document
- * whether the function is applied once atomically only if the value is not
- * present.
+ * whether the remapping function is applied once atomically only if the
+ * value is not present.
*
* @param key key with which the specified value is to be associated
- * @param remappingFunction the function to compute a value
+ * @param remappingFunction the remapping function to compute a value
* @return the new value associated with the specified key, or null if none
* @throws NullPointerException if the specified key is null and
* this map does not support null keys, or the
@@ -1121,9 +1159,11 @@
* map.merge(key, msg, String::concat)
* }</pre>
*
- * <p>If the function returns {@code null} the mapping is removed. If the
- * function itself throws an (unchecked) exception, the exception is
- * rethrown, and the current mapping is left unchanged.
+ * <p>If the remapping function returns {@code null}, the mapping is removed.
+ * If the remapping function itself throws an (unchecked) exception, the
+ * exception is rethrown, and the current mapping is left unchanged.
+ *
+ * <p>The remapping function should not modify this map during computation.
*
* @implSpec
* The default implementation is equivalent to performing the following
@@ -1140,19 +1180,31 @@
* map.put(key, newValue);
* }</pre>
*
+ * <p>The default implementation makes no guarantees about detecting if the
+ * remapping function modifies this map during computation and, if
+ * appropriate, reporting an error. Non-concurrent implementations should
+ * override this method and, on a best-effort basis, throw a
+ * {@code ConcurrentModificationException} if it is detected that the
+ * remapping function modifies this map during computation. Concurrent
+ * implementations should override this method and, on a best-effort basis,
+ * throw an {@code IllegalStateException} if it is detected that the
+ * remapping function modifies this map during computation and as a result
+ * computation would never complete.
+ *
* <p>The default implementation makes no guarantees about synchronization
* or atomicity properties of this method. Any implementation providing
* atomicity guarantees must override this method and document its
* concurrency properties. In particular, all implementations of
* subinterface {@link java.util.concurrent.ConcurrentMap} must document
- * whether the function is applied once atomically only if the value is not
- * present.
+ * whether the remapping function is applied once atomically only if the
+ * value is not present.
*
* @param key key with which the resulting value is to be associated
* @param value the non-null value to be merged with the existing value
* associated with the key or, if no existing value or a null value
* is associated with the key, to be associated with the key
- * @param remappingFunction the function to recompute a value if present
+ * @param remappingFunction the remapping function to recompute a value if
+ * present
* @return the new value associated with the specified key, or null if no
* value is associated with the key
* @throws UnsupportedOperationException if the {@code put} operation
--- a/jdk/src/java.base/share/classes/java/util/zip/ZipEntry.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.base/share/classes/java/util/zip/ZipEntry.java Tue Apr 14 12:10:00 2015 -0700
@@ -481,6 +481,8 @@
}
break;
case EXTID_NTFS:
+ if (sz < 32) // reserved 4 bytes + tag 2 bytes + size 2 bytes
+ break; // m[a|c]time 24 bytes
int pos = off + 4; // reserved 4 bytes
if (get16(extra, pos) != 0x0001 || get16(extra, pos + 2) != 24)
break;
--- a/jdk/src/java.base/share/classes/javax/crypto/CipherInputStream.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.base/share/classes/javax/crypto/CipherInputStream.java Tue Apr 14 12:10:00 2015 -0700
@@ -25,7 +25,11 @@
package javax.crypto;
-import java.io.*;
+import java.io.InputStream;
+import java.io.FilterInputStream;
+import java.io.IOException;
+import javax.crypto.BadPaddingException;
+import javax.crypto.IllegalBlockSizeException;
/**
* A CipherInputStream is composed of an InputStream and a Cipher so
@@ -88,8 +92,6 @@
private int ofinish = 0;
// stream status
private boolean closed = false;
- // The stream has been read from. False if the stream has never been read.
- private boolean read = false;
/**
* private convenience function.
@@ -101,11 +103,15 @@
* return (ofinish-ostart) (we have this many bytes for you)
* return 0 (no data now, but could have more later)
* return -1 (absolutely no more data)
+ *
+ * Note: Exceptions are only thrown after the stream is completely read.
+ * For AEAD ciphers a read() of any length will internally cause the
+ * whole stream to be read fully and verify the authentication tag before
+ * returning decrypted data or exceptions.
*/
private int getMoreData() throws IOException {
if (done) return -1;
int readin = input.read(ibuffer);
- read = true;
if (readin == -1) {
done = true;
try {
@@ -301,17 +307,16 @@
closed = true;
input.close();
- try {
- // throw away the unprocessed data
- if (!done) {
+
+ // Throw away the unprocessed data and throw no crypto exceptions.
+ // AEAD ciphers are fully readed before closing. Any authentication
+ // exceptions would occur while reading.
+ if (!done) {
+ try {
cipher.doFinal();
}
- }
- catch (BadPaddingException | IllegalBlockSizeException ex) {
- /* If no data has been read from the stream to be en/decrypted,
- we supress any exceptions, and close quietly. */
- if (read) {
- throw new IOException(ex);
+ catch (BadPaddingException | IllegalBlockSizeException ex) {
+ // Catch exceptions as the rest of the stream is unused.
}
}
ostart = 0;
--- a/jdk/src/java.base/share/classes/javax/security/auth/Policy.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.base/share/classes/javax/security/auth/Policy.java Tue Apr 14 12:10:00 2015 -0700
@@ -322,7 +322,7 @@
* in conjunction with the provided
* {@code CodeSource}, determines the Permissions
* returned by this method. This parameter
- * may be {@code null}. <p>
+ * may be {@code null}.
*
* @param cs the code specified by its {@code CodeSource}
* that determines, in conjunction with the provided
--- a/jdk/src/java.base/share/classes/javax/security/auth/login/LoginContext.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.base/share/classes/javax/security/auth/login/LoginContext.java Tue Apr 14 12:10:00 2015 -0700
@@ -25,18 +25,18 @@
package javax.security.auth.login;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.lang.reflect.InvocationTargetException;
-import java.util.LinkedList;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.Map;
import java.util.HashMap;
import java.text.MessageFormat;
import javax.security.auth.Subject;
import javax.security.auth.AuthPermission;
import javax.security.auth.callback.*;
-import java.security.AccessController;
+import javax.security.auth.spi.LoginModule;
import java.security.AccessControlContext;
+import java.util.ServiceLoader;
+
import sun.security.util.PendingException;
import sun.security.util.ResourcesMgr;
@@ -192,7 +192,6 @@
*/
public class LoginContext {
- private static final String INIT_METHOD = "initialize";
private static final String LOGIN_METHOD = "login";
private static final String COMMIT_METHOD = "commit";
private static final String ABORT_METHOD = "abort";
@@ -210,7 +209,6 @@
private AccessControlContext creatorAcc = null; // customized config only
private ModuleInfo[] moduleStack;
private ClassLoader contextClassLoader = null;
- private static final Class<?>[] PARAMS = { };
// state saved in the event a user-specified asynchronous exception
// was specified and thrown
@@ -678,64 +676,64 @@
for (int i = moduleIndex; i < moduleStack.length; i++, moduleIndex++) {
try {
- int mIndex = 0;
- Method[] methods = null;
+ if (moduleStack[i].module == null) {
- if (moduleStack[i].module != null) {
- methods = moduleStack[i].module.getClass().getMethods();
- } else {
-
- // instantiate the LoginModule
+ // locate and instantiate the LoginModule
//
- // Allow any object to be a LoginModule as long as it
- // conforms to the interface.
- Class<?> c = Class.forName(
- moduleStack[i].entry.getLoginModuleName(),
- true,
- contextClassLoader);
-
- Constructor<?> constructor = c.getConstructor(PARAMS);
- Object[] args = { };
- moduleStack[i].module = constructor.newInstance(args);
-
- // call the LoginModule's initialize method
- methods = moduleStack[i].module.getClass().getMethods();
- for (mIndex = 0; mIndex < methods.length; mIndex++) {
- if (methods[mIndex].getName().equals(INIT_METHOD)) {
+ String name = moduleStack[i].entry.getLoginModuleName();
+ ServiceLoader<LoginModule> sc = AccessController.doPrivileged(
+ (PrivilegedAction<ServiceLoader<LoginModule>>)
+ () -> ServiceLoader.load(
+ LoginModule.class, contextClassLoader));
+ for (LoginModule m: sc) {
+ if (m.getClass().getName().equals(name)) {
+ moduleStack[i].module = m;
+ if (debug != null) {
+ debug.println(name + " loaded as a service");
+ }
break;
}
}
- Object[] initArgs = {subject,
- callbackHandler,
- state,
- moduleStack[i].entry.getOptions() };
+ if (moduleStack[i].module == null) {
+ try {
+ moduleStack[i].module = (LoginModule) Class.forName(
+ name, false, contextClassLoader).newInstance();
+ if (debug != null) {
+ debug.println(name + " loaded via reflection");
+ }
+ } catch (ClassNotFoundException e) {
+ throw new LoginException("No LoginModule found for "
+ + name);
+ }
+ }
+
// invoke the LoginModule initialize method
- //
- // Throws ArrayIndexOutOfBoundsException if no such
- // method defined. May improve to use LoginException in
- // the future.
- methods[mIndex].invoke(moduleStack[i].module, initArgs);
+ moduleStack[i].module.initialize(subject,
+ callbackHandler,
+ state,
+ moduleStack[i].entry.getOptions());
}
// find the requested method in the LoginModule
- for (mIndex = 0; mIndex < methods.length; mIndex++) {
- if (methods[mIndex].getName().equals(methodName)) {
+ boolean status;
+ switch (methodName) {
+ case LOGIN_METHOD:
+ status = moduleStack[i].module.login();
+ break;
+ case COMMIT_METHOD:
+ status = moduleStack[i].module.commit();
break;
- }
+ case LOGOUT_METHOD:
+ status = moduleStack[i].module.logout();
+ break;
+ case ABORT_METHOD:
+ status = moduleStack[i].module.abort();
+ break;
+ default:
+ throw new AssertionError("Unknown method " + methodName);
}
- // set up the arguments to be passed to the LoginModule method
- Object[] args = { };
-
- // invoke the LoginModule method
- //
- // Throws ArrayIndexOutOfBoundsException if no such
- // method defined. May improve to use LoginException in
- // the future.
- boolean status = ((Boolean)methods[mIndex].invoke
- (moduleStack[i].module, args)).booleanValue();
-
if (status == true) {
// if SUFFICIENT, return if no prior REQUIRED errors
@@ -760,31 +758,12 @@
if (debug != null)
debug.println(methodName + " ignored");
}
-
- } catch (NoSuchMethodException nsme) {
- MessageFormat form = new MessageFormat(ResourcesMgr.getString
- ("unable.to.instantiate.LoginModule.module.because.it.does.not.provide.a.no.argument.constructor"));
- Object[] source = {moduleStack[i].entry.getLoginModuleName()};
- throwException(null, new LoginException(form.format(source)));
- } catch (InstantiationException ie) {
- throwException(null, new LoginException(ResourcesMgr.getString
- ("unable.to.instantiate.LoginModule.") +
- ie.getMessage()));
- } catch (ClassNotFoundException cnfe) {
- throwException(null, new LoginException(ResourcesMgr.getString
- ("unable.to.find.LoginModule.class.") +
- cnfe.getMessage()));
- } catch (IllegalAccessException iae) {
- throwException(null, new LoginException(ResourcesMgr.getString
- ("unable.to.access.LoginModule.") +
- iae.getMessage()));
- } catch (InvocationTargetException ite) {
+ } catch (Exception ite) {
// failure cases
-
LoginException le;
- if (ite.getCause() instanceof PendingException &&
+ if (ite instanceof PendingException &&
methodName.equals(LOGIN_METHOD)) {
// XXX
@@ -808,13 +787,13 @@
// the only time that is not true is in this case -
// do not call throwException here.
- throw (PendingException)ite.getCause();
+ throw (PendingException)ite;
- } else if (ite.getCause() instanceof LoginException) {
+ } else if (ite instanceof LoginException) {
- le = (LoginException)ite.getCause();
+ le = (LoginException)ite;
- } else if (ite.getCause() instanceof SecurityException) {
+ } else if (ite instanceof SecurityException) {
// do not want privacy leak
// (e.g., sensitive file path in exception msg)
@@ -826,14 +805,14 @@
("original security exception with detail msg " +
"replaced by new exception with empty detail msg");
debug.println("original security exception: " +
- ite.getCause().toString());
+ ite.toString());
}
} else {
// capture an unexpected LoginModule exception
java.io.StringWriter sw = new java.io.StringWriter();
- ite.getCause().printStackTrace
- (new java.io.PrintWriter(sw));
+ ite.printStackTrace
+ (new java.io.PrintWriter(sw));
sw.flush();
le = new LoginException(sw.toString());
}
@@ -938,9 +917,9 @@
*/
private static class ModuleInfo {
AppConfigurationEntry entry;
- Object module;
+ LoginModule module;
- ModuleInfo(AppConfigurationEntry newEntry, Object newModule) {
+ ModuleInfo(AppConfigurationEntry newEntry, LoginModule newModule) {
this.entry = newEntry;
this.module = newModule;
}
--- a/jdk/src/java.base/share/classes/javax/security/auth/spi/LoginModule.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.base/share/classes/javax/security/auth/spi/LoginModule.java Tue Apr 14 12:10:00 2015 -0700
@@ -32,10 +32,9 @@
import java.util.Map;
/**
- * <p> {@code LoginModule} describes the interface
- * implemented by authentication technology providers. LoginModules
- * are plugged in under applications to provide a particular type of
- * authentication.
+ * <p> Service-provider interface for authentication technology providers.
+ * LoginModules are plugged in under applications to provide a particular
+ * type of authentication.
*
* <p> While applications write to the {@code LoginContext} API,
* authentication technology providers implement the
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/jdk/Exported.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk;
+
+import java.lang.annotation.*;
+
+/**
+ * Indicates whether or not a JDK specific type or package is an
+ * exported part of the JDK suitable for use outside of the JDK
+ * implementation itself.
+ *
+ * This annotation should only be applied to types and packages
+ * <em>outside</em> of the Java SE namespaces of {@code java.*} and
+ * {@code javax.*} packages. For example, certain portions of {@code
+ * com.sun.*} are official parts of the JDK meant to be generally
+ * usable while other portions of {@code com.sun.*} are not. This
+ * annotation type allows those portions to be easily and
+ * programmatically distinguished.
+ *
+ * <p>If in one release a type or package is
+ * <code>@Exported(true)</code>, in a subsequent major release such a
+ * type or package can transition to <code>@Exported(false)</code>.
+ *
+ * <p>If a type or package is <code>@Exported(false)</code> in a
+ * release, it may be removed in a subsequent major release.
+ *
+ * <p>If a top-level type has an <code>@Exported</code> annotation,
+ * any nested member types with the top-level type should have an
+ * <code>@Exported</code> annotation with the same value.
+ *
+ * (In exceptional cases, if a nested type is going to be removed
+ * before its enclosing type, the nested type's could be
+ * <code>@Exported(false)</code> while its enclosing type was
+ * <code>@Exported(true)</code>.)
+ *
+ * Likewise, if a package has an <code>@Exported</code> annotation,
+ * top-level types within that package should also have an
+ * <code>@Exported</code> annotation.
+ *
+ * Sometimes a top-level type may have a different
+ * <code>@Exported</code> value than its package.
+ *
+ * @since 1.8
+ */
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE, ElementType.PACKAGE})
+@Exported
+public @interface Exported {
+ /**
+ * Whether or not the annotated type or package is an exported
+ * part of the JDK.
+ * @return whether or not the annotated type or package is an exported
+ * part of the JDK
+ */
+ boolean value() default true;
+}
--- a/jdk/src/java.base/share/classes/sun/misc/Unsafe.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.base/share/classes/sun/misc/Unsafe.java Tue Apr 14 12:10:00 2015 -0700
@@ -631,6 +631,10 @@
/**
* Atomically updates Java variable to {@code x} if it is currently
* holding {@code expected}.
+ *
+ * <p>This operation has memory semantics of a {@code volatile} read
+ * and write. Corresponds to C11 atomic_compare_exchange_strong.
+ *
* @return {@code true} if successful
*/
public final native boolean compareAndSwapObject(Object o, long offset,
@@ -640,6 +644,10 @@
/**
* Atomically updates Java variable to {@code x} if it is currently
* holding {@code expected}.
+ *
+ * <p>This operation has memory semantics of a {@code volatile} read
+ * and write. Corresponds to C11 atomic_compare_exchange_strong.
+ *
* @return {@code true} if successful
*/
public final native boolean compareAndSwapInt(Object o, long offset,
@@ -649,6 +657,10 @@
/**
* Atomically updates Java variable to {@code x} if it is currently
* holding {@code expected}.
+ *
+ * <p>This operation has memory semantics of a {@code volatile} read
+ * and write. Corresponds to C11 atomic_compare_exchange_strong.
+ *
* @return {@code true} if successful
*/
public final native boolean compareAndSwapLong(Object o, long offset,
--- a/jdk/src/java.base/share/classes/sun/reflect/misc/FieldUtil.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.base/share/classes/sun/reflect/misc/FieldUtil.java Tue Apr 14 12:10:00 2015 -0700
@@ -45,9 +45,4 @@
ReflectUtil.checkPackageAccess(cls);
return cls.getFields();
}
-
- public static Field[] getDeclaredFields(Class<?> cls) {
- ReflectUtil.checkPackageAccess(cls);
- return cls.getDeclaredFields();
- }
}
--- a/jdk/src/java.base/share/classes/sun/util/calendar/ZoneInfoFile.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.base/share/classes/sun/util/calendar/ZoneInfoFile.java Tue Apr 14 12:10:00 2015 -0700
@@ -625,6 +625,15 @@
params[2] = 5;
params[3] = 86400000;
}
+ // Additional check for startDayOfWeek=6 and starTime=86400000
+ // is needed for Asia/Amman; Asia/Gasa and Asia/Hebron
+ if (params[2] == 7 && params[3] == 0 &&
+ (zoneId.equals("Asia/Amman") ||
+ zoneId.equals("Asia/Gaza") ||
+ zoneId.equals("Asia/Hebron"))) {
+ params[2] = 6; // Friday
+ params[3] = 86400000; // 24h
+ }
//endDayOfWeek and endTime workaround
if (params[7] == 6 && params[8] == 0 &&
(zoneId.equals("Africa/Cairo"))) {
--- a/jdk/src/java.base/share/native/libjli/java.c Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.base/share/native/libjli/java.c Tue Apr 14 12:10:00 2015 -0700
@@ -730,7 +730,7 @@
static int
parse_size(const char *s, jlong *result) {
jlong n = 0;
- int args_read = sscanf(s, jlong_format_specifier(), &n);
+ int args_read = sscanf(s, JLONG_FORMAT_SPECIFIER, &n);
if (args_read != 1) {
return 0;
}
@@ -798,7 +798,7 @@
* overflow before the JVM startup code can check to make sure the stack
* is big enough.
*/
- if (threadStackSize < STACK_SIZE_MINIMUM) {
+ if (threadStackSize < (jlong)STACK_SIZE_MINIMUM) {
threadStackSize = STACK_SIZE_MINIMUM;
}
}
--- a/jdk/src/java.base/share/native/libjli/java.h Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.base/share/native/libjli/java.h Tue Apr 14 12:10:00 2015 -0700
@@ -144,8 +144,6 @@
void JLI_ReportExceptionDescription(JNIEnv * env);
void PrintMachineDependentOptions();
-const char *jlong_format_specifier();
-
/*
* Block current thread and continue execution in new thread
*/
--- a/jdk/src/java.base/share/native/libjli/manifest_info.h Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.base/share/native/libjli/manifest_info.h Tue Apr 14 12:10:00 2015 -0700
@@ -109,6 +109,8 @@
/*
* Macros for getting end of central directory header (END) fields
*/
+#define ENDNMD(b) SH(b, 4) /* number of this disk */
+#define ENDDSK(b) SH(b, 6) /* disk number of start */
#define ENDSUB(b) SH(b, 8) /* number of entries on this disk */
#define ENDTOT(b) SH(b, 10) /* total number of entries */
#define ENDSIZ(b) LG(b, 12) /* central directory size */
--- a/jdk/src/java.base/share/native/libjli/parse_manifest.c Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.base/share/native/libjli/parse_manifest.c Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -111,52 +111,127 @@
return (NULL);
}
-static jboolean zip64_present = JNI_FALSE;
+/*
+ * Implementation notes:
+ *
+ * This is a zip format reader for seekable files, that tolerates
+ * leading and trailing garbage, and tolerates having had internal
+ * offsets adjusted for leading garbage (as with Info-Zip's zip -A).
+ *
+ * We find the end header by scanning backwards from the end of the
+ * file for the end signature. This may fail in the presence of
+ * trailing garbage or a ZIP file comment that contains binary data.
+ * Similarly, the ZIP64 end header may need to be located by scanning
+ * backwards from the end header. It may be misidentified, but this
+ * is very unlikely to happen in practice without adversarial input.
+ *
+ * The zip file format is documented at:
+ * https://www.pkware.com/documents/casestudies/APPNOTE.TXT
+ *
+ * TODO: more informative error messages
+ */
+
+/** Reads count bytes from fd at position pos into given buffer. */
+static jboolean
+readAt(int fd, jlong pos, unsigned int count, void *buf) {
+ return (pos >= 0
+ && JLI_Lseek(fd, pos, SEEK_SET) == pos
+ && read(fd, buf, count) == (jlong) count);
+}
+
/*
- * Checks to see if we have ZIP64 archive, and save
- * the check for later use
+ * Tells whether given header values (obtained from either ZIP64 or
+ * non-ZIP64 header) appear to be correct, by checking the first LOC
+ * and CEN headers.
*/
-static int
-haveZIP64(Byte *p) {
- jlong cenlen, cenoff, centot;
- cenlen = ENDSIZ(p);
- cenoff = ENDOFF(p);
- centot = ENDTOT(p);
- zip64_present = (cenlen == ZIP64_MAGICVAL ||
- cenoff == ZIP64_MAGICVAL ||
- centot == ZIP64_MAGICCOUNT);
- return zip64_present;
-}
-
-static jlong
-find_end64(int fd, Byte *ep, jlong pos)
-{
- jlong end64pos;
- jlong bytes;
- if ((end64pos = JLI_Lseek(fd, pos - ZIP64_LOCHDR, SEEK_SET)) < (jlong)0)
- return -1;
- if ((bytes = read(fd, ep, ZIP64_LOCHDR)) < 0)
- return -1;
- if (ZIP64_LOCSIG_AT(ep))
- return end64pos;
- return -1;
+static jboolean
+is_valid_end_header(int fd, jlong endpos,
+ jlong censiz, jlong cenoff, jlong entries) {
+ Byte cenhdr[CENHDR];
+ Byte lochdr[LOCHDR];
+ // Expected offset of the first central directory header
+ jlong censtart = endpos - censiz;
+ // Expected position within the file that offsets are relative to
+ jlong base_offset = endpos - (censiz + cenoff);
+ return censtart >= 0 && cenoff >= 0 &&
+ (censiz == 0 ||
+ // Validate first CEN and LOC header signatures.
+ // Central directory must come directly before the end header.
+ (readAt(fd, censtart, CENHDR, cenhdr)
+ && CENSIG_AT(cenhdr)
+ && readAt(fd, base_offset + CENOFF(cenhdr), LOCHDR, lochdr)
+ && LOCSIG_AT(lochdr)
+ && CENNAM(cenhdr) == LOCNAM(lochdr)));
}
/*
- * A very little used routine to handle the case that zip file has
- * a comment at the end. Believe it or not, the only way to find the
- * END record is to walk backwards, byte by bloody byte looking for
- * the END record signature.
+ * Tells whether p appears to be pointing at a valid ZIP64 end header.
+ * Values censiz, cenoff, and entries are the corresponding values
+ * from the non-ZIP64 end header. We perform extra checks to avoid
+ * misidentifying data from the last entry as a ZIP64 end header.
+ */
+static jboolean
+is_zip64_endhdr(int fd, const Byte *p, jlong end64pos,
+ jlong censiz, jlong cenoff, jlong entries) {
+ if (ZIP64_ENDSIG_AT(p)) {
+ jlong censiz64 = ZIP64_ENDSIZ(p);
+ jlong cenoff64 = ZIP64_ENDOFF(p);
+ jlong entries64 = ZIP64_ENDTOT(p);
+ return (censiz64 == censiz || censiz == ZIP64_MAGICVAL)
+ && (cenoff64 == cenoff || cenoff == ZIP64_MAGICVAL)
+ && (entries64 == entries || entries == ZIP64_MAGICCOUNT)
+ && is_valid_end_header(fd, end64pos, censiz64, cenoff64, entries64);
+ }
+ return JNI_FALSE;
+}
+
+/*
+ * Given a non-ZIP64 end header located at endhdr and endpos, look for
+ * an adjacent ZIP64 end header, finding the base offset and censtart
+ * from the ZIP64 header if available, else from the non-ZIP64 header.
+ * @return 0 if successful, -1 in case of failure
+ */
+static int
+find_positions64(int fd, const Byte * const endhdr, const jlong endpos,
+ jlong* base_offset, jlong* censtart)
+{
+ jlong censiz = ENDSIZ(endhdr);
+ jlong cenoff = ENDOFF(endhdr);
+ jlong entries = ENDTOT(endhdr);
+ jlong end64pos;
+ Byte buf[ZIP64_ENDHDR + ZIP64_LOCHDR];
+ if (censiz + cenoff != endpos
+ && (end64pos = endpos - sizeof(buf)) >= (jlong)0
+ && readAt(fd, end64pos, sizeof(buf), buf)
+ && ZIP64_LOCSIG_AT(buf + ZIP64_ENDHDR)
+ && (jlong) ZIP64_LOCDSK(buf + ZIP64_ENDHDR) == ENDDSK(endhdr)
+ && (is_zip64_endhdr(fd, buf, end64pos, censiz, cenoff, entries)
+ || // A variable sized "zip64 extensible data sector" ?
+ ((end64pos = ZIP64_LOCOFF(buf + ZIP64_ENDHDR)) >= (jlong)0
+ && readAt(fd, end64pos, ZIP64_ENDHDR, buf)
+ && is_zip64_endhdr(fd, buf, end64pos, censiz, cenoff, entries)))
+ ) {
+ *censtart = end64pos - ZIP64_ENDSIZ(buf);
+ *base_offset = *censtart - ZIP64_ENDOFF(buf);
+ } else {
+ if (!is_valid_end_header(fd, endpos, censiz, cenoff, entries))
+ return -1;
+ *censtart = endpos - censiz;
+ *base_offset = *censtart - cenoff;
+ }
+ return 0;
+}
+
+/*
+ * Finds the base offset and censtart of the zip file.
*
- * fd: File descriptor of the jar file.
- * eb: Pointer to a buffer to receive a copy of the END header.
- *
- * Returns the offset of the END record in the file on success,
- * -1 on failure.
+ * @param fd file descriptor of the jar file
+ * @param eb scratch buffer
+ * @return 0 if successful, -1 in case of failure
*/
-static jlong
-find_end(int fd, Byte *eb)
+static int
+find_positions(int fd, Byte *eb, jlong* base_offset, jlong* censtart)
{
jlong len;
jlong pos;
@@ -174,10 +249,10 @@
*/
if ((pos = JLI_Lseek(fd, -ENDHDR, SEEK_END)) < (jlong)0)
return (-1);
- if ((bytes = read(fd, eb, ENDHDR)) < 0)
+ if (read(fd, eb, ENDHDR) < 0)
return (-1);
if (ENDSIG_AT(eb)) {
- return haveZIP64(eb) ? find_end64(fd, eb, pos) : pos;
+ return find_positions64(fd, eb, pos, base_offset, censtart);
}
/*
@@ -193,7 +268,13 @@
return (-1);
if ((buffer = malloc(END_MAXLEN)) == NULL)
return (-1);
- if ((bytes = read(fd, buffer, len)) < 0) {
+
+ /*
+ * read() on windows takes an unsigned int for count. Casting len
+ * to an unsigned int here is safe since it is guaranteed to be
+ * less than END_MAXLEN.
+ */
+ if ((bytes = read(fd, buffer, (unsigned int)len)) < 0) {
free(buffer);
return (-1);
}
@@ -208,7 +289,7 @@
(void) memcpy(eb, cp, ENDHDR);
free(buffer);
pos = flen - (endpos - cp);
- return haveZIP64(eb) ? find_end64(fd, eb, pos) : pos;
+ return find_positions64(fd, eb, pos, base_offset, censtart);
}
free(buffer);
return (-1);
@@ -218,82 +299,6 @@
#define MINREAD 1024
/*
- * Computes and positions at the start of the CEN header, ie. the central
- * directory, this will also return the offset if there is a zip file comment
- * at the end of the archive, for most cases this would be 0.
- */
-static jlong
-compute_cen(int fd, Byte *bp)
-{
- int bytes;
- Byte *p;
- jlong base_offset;
- jlong offset;
- char buffer[MINREAD];
- p = (Byte*) buffer;
- /*
- * Read the END Header, which is the starting point for ZIP files.
- * (Clearly designed to make writing a zip file easier than reading
- * one. Now isn't that precious...)
- */
- if ((base_offset = find_end(fd, bp)) == -1) {
- return (-1);
- }
- p = bp;
- /*
- * There is a historical, but undocumented, ability to allow for
- * additional "stuff" to be prepended to the zip/jar file. It seems
- * that this has been used to prepend an actual java launcher
- * executable to the jar on Windows. Although this is just another
- * form of statically linking a small piece of the JVM to the
- * application, we choose to continue to support it. Note that no
- * guarantees have been made (or should be made) to the customer that
- * this will continue to work.
- *
- * Therefore, calculate the base offset of the zip file (within the
- * expanded file) by assuming that the central directory is followed
- * immediately by the end record.
- */
- if (zip64_present) {
- if ((offset = ZIP64_LOCOFF(p)) < (jlong)0) {
- return -1;
- }
- if (JLI_Lseek(fd, offset, SEEK_SET) < (jlong) 0) {
- return (-1);
- }
- if ((bytes = read(fd, buffer, MINREAD)) < 0) {
- return (-1);
- }
- if (!ZIP64_ENDSIG_AT(buffer)) {
- return -1;
- }
- if ((offset = ZIP64_ENDOFF(buffer)) < (jlong)0) {
- return -1;
- }
- if (JLI_Lseek(fd, offset, SEEK_SET) < (jlong)0) {
- return (-1);
- }
- p = (Byte*) buffer;
- base_offset = base_offset - ZIP64_ENDSIZ(p) - ZIP64_ENDOFF(p) - ZIP64_ENDHDR;
- } else {
- base_offset = base_offset - ENDSIZ(p) - ENDOFF(p);
- /*
- * The END Header indicates the start of the Central Directory
- * Headers. Remember that the desired Central Directory Header (CEN)
- * will almost always be the second one and the first one is a small
- * directory entry ("META-INF/"). Keep the code optimized for
- * that case.
- *
- * Seek to the beginning of the Central Directory.
- */
- if (JLI_Lseek(fd, base_offset + ENDOFF(p), SEEK_SET) < (jlong) 0) {
- return (-1);
- }
- }
- return base_offset;
-}
-
-/*
* Locate the manifest file with the zip/jar file.
*
* fd: File descriptor of the jar file.
@@ -327,7 +332,23 @@
int res;
int entry_size;
int read_size;
+
+ /*
+ * The (imaginary) position within the file relative to which
+ * offsets within the zip file refer. This is usually the
+ * location of the first local header (the start of the zip data)
+ * (which in turn is usually 0), but if the zip file has content
+ * prepended, then it will be either 0 or the length of the
+ * prepended content, depending on whether or not internal offsets
+ * have been adjusted (via e.g. zip -A). May be negative if
+ * content is prepended, zip -A is run, then the prefix is
+ * detached!
+ */
jlong base_offset;
+
+ /** The position within the file of the start of the central directory. */
+ jlong censtart;
+
Byte *p;
Byte *bp;
Byte *buffer;
@@ -338,9 +359,11 @@
}
bp = buffer;
- base_offset = compute_cen(fd, bp);
- if (base_offset == -1) {
- free(buffer);
+
+ if (find_positions(fd, bp, &base_offset, &censtart) == -1) {
+ return -1;
+ }
+ if (JLI_Lseek(fd, censtart, SEEK_SET) < (jlong) 0) {
return -1;
}
@@ -574,7 +597,7 @@
info->jre_version = NULL;
info->jre_restrict_search = 0;
info->splashscreen_image_file_name = NULL;
- if (rc = find_file(fd, &entry, manifest_name) != 0) {
+ if ((rc = find_file(fd, &entry, manifest_name)) != 0) {
close(fd);
return (-2);
}
@@ -675,7 +698,7 @@
return (-1);
}
- if (rc = find_file(fd, &entry, manifest_name) != 0) {
+ if ((rc = find_file(fd, &entry, manifest_name)) != 0) {
close(fd);
return (-2);
}
--- a/jdk/src/java.base/share/native/libjli/splashscreen_stubs.c Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.base/share/native/libjli/splashscreen_stubs.c Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -61,11 +61,11 @@
#define INVOKEV(name) _INVOKE(name, ,;)
int DoSplashLoadMemory(void* pdata, int size) {
- INVOKE(SplashLoadMemory, NULL)(pdata, size);
+ INVOKE(SplashLoadMemory, 0)(pdata, size);
}
int DoSplashLoadFile(const char* filename) {
- INVOKE(SplashLoadFile, NULL)(filename);
+ INVOKE(SplashLoadFile, 0)(filename);
}
void DoSplashInit(void) {
@@ -87,4 +87,4 @@
char* DoSplashGetScaledImageName(const char* fileName, const char* jarName,
float* scaleFactor) {
INVOKE(SplashGetScaledImageName, NULL)(fileName, jarName, scaleFactor);
-}
\ No newline at end of file
+}
--- a/jdk/src/java.base/share/native/libjli/wildcard.c Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.base/share/native/libjli/wildcard.c Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -274,7 +274,7 @@
}
static void
-FileList_addSubstring(FileList fl, const char *beg, int len)
+FileList_addSubstring(FileList fl, const char *beg, size_t len)
{
char *filename = (char *) JLI_MemAlloc(len+1);
memcpy(filename, beg, len);
@@ -310,7 +310,7 @@
FileList_split(const char *path, char sep)
{
const char *p, *q;
- int len = (int)JLI_StrLen(path);
+ size_t len = JLI_StrLen(path);
int count;
FileList fl;
for (count = 1, p = path; p < path + len; p++)
--- a/jdk/src/java.base/unix/classes/java/lang/ProcessImpl.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.base/unix/classes/java/lang/ProcessImpl.java Tue Apr 14 12:10:00 2015 -0700
@@ -285,8 +285,6 @@
* 1 - fork(2) and exec(2)
* 2 - posix_spawn(3P)
* 3 - vfork(2) and exec(2)
- *
- * (4 - clone(2) and exec(2) - obsolete and currently disabled in native code)
* </pre>
* @param fds an array of three file descriptors.
* Indexes 0, 1, and 2 correspond to standard input,
--- a/jdk/src/java.base/unix/conf/arm/jvm.cfg Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation. Oracle designates this
-# particular file as subject to the "Classpath" exception as provided
-# by Oracle in the LICENSE file that accompanied this code.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-# List of JVMs that can be used as an option to java, javac, etc.
-# Order is important -- first in this list is the default JVM.
-# NOTE that this both this file and its format are UNSUPPORTED and
-# WILL GO AWAY in a future release.
-#
-# You may also select a JVM in an arbitrary location with the
-# "-XXaltjvm=<jvm_dir>" option, but that too is unsupported
-# and may not be available in a future release.
-#
--client IF_SERVER_CLASS -server
--server KNOWN
--minimal KNOWN
--- a/jdk/src/java.base/unix/conf/ppc/jvm.cfg Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation. Oracle designates this
-# particular file as subject to the "Classpath" exception as provided
-# by Oracle in the LICENSE file that accompanied this code.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-# List of JVMs that can be used as an option to java, javac, etc.
-# Order is important -- first in this list is the default JVM.
-# NOTE that this both this file and its format are UNSUPPORTED and
-# WILL GO AWAY in a future release.
-#
-# You may also select a JVM in an arbitrary location with the
-# "-XXaltjvm=<jvm_dir>" option, but that too is unsupported
-# and may not be available in a future release.
-#
--client KNOWN
--server KNOWN
--minimal KNOWN
--- a/jdk/src/java.base/unix/native/libjava/ProcessImpl_md.c Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.base/unix/native/libjava/ProcessImpl_md.c Tue Apr 14 12:10:00 2015 -0700
@@ -97,8 +97,7 @@
* address space temporarily, before launching the target command.
*
* Based on the above analysis, we are currently using vfork() on
- * Linux and spawn() on other Unix systems, but the code to use clone()
- * and fork() remains.
+ * Linux and posix_spawn() on other Unix systems.
*/
@@ -385,39 +384,13 @@
}
/**
- * We are unusually paranoid; use of clone/vfork is
+ * We are unusually paranoid; use of vfork is
* especially likely to tickle gcc/glibc bugs.
*/
#ifdef __attribute_noinline__ /* See: sys/cdefs.h */
__attribute_noinline__
#endif
-#define START_CHILD_USE_CLONE 0 /* clone() currently disabled; see above. */
-
-#ifdef START_CHILD_USE_CLONE
-static pid_t
-cloneChild(ChildStuff *c) {
-#ifdef __linux__
-#define START_CHILD_CLONE_STACK_SIZE (64 * 1024)
- /*
- * See clone(2).
- * Instead of worrying about which direction the stack grows, just
- * allocate twice as much and start the stack in the middle.
- */
- if ((c->clone_stack = malloc(2 * START_CHILD_CLONE_STACK_SIZE)) == NULL)
- /* errno will be set to ENOMEM */
- return -1;
- return clone(childProcess,
- c->clone_stack + START_CHILD_CLONE_STACK_SIZE,
- CLONE_VFORK | CLONE_VM | SIGCHLD, c);
-#else
-/* not available on Solaris / Mac */
- assert(0);
- return -1;
-#endif
-}
-#endif
-
static pid_t
vforkChild(ChildStuff *c) {
volatile pid_t resultPid;
@@ -590,12 +563,11 @@
c->argv = NULL;
c->envv = NULL;
c->pdir = NULL;
- c->clone_stack = NULL;
/* Convert prog + argBlock into a char ** argv.
* Add one word room for expansion of argv for use by
* execve_as_traditional_shell_script.
- * This word is also used when using spawn mode
+ * This word is also used when using posix_spawn mode
*/
assert(prog != NULL && argBlock != NULL);
if ((phelperpath = getBytes(env, helperpath)) == NULL) goto Catch;
@@ -654,7 +626,7 @@
throwIOException(env, errno, "fork failed");
break;
case MODE_POSIX_SPAWN:
- throwIOException(env, errno, "spawn failed");
+ throwIOException(env, errno, "posix_spawn failed");
break;
}
goto Catch;
@@ -677,8 +649,6 @@
fds[2] = (err[0] != -1) ? err[0] : -1;
Finally:
- free(c->clone_stack);
-
/* Always clean up the child's side of the pipes */
closeSafely(in [0]);
closeSafely(out[1]);
--- a/jdk/src/java.base/unix/native/libjava/childproc.c Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.base/unix/native/libjava/childproc.c Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -304,7 +304,7 @@
}
/**
- * Child process after a successful fork() or clone().
+ * Child process after a successful fork().
* This function must not return, and must be prepared for either all
* of its address space to be shared with its parent, or to be a copy.
* It must not modify global variables such as "environ".
--- a/jdk/src/java.base/unix/native/libjava/childproc.h Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.base/unix/native/libjava/childproc.h Tue Apr 14 12:10:00 2015 -0700
@@ -101,7 +101,6 @@
const char **envv;
const char *pdir;
int redirectErrorStream;
- void *clone_stack;
} ChildStuff;
/* following used in addition when mode is SPAWN */
--- a/jdk/src/java.base/unix/native/libjava/jni_util_md.c Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.base/unix/native/libjava/jni_util_md.c Tue Apr 14 12:10:00 2015 -0700
@@ -55,10 +55,12 @@
size_t
getLastErrorString(char *buf, size_t len)
{
+ char *err;
+ size_t n;
if (errno == 0 || len < 1) return 0;
- const char *err = strerror(errno);
- size_t n = strlen(err);
+ err = strerror(errno);
+ n = strlen(err);
if (n >= len)
n = len - 1;
--- a/jdk/src/java.base/unix/native/libjli/java_md.h Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.base/unix/native/libjli/java_md.h Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -43,6 +43,12 @@
#define MAXNAMELEN PATH_MAX
#endif
+#ifdef _LP64
+#define JLONG_FORMAT_SPECIFIER "%ld"
+#else
+#define JLONG_FORMAT_SPECIFIER "%lld"
+#endif
+
int UnsetEnv(char *name);
char *FindExecName(char *program);
const char *SetExecname(char **argv);
--- a/jdk/src/java.base/unix/native/libjli/java_md_common.c Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.base/unix/native/libjli/java_md_common.c Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -269,11 +269,6 @@
return(borrowed_unsetenv(name));
}
-const char *
-jlong_format_specifier() {
- return "%lld";
-}
-
jboolean
IsJavaw()
{
--- a/jdk/src/java.base/unix/native/libjli/java_md_solinux.c Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.base/unix/native/libjli/java_md_solinux.c Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -888,7 +888,7 @@
if (pthread_create(&tid, &attr, (void *(*)(void*))continuation, (void*)args) == 0) {
void * tmp;
pthread_join(tid, &tmp);
- rslt = (int)tmp;
+ rslt = (int)(intptr_t)tmp;
} else {
/*
* Continue execution in current thread if for some reason (e.g. out of
@@ -906,7 +906,7 @@
if (thr_create(NULL, stack_size, (void *(*)(void *))continuation, args, flags, &tid) == 0) {
void * tmp;
thr_join(tid, NULL, &tmp);
- rslt = (int)tmp;
+ rslt = (int)(intptr_t)tmp;
} else {
/* See above. Continue in current thread if thr_create() failed */
rslt = continuation(args);
--- a/jdk/src/java.base/windows/native/libjli/cmdtoargs.c Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.base/windows/native/libjli/cmdtoargs.c Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -77,7 +77,7 @@
USHORT ch = 0;
int i;
jboolean done = JNI_FALSE;
- int charLength;
+ ptrdiff_t charLength;
*wildcard = JNI_FALSE;
while (!done) {
@@ -208,10 +208,12 @@
argv = (StdArg*) JLI_MemRealloc(argv, (nargs+1) * sizeof(StdArg));
argv[nargs].arg = JLI_StringDup(arg);
argv[nargs].has_wildcard = wildcard;
- *arg = NULL;
+ *arg = '\0';
nargs++;
} while (src != NULL);
+ JLI_MemFree(arg);
+
stdargc = nargs;
stdargs = argv;
}
--- a/jdk/src/java.base/windows/native/libjli/java_md.c Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.base/windows/native/libjli/java_md.c Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -107,7 +107,7 @@
* GetParamValue("theParam", "theParam=value") returns pointer to "value".
*/
const char * GetParamValue(const char *paramName, const char *arg) {
- int nameLen = JLI_StrLen(paramName);
+ size_t nameLen = JLI_StrLen(paramName);
if (JLI_StrNCmp(paramName, arg, nameLen) == 0) {
/* arg[nameLen] is valid (may contain final NULL) */
if (arg[nameLen] == '=') {
@@ -561,7 +561,7 @@
if (rc < 0) {
/* apply ansi semantics */
buffer[size - 1] = '\0';
- return size;
+ return (int)size;
} else if (rc == size) {
/* force a null terminator */
buffer[size - 1] = '\0';
@@ -728,11 +728,6 @@
}
}
-const char *
-jlong_format_specifier() {
- return "%I64d";
-}
-
/*
* Block current thread and continue execution in a new thread
*/
@@ -882,7 +877,7 @@
if (hPreloadAwt == NULL) {
/* awt.dll is not loaded yet */
char libraryPath[MAXPATHLEN];
- int jrePathLen = 0;
+ size_t jrePathLen = 0;
HMODULE hJava = NULL;
HMODULE hVerify = NULL;
@@ -1004,7 +999,8 @@
jobjectArray
CreateApplicationArgs(JNIEnv *env, char **strv, int argc)
{
- int i, j, idx, tlen;
+ int i, j, idx;
+ size_t tlen;
jobjectArray outArray, inArray;
char *ostart, *astart, **nargv;
jboolean needs_expansion = JNI_FALSE;
--- a/jdk/src/java.base/windows/native/libjli/java_md.h Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.base/windows/native/libjli/java_md.h Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -39,6 +39,7 @@
#define MAXPATHLEN MAX_PATH
#define MAXNAMELEN MAX_PATH
+#define JLONG_FORMAT_SPECIFIER "%I64d"
/*
* Support for doing cheap, accurate interval timing.
--- a/jdk/src/java.desktop/macosx/classes/sun/font/CFontManager.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.desktop/macosx/classes/sun/font/CFontManager.java Tue Apr 14 12:10:00 2015 -0700
@@ -44,7 +44,6 @@
import sun.lwawt.macosx.*;
public final class CFontManager extends SunFontManager {
- private FontConfigManager fcManager = null;
private static Hashtable<String, Font2D> genericFonts = new Hashtable<String, Font2D>();
@Override
@@ -231,15 +230,6 @@
return font2D;
}
- /*
- public synchronized FontConfigManager getFontConfigManager() {
- if (fcManager == null) {
- fcManager = new FontConfigManager();
- }
- return fcManager;
- }
- */
-
protected void registerFontsInDir(String dirName, boolean useJavaRasterizer, int fontRank, boolean defer, boolean resolveSymLinks) {
loadNativeDirFonts(dirName);
super.registerFontsInDir(dirName, useJavaRasterizer, fontRank, defer, resolveSymLinks);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/macosx/classes/sun/font/NativeFont.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.font;
+
+import java.awt.FontFormatException;
+import java.awt.font.FontRenderContext;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+
+/*
+ * This class should never be invoked on the windows implementation
+ * So the constructor throws a FontFormatException, which is caught
+ * and the font is ignored.
+ */
+
+public class NativeFont extends PhysicalFont {
+
+ /**
+ * Verifies native font is accessible.
+ * @throws FontFormatException - if the font can't be located.
+ */
+ public NativeFont(String platName, boolean isBitmapDelegate)
+ throws FontFormatException {
+
+ throw new FontFormatException("NativeFont not used on OS X");
+ }
+
+ static boolean hasExternalBitmaps(String platName) {
+ return false;
+ }
+
+ public CharToGlyphMapper getMapper() {
+ return null;
+ }
+
+ PhysicalFont getDelegateFont() {
+ return null;
+ }
+
+ FontStrike createStrike(FontStrikeDesc desc) {
+ return null;
+ }
+
+ public Rectangle2D getMaxCharBounds(FontRenderContext frc) {
+ return null;
+ }
+
+ StrikeMetrics getFontMetrics(long pScalerContext) {
+ return null;
+ }
+
+ public GeneralPath getGlyphOutline(long pScalerContext,
+ int glyphCode,
+ float x, float y) {
+ return null;
+ }
+
+ public GeneralPath getGlyphVectorOutline(long pScalerContext,
+ int[] glyphs, int numGlyphs,
+ float x, float y) {
+ return null;
+ }
+
+
+ long getGlyphImage(long pScalerContext, int glyphCode) {
+ return 0L;
+ }
+
+
+ void getGlyphMetrics(long pScalerContext, int glyphCode,
+ Point2D.Float metrics) {
+ }
+
+
+ float getGlyphAdvance(long pScalerContext, int glyphCode) {
+ return 0f;
+ }
+
+ Rectangle2D.Float getGlyphOutlineBounds(long pScalerContext,
+ int glyphCode) {
+ return new Rectangle2D.Float(0f, 0f, 0f, 0f);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/macosx/classes/sun/font/NativeStrike.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.font;
+
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Point2D;
+import java.awt.Rectangle;
+import java.awt.geom.Rectangle2D;
+
+public class NativeStrike extends PhysicalStrike {
+
+ NativeFont nativeFont;
+
+ NativeStrike(NativeFont nativeFont, FontStrikeDesc desc) {
+ super(nativeFont, desc);
+
+ throw new RuntimeException("NativeFont not used on OS X");
+ }
+
+ NativeStrike(NativeFont nativeFont, FontStrikeDesc desc,
+ boolean nocache) {
+ super(nativeFont, desc);
+
+ throw new RuntimeException("NativeFont not used on Windows");
+ }
+
+
+ void getGlyphImagePtrs(int[] glyphCodes, long[] images,int len) {
+ }
+
+ long getGlyphImagePtr(int glyphCode) {
+ return 0L;
+ }
+
+ long getGlyphImagePtrNoCache(int glyphCode) {
+ return 0L;
+ }
+
+ void getGlyphImageBounds(int glyphcode,
+ Point2D.Float pt,
+ Rectangle result) {
+ }
+
+ Point2D.Float getGlyphMetrics(int glyphCode) {
+ return null;
+ }
+
+ float getGlyphAdvance(int glyphCode) {
+ return 0f;
+ }
+
+ Rectangle2D.Float getGlyphOutlineBounds(int glyphCode) {
+ return null;
+ }
+ GeneralPath getGlyphOutline(int glyphCode, float x, float y) {
+ return null;
+ }
+
+ GeneralPath getGlyphVectorOutline(int[] glyphs, float x, float y) {
+ return null;
+ }
+
+}
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m Tue Apr 14 12:10:00 2015 -0700
@@ -311,7 +311,10 @@
}
- (BOOL) performKeyEquivalent: (NSEvent *) event {
- [self deliverJavaKeyEventHelper: event];
+ // if IM is active key events should be ignored
+ if (![self hasMarkedText] && !fInPressAndHold) {
+ [self deliverJavaKeyEventHelper: event];
+ }
// Workaround for 8020209: special case for "Cmd =" and "Cmd ."
// because Cocoa calls performKeyEquivalent twice for these keystrokes
--- a/jdk/src/java.desktop/macosx/native/libsplashscreen/splashscreen_sys.m Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.desktop/macosx/native/libsplashscreen/splashscreen_sys.m Tue Apr 14 12:10:00 2015 -0700
@@ -126,14 +126,28 @@
return buf;
}
+BOOL isSWTRunning() {
+ char envVar[80];
+ // If this property is present we are running SWT
+ snprintf(envVar, sizeof(envVar), "JAVA_STARTED_ON_FIRST_THREAD_%d", getpid());
+ return getenv(envVar) != NULL;
+}
+
char* SplashGetScaledImageName(const char* jar, const char* file,
float *scaleFactor) {
+ *scaleFactor = 1;
+
+ if(isSWTRunning()){
+ return nil;
+ }
+
NSAutoreleasePool *pool = [NSAutoreleasePool new];
- *scaleFactor = 1;
char* scaledFile = nil;
__block float screenScaleFactor = 1;
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
+ // initialize NSApplication and AWT stuff
+ [NSApplicationAWT sharedApplication];
screenScaleFactor = [SplashNSScreen() backingScaleFactor];
}];
@@ -180,12 +194,8 @@
splash->screenFormat.byteOrder = 1 ? BYTE_ORDER_LSBFIRST : BYTE_ORDER_MSBFIRST;
splash->screenFormat.depthBytes = 4;
- // If this property is present we are running SWT and should not start a runLoop
- // Can't check if running SWT in webstart, so splash screen in webstart SWT
- // applications is not supported
- char envVar[80];
- snprintf(envVar, sizeof(envVar), "JAVA_STARTED_ON_FIRST_THREAD_%d", getpid());
- if (getenv(envVar) == NULL) {
+ // If we are running SWT we should not start a runLoop
+ if (!isSWTRunning()) {
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^() {
[NSApplicationAWT runAWTLoopWithApp:[NSApplicationAWT sharedApplication]];
}];
--- a/jdk/src/java.desktop/share/classes/javax/imageio/stream/ImageInputStreamImpl.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/stream/ImageInputStreamImpl.java Tue Apr 14 12:10:00 2015 -0700
@@ -225,7 +225,7 @@
}
public short readShort() throws IOException {
- if (read(byteBuf, 0, 2) < 0) {
+ if (read(byteBuf, 0, 2) != 2) {
throw new EOFException();
}
@@ -247,7 +247,7 @@
}
public int readInt() throws IOException {
- if (read(byteBuf, 0, 4) < 0) {
+ if (read(byteBuf, 0, 4) != 4) {
throw new EOFException();
}
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSliderUI.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSliderUI.java Tue Apr 14 12:10:00 2015 -0700
@@ -308,14 +308,14 @@
public Dimension getPreferredSize(JComponent c) {
recalculateIfInsetsChanged();
Dimension d = new Dimension(contentRect.width, contentRect.height);
+ Insets i = slider.getInsets();
if (slider.getOrientation() == JSlider.VERTICAL) {
d.height = 200;
+ d.height += i.top + i.bottom;
} else {
d.width = 200;
+ d.width += i.left + i.right;
}
- Insets i = slider.getInsets();
- d.width += i.left + i.right;
- d.height += i.top + i.bottom;
return d;
}
--- a/jdk/src/java.desktop/share/classes/javax/swing/table/JTableHeader.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/table/JTableHeader.java Tue Apr 14 12:10:00 2015 -0700
@@ -439,6 +439,26 @@
return tip;
}
+ /**
+ * Returns the preferred size of the table header.
+ * This is the size required to display the header and requested for
+ * the viewport.
+ * The returned {@code Dimension} {@code width} will always be calculated by
+ * the underlying TableHeaderUI, regardless of any width specified by
+ * {@link JComponent#setPreferredSize(java.awt.Dimension)}
+ *
+ * @return the size
+ */
+ @Override
+ public Dimension getPreferredSize() {
+ Dimension preferredSize = super.getPreferredSize();
+ if (isPreferredSizeSet() && ui != null) {
+ Dimension size = ui.getPreferredSize(this);
+ if (size != null) preferredSize.width = size.width;
+ }
+ return preferredSize;
+ }
+
//
// Managing TableHeaderUI
//
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.c Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.c Tue Apr 14 12:10:00 2015 -0700
@@ -368,9 +368,9 @@
if (length > CONV_BUFFER_SIZE-1)
{
length = CONV_BUFFER_SIZE-1;
-#ifdef INTERNAL_BUILD
+#ifdef DEBUG
fprintf(stderr, "Note: Detail is too long: %d chars\n", length);
-#endif /* INTERNAL_BUILD */
+#endif /* DEBUG */
}
(*env)->GetStringUTFRegion(env, val, 0, length, convertionBuffer);
@@ -507,9 +507,9 @@
}
}
} else {
-#ifdef INTERNAL_BUILD
+#ifdef DEBUG
fprintf(stderr, "Cannot load g_vfs_get_supported_uri_schemes\n");
-#endif /* INTERNAL_BUILD */
+#endif /* DEBUG */
}
}
@@ -522,23 +522,23 @@
const char *gtk_version = fp_gtk_check_version(2, 14, 0);
if (gtk_version != NULL) {
// The gtk_show_uri is available from GTK+ 2.14
-#ifdef INTERNAL_BUILD
+#ifdef DEBUG
fprintf (stderr, "The version of GTK is %s. "
"The gtk_show_uri function is supported "
"since GTK+ 2.14.\n", gtk_version);
-#endif /* INTERNAL_BUILD */
+#endif /* DEBUG */
} else {
// Loading symbols only if the GTK version is 2.14 and higher
fp_gtk_show_uri = dl_symbol("gtk_show_uri");
const char *dlsym_error = dlerror();
if (dlsym_error) {
-#ifdef INTERNAL_BUILD
+#ifdef DEBUG
fprintf (stderr, "Cannot load symbol: %s \n", dlsym_error);
-#endif /* INTERNAL_BUILD */
+#endif /* DEBUG */
} else if (fp_gtk_show_uri == NULL) {
-#ifdef INTERNAL_BUILD
+#ifdef DEBUG
fprintf(stderr, "dlsym(gtk_show_uri) returned NULL\n");
-#endif /* INTERNAL_BUILD */
+#endif /* DEBUG */
} else {
update_supported_actions(env);
success = TRUE;
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/XlibWrapper.c Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/XlibWrapper.c Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -49,7 +49,7 @@
#include <X11/XKBlib.h>
-#if defined(DEBUG) || defined(INTERNAL_BUILD)
+#if defined(DEBUG)
static jmethodID lockIsHeldMID = NULL;
static void
@@ -2346,4 +2346,3 @@
(*env)->ReleaseIntArrayElements(env, bitmap, values, JNI_ABORT);
}
-
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/gnome_interface.c Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/gnome_interface.c Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -42,7 +42,7 @@
// we are trying to load the library without a version suffix
vfs_handle = dlopen(JNI_LIB_NAME("gnomevfs-2"), RTLD_LAZY);
if (vfs_handle == NULL) {
- #ifdef INTERNAL_BUILD
+ #ifdef DEBUG
fprintf(stderr, "can not load libgnomevfs-2.so\n");
#endif
return FALSE;
@@ -51,13 +51,13 @@
dlerror(); /* Clear errors */
gnome_vfs_init = (GNOME_VFS_INIT_TYPE*)dlsym(vfs_handle, "gnome_vfs_init");
if (gnome_vfs_init == NULL){
- #ifdef INTERNAL_BUILD
+ #ifdef DEBUG
fprintf(stderr, "dlsym( gnome_vfs_init) returned NULL\n");
#endif
return FALSE;
}
if ((errmsg = dlerror()) != NULL) {
- #ifdef INTERNAL_BUILD
+ #ifdef DEBUG
fprintf(stderr, "can not find symbol gnome_vfs_init %s \n", errmsg);
#endif
return FALSE;
@@ -69,7 +69,7 @@
if (gnome_handle == NULL) {
gnome_handle = dlopen(JNI_LIB_NAME("gnome-2"), RTLD_LAZY);
if (gnome_handle == NULL) {
- #ifdef INTERNAL_BUILD
+ #ifdef DEBUG
fprintf(stderr, "can not load libgnome-2.so\n");
#endif
return FALSE;
@@ -78,7 +78,7 @@
dlerror(); /* Clear errors */
gnome_url_show = (GNOME_URL_SHOW_TYPE*)dlsym(gnome_handle, "gnome_url_show");
if ((errmsg = dlerror()) != NULL) {
- #ifdef INTERNAL_BUILD
+ #ifdef DEBUG
fprintf(stderr, "can not find symble gnome_url_show\n");
#endif
return FALSE;
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt.h Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt.h Tue Apr 14 12:10:00 2015 -0700
@@ -228,7 +228,7 @@
/*
* checks if the current thread is/isn't the toolkit thread
*/
-#if defined(DEBUG) || defined(INTERNAL_BUILD)
+#if defined(DEBUG)
#define CHECK_IS_TOOLKIT_THREAD() \
if (GetCurrentThreadId() != AwtToolkit::MainThread()) \
{ JNU_ThrowInternalError(env,"Operation is not permitted on non-toolkit thread!\n"); }
--- a/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@
import java.security.*;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import sun.misc.JavaAWTAccess;
import sun.misc.SharedSecrets;
@@ -579,7 +580,8 @@
// added in the user context.
class LoggerContext {
// Table of named Loggers that maps names to Loggers.
- private final Hashtable<String,LoggerWeakRef> namedLoggers = new Hashtable<>();
+ private final ConcurrentHashMap<String,LoggerWeakRef> namedLoggers =
+ new ConcurrentHashMap<>();
// Tree of named Loggers
private final LogNode root;
private LoggerContext() {
@@ -642,21 +644,44 @@
}
- synchronized Logger findLogger(String name) {
- // ensure that this context is properly initialized before
- // looking for loggers.
- ensureInitialized();
+ Logger findLogger(String name) {
+ // Attempt to find logger without locking.
LoggerWeakRef ref = namedLoggers.get(name);
- if (ref == null) {
- return null;
+ Logger logger = ref == null ? null : ref.get();
+
+ // if logger is not null, then we can return it right away.
+ // if name is "" or "global" and logger is null
+ // we need to fall through and check that this context is
+ // initialized.
+ // if ref is not null and logger is null we also need to
+ // fall through.
+ if (logger != null || (ref == null && !name.isEmpty()
+ && !name.equals(Logger.GLOBAL_LOGGER_NAME))) {
+ return logger;
}
- Logger logger = ref.get();
- if (logger == null) {
- // Hashtable holds stale weak reference
- // to a logger which has been GC-ed.
- ref.dispose();
+
+ // We either found a stale reference, or we were looking for
+ // "" or "global" and didn't find them.
+ // Make sure context is initialized (has the default loggers),
+ // and look up again, cleaning the stale reference if it hasn't
+ // been cleaned up in between. All this needs to be done inside
+ // a synchronized block.
+ synchronized(this) {
+ // ensure that this context is properly initialized before
+ // looking for loggers.
+ ensureInitialized();
+ ref = namedLoggers.get(name);
+ if (ref == null) {
+ return null;
+ }
+ logger = ref.get();
+ if (logger == null) {
+ // The namedLoggers map holds stale weak reference
+ // to a logger which has been GC-ed.
+ ref.dispose();
+ }
+ return logger;
}
- return logger;
}
// This method is called before adding a logger to the
@@ -752,7 +777,6 @@
final LogManager owner = getOwner();
logger.setLogManager(owner);
ref = owner.new LoggerWeakRef(logger);
- namedLoggers.put(name, ref);
// Apply any initial level defined for the new logger, unless
// the logger's level is already initialized
@@ -789,10 +813,17 @@
node.walkAndSetParent(logger);
// new LogNode is ready so tell the LoggerWeakRef about it
ref.setNode(node);
+
+ // Do not publish 'ref' in namedLoggers before the logger tree
+ // is fully updated - because the named logger will be visible as
+ // soon as it is published in namedLoggers (findLogger takes
+ // benefit of the ConcurrentHashMap implementation of namedLoggers
+ // to avoid synchronizing on retrieval when that is possible).
+ namedLoggers.put(name, ref);
return true;
}
- synchronized void removeLoggerRef(String name, LoggerWeakRef ref) {
+ void removeLoggerRef(String name, LoggerWeakRef ref) {
namedLoggers.remove(name, ref);
}
@@ -800,7 +831,7 @@
// ensure that this context is properly initialized before
// returning logger names.
ensureInitialized();
- return namedLoggers.keys();
+ return Collections.enumeration(namedLoggers.keySet());
}
// If logger.getUseParentHandlers() returns 'true' and any of the logger's
@@ -1379,7 +1410,19 @@
reset();
// Load the properties
- props.load(ins);
+ try {
+ props.load(ins);
+ } catch (IllegalArgumentException x) {
+ // props.load may throw an IllegalArgumentException if the stream
+ // contains malformed Unicode escape sequences.
+ // We wrap that in an IOException as readConfiguration is
+ // specified to throw IOException if there are problems reading
+ // from the stream.
+ // Note: new IOException(x.getMessage(), x) allow us to get a more
+ // concise error message than new IOException(x);
+ throw new IOException(x.getMessage(), x);
+ }
+
// Instantiate new configuration objects.
String names[] = parseClassNames("config");
--- a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSContext.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSContext.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -104,7 +104,7 @@
* operations on the <code>GSSContext</code> object are presented,
* including: object instantiation, setting of desired flags, context
* establishment, query of actual context flags, per-message operations on
- * application data, and finally context deletion.<p>
+ * application data, and finally context deletion.
*
* <pre>
* // Create a context using default credentials
@@ -209,7 +209,7 @@
* Some mechanism providers might require that the caller be granted
* permission to initiate a security context. A failed permission check
* might cause a {@link java.lang.SecurityException SecurityException}
- * to be thrown from this method.<p>
+ * to be thrown from this method.
*
* @return a byte[] containing the token to be sent to the
* peer. <code>null</code> indicates that no token is generated.
@@ -276,7 +276,7 @@
* to be thrown from this method.<p>
*
* The following example code demonstrates how this method might be
- * used:<p>
+ * used:
* <pre>
* InputStream is ...
* OutputStream os ...
@@ -346,7 +346,7 @@
* to be thrown from this method.<p>
*
* The following example code demonstrates how this method might be
- * used:<p>
+ * used:
* <pre>
* byte[] inToken;
* byte[] outToken;
@@ -423,7 +423,7 @@
* to be thrown from this method.<p>
*
* The following example code demonstrates how this method might be
- * used:<p>
+ * used:
* <pre>
* InputStream is ...
* OutputStream os ...
@@ -510,7 +510,7 @@
* GSS-API implementations are recommended but not required to detect
* invalid QOP values when <code>getWrapSizeLimit</code> is called.
* This routine guarantees only a maximum message size, not the
- * availability of specific QOP values for message protection.<p>
+ * availability of specific QOP values for message protection.
*
* @param qop the level of protection wrap will be asked to provide.
* @param confReq <code>true</code> if wrap will be asked to provide
@@ -595,7 +595,7 @@
*
* Since some application-level protocols may wish to use tokens
* emitted by wrap to provide "secure framing", implementations should
- * support the wrapping of zero-length messages.<p>
+ * support the wrapping of zero-length messages.
*
* @param inStream an InputStream containing the application data to be
* protected. All of the data that is available in
@@ -630,7 +630,7 @@
*
* Since some application-level protocols may wish to use tokens
* emitted by wrap to provide "secure framing", implementations should
- * support the wrapping and unwrapping of zero-length messages.<p>
+ * support the wrapping and unwrapping of zero-length messages.
*
* @param inBuf a byte array containing the wrap token received from
* peer.
@@ -679,7 +679,7 @@
*
* Other than the possible blocking behavior described above, this
* method is equivalent to the byte array based {@link #unwrap(byte[],
- * int, int, MessageProp) unwrap} method.<p>
+ * int, int, MessageProp) unwrap} method.
*
* @param inStream an InputStream that contains the wrap token generated
* by the peer.
@@ -827,7 +827,7 @@
*
* Other than the possible blocking behavior described above, this
* method is equivalent to the byte array based {@link #verifyMIC(byte[],
- * int, int, byte[], int, int, MessageProp) verifyMIC} method.<p>
+ * int, int, byte[], int, int, MessageProp) verifyMIC} method.
*
* @param tokStream an InputStream containing the token generated by the
* peer's getMIC method.
@@ -913,7 +913,7 @@
* might require mutual authentication even if the application
* doesn't. Therefore, the application should check to see if the
* request was honored with the {@link #getMutualAuthState()
- * getMutualAuthState} method.<p>
+ * getMutualAuthState} method.
*
* @param state a boolean value indicating whether mutual
* authentication should be used or not.
@@ -943,7 +943,7 @@
* MessageProp#isOldToken() MessageProp.isOldToken} methods will return
* valid results for the <code>MessageProp</code> object that is passed
* in to the <code>unwrap</code> method or the <code>verifyMIC</code>
- * method.<p>
+ * method.
*
* @param state a boolean value indicating whether replay detection
* should be enabled over the established context or not.
@@ -975,7 +975,7 @@
* {@link MessageProp#isGapToken() MessageProp.isGapToken} methods will return
* valid results for the <code>MessageProp</code> object that is passed
* in to the <code>unwrap</code> method or the <code>verifyMIC</code>
- * method.<p>
+ * method.
*
* @param state a boolean value indicating whether sequence checking
* should be enabled over the established context or not.
@@ -1001,7 +1001,7 @@
* delegation must not be used, then the mechanism will honor the
* request and delegation will not occur. This is an exception
* to the general rule that a mechanism may enable a service even if it
- * is not requested.<p>
+ * is not requested.
*
* @param state a boolean value indicating whether the credentials
* should be delegated or not.
@@ -1021,7 +1021,7 @@
*
* Not all mechanisms support anonymity for the initiator. Therefore, the
* application should check to see if the request was honored with the
- * {@link #getAnonymityState() getAnonymityState} method.<p>
+ * {@link #getAnonymityState() getAnonymityState} method.
*
* @param state a boolean value indicating if the initiator should
* be authenticated to the acceptor as an anonymous principal.
@@ -1048,7 +1048,7 @@
* object that is passed in to the <code>wrap</code> method.<p>
*
* Enabling confidentiality will also automatically enable
- * integrity.<p>
+ * integrity.
*
* @param state a boolean value indicating whether confidentiality
* should be enabled or not.
@@ -1075,7 +1075,7 @@
* the {@link #getIntegState() getIntegState} method.<p>
*
* Disabling integrity will also automatically disable
- * confidentiality.<p>
+ * confidentiality.
*
* @param state a boolean value indicating whether integrity
* should be enabled or not.
@@ -1095,7 +1095,7 @@
*
* The actual lifetime of the context will depend on the capabilities of
* the underlying mechanism and the application should call the {@link
- * #getLifetime() getLifetime} method to determine this.<p>
+ * #getLifetime() getLifetime} method to determine this.
*
* @param lifetime the desired context lifetime in seconds. Use
* <code>INDEFINITE_LIFETIME</code> to request an indefinite lifetime
@@ -1133,7 +1133,7 @@
* initiator requests that delegation not be allowed the {@link
* #requestCredDeleg(boolean) requestCredDeleg} method will honor that
* request and this method will return <code>false</code> on the
- * initiator's side from that point onwards. <p>
+ * initiator's side from that point onwards.
*
* @return true if delegation is enabled, false otherwise.
* @see #requestCredDeleg(boolean)
@@ -1147,7 +1147,7 @@
* called only after context establishment is complete. An initiator
* that requests mutual authentication can call this method after
* context completion and dispose the context if its request was not
- * honored.<p>
+ * honored.
*
* @return true if mutual authentication is enabled, false otherwise.
* @see #requestMutualAuth(boolean)
@@ -1161,7 +1161,7 @@
* definitive answer this method must be called only after context
* establishment is complete. An initiator that requests replay
* detection can call this method after context completion and
- * dispose the context if its request was not honored.<p>
+ * dispose the context if its request was not honored.
*
* @return true if replay detection is enabled, false otherwise.
* @see #requestReplayDet(boolean)
@@ -1175,7 +1175,7 @@
* definitive answer this method must be called only after context
* establishment is complete. An initiator that requests sequence
* checking can call this method after context completion and
- * dispose the context if its request was not honored.<p>
+ * dispose the context if its request was not honored.
*
* @return true if sequence checking is enabled, false otherwise.
* @see #requestSequenceDet(boolean)
@@ -1195,7 +1195,7 @@
* should be sent to the peer or the context aborted.</strong> On the
* acceptor side, a call to this method determines if any of the tokens
* processed by <code>acceptSecContext</code> thus far have divulged
- * the identity of the initiator.<p>
+ * the identity of the initiator.
*
* @return true if the context initiator is still anonymous, false
* otherwise.
@@ -1235,7 +1235,7 @@
* #isProtReady() isProtReady} or {@link #isEstablished()
* isEstablished} return <code>true</code>. If this method returns
* <code>true</code>, so will {@link #getIntegState()
- * getIntegState}<p>
+ * getIntegState}
*
* @return true if confidentiality services are available, false
* otherwise.
@@ -1250,7 +1250,7 @@
* #isProtReady() isProtReady} or {@link #isEstablished()
* isEstablished} return <code>true</code>. This method will always
* return <code>true</code> if {@link #getConfState() getConfState}
- * returns true.<p>
+ * returns true.
*
* @return true if integrity services are available, false otherwise.
* @see #requestInteg(boolean)
@@ -1262,7 +1262,7 @@
* context is. It can be called by both the context initiator and the
* context acceptor, but for a definitive answer it should be called
* only after {@link #isEstablished() isEstablished} returns
- * true.<p>
+ * true.
*
* @return the remaining lifetime in seconds
* @see #requestLifetime(int)
--- a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSCredential.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSCredential.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -57,7 +57,7 @@
*
* This example code demonstrates the creation of a GSSCredential
* implementation for a specific entity, querying of its fields, and its
- * release when it is no longer needed:<p>
+ * release when it is no longer needed:
* <pre>
* GSSManager manager = GSSManager.getInstance();
*
--- a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSException.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSException.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -34,7 +34,7 @@
* mechanism implementation is responsible for setting appropriate minor
* status codes when throwing this exception. Aside from delivering the
* numeric error codes to the caller, this class performs the mapping from
- * their numeric values to textual representations. <p>
+ * their numeric values to textual representations.
*
* @author Mayank Upadhyay
* @since 1.4
--- a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSManager.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSManager.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -55,7 +55,7 @@
* of this and recover cleanly by catching the exception.<p>
*
* It is envisioned that there will be three most common ways in which
- * providers will be used:<p>
+ * providers will be used:
* <ol>
* <li> The application does not care about what provider is used (the
* default case).
@@ -87,7 +87,7 @@
* the <code>addProviderAtFront</code> method on a GSSManager that has
* already created an object.<p>
*
- * Here is some sample code showing how the GSSManager might be used: <p>
+ * Here is some sample code showing how the GSSManager might be used:
* <pre>
* GSSManager manager = GSSManager.getInstance();
*
@@ -116,7 +116,7 @@
* GSSContext.DEFAULT_LIFETIME);
* </pre><p>
*
- * The server side might use the following variation of this source:<p>
+ * The server side might use the following variation of this source:
*
* <pre>
* // Acquire credentials for the server
@@ -387,7 +387,7 @@
* Non-default values for lifetime cannot always be honored by the
* underlying mechanisms, thus applications should be prepared to call
* {@link GSSCredential#getRemainingLifetime() getRemainingLifetime}
- * on the returned credential.<p>
+ * on the returned credential.
*
* @param name the name of the principal for whom this credential is to be
* acquired. Use <code>null</code> to specify the default principal.
@@ -442,7 +442,7 @@
* Non-default values for lifetime cannot always be honored by the
* underlying mechanisms, thus applications should be prepared to call
* {@link GSSCredential#getRemainingLifetime() getRemainingLifetime}
- * on the returned credential.<p>
+ * on the returned credential.
*
* @param name the name of the principal for whom this credential is to
* be acquired. Use <code>null</code> to specify the default
@@ -492,7 +492,7 @@
* Non-default values for lifetime cannot always be honored by the
* underlying mechanism, thus applications should be prepared to call
* {@link GSSContext#getLifetime() getLifetime} on the returned
- * context.<p>
+ * context.
*
* @param peer the name of the target peer.
* @param mech the Oid of the desired mechanism. Use <code>null</code>
@@ -610,7 +610,7 @@
* operation is unavailable.<p>
*
* Suppose an application desired that the provider A always be checked
- * first when any mechanism is needed, it would call:<p>
+ * first when any mechanism is needed, it would call:
* <pre>
* GSSManager mgr = GSSManager.getInstance();
* // mgr may at this point have its own pre-configured list
@@ -621,7 +621,7 @@
* </pre>
* Now if it also desired that the mechanism of Oid m1 always be
* obtained from the provider B before the previously set A was checked,
- * it would call:<p>
+ * it would call:
* <pre>
* mgr.addProviderAtFront(B, m1);
* </pre>
@@ -632,7 +632,7 @@
* directly.<p>
*
* Suppose at a later time the following call is made to the same
- * GSSManager instance:<p>
+ * GSSManager instance:
* <pre>
* mgr.addProviderAtFront(B, null)
* </pre>
@@ -684,14 +684,14 @@
* Suppose an application desired that when a mechanism of Oid m1 is
* needed the system default providers always be checked first, and only
* when they do not support m1 should a provider A be checked. It would
- * then make the call:<p>
+ * then make the call:
* <pre>
* GSSManager mgr = GSSManager.getInstance();
* mgr.addProviderAtEnd(A, m1);
* </pre>
* Now, if it also desired that for all mechanisms the provider B be
* checked after all configured providers have been checked, it would
- * then call:<p>
+ * then call:
* <pre>
* mgr.addProviderAtEnd(B, null);
* </pre>
@@ -699,7 +699,7 @@
* null)}.<p>
*
* Suppose at a later time the following call is made to the same
- * GSSManager instance:<p>
+ * GSSManager instance:
* <pre>
* mgr.addProviderAtEnd(B, m2)
* </pre>
@@ -708,7 +708,7 @@
* request is made for the already existing pairs of (A, m1) or (B,
* null).<p>
*
- * Please note, however, that the following call:<p>
+ * Please note, however, that the following call:
* <pre>
* mgr.addProviderAtEnd(A, null)
* </pre>
--- a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSName.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/GSSName.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -48,7 +48,7 @@
* The code below creates a <code>GSSName</code>, converts it to an MN, performs a
* comparison, obtains a printable representation of the name, exports it
* to a byte array and then re-imports to obtain a
- * new <code>GSSName</code>.<p>
+ * new <code>GSSName</code>.
* <pre>
* GSSManager manager = GSSManager.getInstance();
*
@@ -236,7 +236,8 @@
* method {@link GSSManager#createName(byte[], Oid)
* GSSManager.createName} and specifying the NT_EXPORT_NAME as the name
* type object identifier. The resulting <code>GSSName</code> name will
- * also be a MN.<p>
+ * also be a MN.
+ *
* @return a byte[] containing the exported name. RFC 2743 defines the
* "Mechanism-Independent Exported Name Object Format" for these bytes.
*
--- a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/MessageProp.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/MessageProp.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -42,7 +42,7 @@
* <code>false</code>. Upon return from these methods, this object will also
* contain any supplementary status values applicable to the processed
* token. The supplementary status values can indicate old tokens, out
- * of sequence tokens, gap tokens or duplicate tokens.<p>
+ * of sequence tokens, gap tokens or duplicate tokens.
*
* @see GSSContext#wrap
* @see GSSContext#unwrap
--- a/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/package.html Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/java.security.jgss/share/classes/org/ietf/jgss/package.html Tue Apr 14 12:10:00 2015 -0700
@@ -2,7 +2,7 @@
<html>
<head>
<!--
-Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
@@ -55,10 +55,10 @@
The GSS-API does not perform any communication with the peer. It merely
produces tokens that the application must somehow transport to the
- other end.<p>
+ other end.
<h3>Credential Acquisition</h3>
-<a name=useSubjectCredsOnly>
+<a name=useSubjectCredsOnly></a>
The GSS-API itself does not dictate how an underlying mechanism
obtains the credentials that are needed for authentication. It is
assumed that prior to calling the GSS-API, these credentials are
@@ -97,7 +97,6 @@
the provider is free to use any credentials cache of its choice. Such
a credential cache might be a disk cache, an in-memory cache, or even
just the current Subject itself.
-</a>
<h2>Related Documentation</h2>
<p>
--- a/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/SessionManager.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/SessionManager.java Tue Apr 14 12:10:00 2015 -0700
@@ -90,6 +90,7 @@
// maximum number of active sessions during this invocation, for debugging
private int maxActiveSessions;
+ private Object maxActiveSessionsLock;
// flags to use in the C_OpenSession() call
private final long openSessionFlags;
@@ -113,6 +114,9 @@
this.token = token;
this.objSessions = new Pool(this);
this.opSessions = new Pool(this);
+ if (debug != null) {
+ maxActiveSessionsLock = new Object();
+ }
}
// returns whether only a fairly low number of sessions are
@@ -212,7 +216,7 @@
Session session = new Session(token, id);
activeSessions.incrementAndGet();
if (debug != null) {
- synchronized(this) {
+ synchronized(maxActiveSessionsLock) {
if (activeSessions.get() > maxActiveSessions) {
maxActiveSessions = activeSessions.get();
if (maxActiveSessions % 10 == 0) {
--- a/jdk/src/jdk.dev/share/classes/jdk/tools/jimage/JImageTask.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/jdk.dev/share/classes/jdk/tools/jimage/JImageTask.java Tue Apr 14 12:10:00 2015 -0700
@@ -269,11 +269,11 @@
return 0L;
}
- String name = pathString.substring(chop).replace('\\','/');
-
File file = path.toFile();
if (file.isFile()) {
+ String name = pathString.substring(chop).replace(File.separatorChar, '/');
+
if (options.verbose) {
log.println(name);
}
@@ -310,7 +310,7 @@
for (File file : files) {
try {
Path path = file.toPath();
- String name = path.toString();
+ String name = path.toString().replace(File.separatorChar, '/');
if (name.endsWith(MODULES_ENTRY) || name.endsWith(PACKAGES_ENTRY)) {
for (String line: Files.readAllLines(path)) {
--- a/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipConstants.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipConstants.java Tue Apr 14 12:10:00 2015 -0700
@@ -184,10 +184,19 @@
return (LG(b, n)) | (LG(b, n + 4) << 32);
}
- static final long GETSIG(byte[] b) {
- return LG(b, 0);
+ static long getSig(byte[] b, int n) { return LG(b, n); }
+
+ private static boolean pkSigAt(byte[] b, int n, int b1, int b2) {
+ return b[n] == 'P' & b[n + 1] == 'K' & b[n + 2] == b1 & b[n + 3] == b2;
}
+ static boolean cenSigAt(byte[] b, int n) { return pkSigAt(b, n, 1, 2); }
+ static boolean locSigAt(byte[] b, int n) { return pkSigAt(b, n, 3, 4); }
+ static boolean endSigAt(byte[] b, int n) { return pkSigAt(b, n, 5, 6); }
+ static boolean extSigAt(byte[] b, int n) { return pkSigAt(b, n, 7, 8); }
+ static boolean end64SigAt(byte[] b, int n) { return pkSigAt(b, n, 6, 6); }
+ static boolean locator64SigAt(byte[] b, int n) { return pkSigAt(b, n, 6, 7); }
+
// local file (LOC) header fields
static final long LOCSIG(byte[] b) { return LG(b, 0); } // signature
static final int LOCVER(byte[] b) { return SH(b, 4); } // version needed to extract
--- a/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java Tue Apr 14 12:10:00 2015 -0700
@@ -1060,7 +1060,7 @@
int pos = 0;
int limit = cen.length - ENDHDR;
while (pos < limit) {
- if (CENSIG(cen, pos) != CENSIG)
+ if (!cenSigAt(cen, pos))
zerror("invalid CEN header (bad signature)");
int method = CENHOW(cen, pos);
int nlen = CENNAM(cen, pos);
@@ -1894,7 +1894,7 @@
throws IOException
{
byte[] cen = zipfs.cen;
- if (CENSIG(cen, pos) != CENSIG)
+ if (!cenSigAt(cen, pos))
zerror("invalid CEN header (bad signature)");
versionMade = CENVEM(cen, pos);
version = CENVER(cen, pos);
@@ -2057,9 +2057,9 @@
assert (buf.length >= LOCHDR);
if (zipfs.readFullyAt(buf, 0, LOCHDR , pos) != LOCHDR)
throw new ZipException("loc: reading failed");
- if (LOCSIG(buf) != LOCSIG)
+ if (!locSigAt(buf, 0))
throw new ZipException("loc: wrong sig ->"
- + Long.toString(LOCSIG(buf), 16));
+ + Long.toString(getSig(buf, 0), 16));
//startPos = pos;
version = LOCVER(buf);
flag = LOCFLG(buf);
@@ -2271,6 +2271,8 @@
}
break;
case EXTID_NTFS:
+ if (sz < 32)
+ break;
pos += 4; // reserved 4 bytes
if (SH(extra, pos) != 0x0001)
break;
@@ -2289,9 +2291,9 @@
if (zipfs.readFullyAt(buf, 0, buf.length , locoff)
!= buf.length)
throw new ZipException("loc: reading failed");
- if (LOCSIG(buf) != LOCSIG)
+ if (!locSigAt(buf, 0))
throw new ZipException("loc: wrong sig ->"
- + Long.toString(LOCSIG(buf), 16));
+ + Long.toString(getSig(buf, 0), 16));
int locElen = LOCEXT(buf);
if (locElen < 9) // EXTT is at lease 9 bytes
--- a/jdk/test/ProblemList.txt Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/test/ProblemList.txt Tue Apr 14 12:10:00 2015 -0700
@@ -251,6 +251,64 @@
# 8026393
sun/security/tools/jarsigner/warnings/BadKeyUsageTest.java generic-all
+# 8077138: Some PKCS11 tests fail because NSS library is not initialized
+sun/security/pkcs11/Cipher/ReinitCipher.java windows-all
+sun/security/pkcs11/Cipher/TestPKCS5PaddingError.java windows-all
+sun/security/pkcs11/Cipher/TestRSACipher.java windows-all
+sun/security/pkcs11/Cipher/TestRSACipherWrap.java windows-all
+sun/security/pkcs11/Cipher/TestRawRSACipher.java windows-all
+sun/security/pkcs11/Cipher/TestSymmCiphers.java windows-all
+sun/security/pkcs11/Cipher/TestSymmCiphersNoPad.java windows-all
+sun/security/pkcs11/KeyAgreement/TestDH.java windows-all
+sun/security/pkcs11/KeyAgreement/TestInterop.java windows-all
+sun/security/pkcs11/KeyAgreement/TestShort.java windows-all
+sun/security/pkcs11/KeyGenerator/DESParity.java windows-all
+sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java windows-all
+sun/security/pkcs11/KeyPairGenerator/TestDH2048.java windows-all
+sun/security/pkcs11/KeyStore/SecretKeysBasic.sh windows-all
+sun/security/pkcs11/Mac/MacKAT.java windows-all
+sun/security/pkcs11/Mac/MacSameTest.java windows-all
+sun/security/pkcs11/Mac/ReinitMac.java windows-all
+sun/security/pkcs11/MessageDigest/ByteBuffers.java windows-all
+sun/security/pkcs11/MessageDigest/DigestKAT.java windows-all
+sun/security/pkcs11/MessageDigest/ReinitDigest.java windows-all
+sun/security/pkcs11/MessageDigest/TestCloning.java windows-all
+sun/security/pkcs11/Provider/ConfigQuotedString.sh windows-all
+sun/security/pkcs11/Provider/Login.sh windows-all
+sun/security/pkcs11/SampleTest.java windows-all
+sun/security/pkcs11/Secmod/AddPrivateKey.java windows-all
+sun/security/pkcs11/Secmod/AddTrustedCert.java windows-all
+sun/security/pkcs11/Secmod/Crypto.java windows-all
+sun/security/pkcs11/Secmod/GetPrivateKey.java windows-all
+sun/security/pkcs11/Secmod/JksSetPrivateKey.java windows-all
+sun/security/pkcs11/SecureRandom/Basic.java windows-all
+sun/security/pkcs11/SecureRandom/TestDeserialization.java windows-all
+sun/security/pkcs11/Serialize/SerializeProvider.java windows-all
+sun/security/pkcs11/Signature/ByteBuffers.java windows-all
+sun/security/pkcs11/Signature/ReinitSignature.java windows-all
+sun/security/pkcs11/Signature/TestDSA.java windows-all
+sun/security/pkcs11/Signature/TestDSAKeyLength.java windows-all
+sun/security/pkcs11/Signature/TestRSAKeyLength.java windows-all
+sun/security/pkcs11/ec/ReadCertificates.java windows-all
+sun/security/pkcs11/ec/ReadPKCS12.java windows-all
+sun/security/pkcs11/ec/TestCurves.java windows-all
+sun/security/pkcs11/ec/TestECDH.java windows-all
+sun/security/pkcs11/ec/TestECDH2.java windows-all
+sun/security/pkcs11/ec/TestECDSA.java windows-all
+sun/security/pkcs11/ec/TestECDSA2.java windows-all
+sun/security/pkcs11/ec/TestECGenSpec.java windows-all
+sun/security/pkcs11/rsa/KeyWrap.java windows-all
+sun/security/pkcs11/rsa/TestCACerts.java windows-all
+sun/security/pkcs11/rsa/TestKeyFactory.java windows-all
+sun/security/pkcs11/rsa/TestKeyPairGenerator.java windows-all
+sun/security/pkcs11/rsa/TestSignatures.java windows-all
+sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java windows-all
+sun/security/pkcs11/tls/TestKeyMaterial.java windows-all
+sun/security/pkcs11/tls/TestLeadingZeroesP11.java windows-all
+sun/security/pkcs11/tls/TestMasterSecret.java windows-all
+sun/security/pkcs11/tls/TestPRF.java windows-all
+sun/security/pkcs11/tls/TestPremaster.java windows-all
+
############################################################################
# jdk_sound
--- a/jdk/test/TEST.groups Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/test/TEST.groups Tue Apr 14 12:10:00 2015 -0700
@@ -453,7 +453,6 @@
java/util/jar/JarInputStream/ExtraFileInMetaInf.java \
java/util/logging/TestLoggerWeakRefLeak.java \
java/util/zip/3GBZipFiles.sh \
- jdk/lambda/FDTest.java \
jdk/lambda/separate/Compiler.java \
sun/management/jmxremote/bootstrap/JvmstatCountersTest.java \
sun/management/jmxremote/bootstrap/LocalManagementTest.java \
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/ModalExcludedWindowClickTest/ModalExcludedWindowClickTest.html Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,43 @@
+<!--
+ Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+ This code is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License version 2 only, as
+ published by the Free Software Foundation.
+
+ This code is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ version 2 for more details (a copy is included in the LICENSE file that
+ accompanied this code).
+
+ You should have received a copy of the GNU General Public License version
+ 2 along with this work; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ or visit www.oracle.com if you need additional information or have any
+ questions.
+-->
+
+<html>
+<!--
+ @test
+ @bug 6271849
+ @summary Tests that component in modal excluded Window which parent is blocked responses to mouse clicks.
+ @author anton.tarasov@sun.com: area=awt.focus
+ @run applet ModalExcludedWindowClickTest.html
+ -->
+<head>
+<title>ModalExcludedWindowClickTest</title>
+</head>
+<body>
+
+<h1>ModalExcludedWindowClickTest<br>Bug ID: 6272324</h1>
+
+<p> See the dialog box (usually in upper left corner) for instructions</p>
+
+<APPLET CODE="ModalExcludedWindowClickTest.class" WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/ModalExcludedWindowClickTest/ModalExcludedWindowClickTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,291 @@
+/*
+ * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ test
+ @bug 6271849
+ @summary Tests that component in modal excluded Window which parent is blocked responses to mouse clicks.
+ @author anton.tarasov@sun.com: area=awt.focus
+ @run applet ModalExcludedWindowClickTest.html
+*/
+
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.reflect.*;
+
+public class ModalExcludedWindowClickTest extends Applet {
+ Robot robot;
+ Frame frame = new Frame("Frame");
+ Window w = new Window(frame);
+ Dialog d = new Dialog ((Dialog)null, "NullParentDialog", true);
+ Button button = new Button("Button");
+ boolean actionPerformed = false;
+
+ public static void main (String args[]) {
+ ModalExcludedWindowClickTest app = new ModalExcludedWindowClickTest();
+ app.init();
+ app.start();
+ }
+
+ public void init() {
+ try {
+ robot = new Robot();
+ } catch (AWTException e) {
+ throw new RuntimeException("Error: unable to create robot", e);
+ }
+ // Create instructions for the user here, as well as set up
+ // the environment -- set the layout manager, add buttons,
+ // etc.
+ this.setLayout (new BorderLayout ());
+ Sysout.createDialogWithInstructions(new String[]
+ {"This is an AUTOMATIC test", "simply wait until it is done"});
+ }
+
+ public void start() {
+
+ if ("sun.awt.motif.MToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName())) {
+ Sysout.println("No testing on MToolkit.");
+ return;
+ }
+
+ button.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ actionPerformed = true;
+ Sysout.println(e.paramString());
+ }
+ });
+
+ EventQueue.invokeLater(new Runnable() {
+ public void run() {
+ frame.setSize(200, 200);
+ frame.setVisible(true);
+
+ w.setModalExclusionType(Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
+ w.add(button);
+ w.setSize(200, 200);
+ w.setLocation(230, 230);
+ w.setVisible(true);
+
+ d.setSize(200, 200);
+ d.setLocation(0, 230);
+ d.setVisible(true);
+
+ }
+ });
+
+ waitTillShown(d);
+
+ test();
+ }
+
+ void test() {
+ clickOn(button);
+ waitForIdle();
+ if (!actionPerformed) {
+ throw new RuntimeException("Test failed!");
+ }
+ Sysout.println("Test passed.");
+ }
+
+ void clickOn(Component c) {
+ Point p = c.getLocationOnScreen();
+ Dimension d = c.getSize();
+
+ Sysout.println("Clicking " + c);
+
+ if (c instanceof Frame) {
+ robot.mouseMove(p.x + (int)(d.getWidth()/2), p.y + ((Frame)c).getInsets().top/2);
+ } else {
+ robot.mouseMove(p.x + (int)(d.getWidth()/2), p.y + (int)(d.getHeight()/2));
+ }
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ waitForIdle();
+ }
+ void waitTillShown(Component c) {
+ while (true) {
+ try {
+ Thread.sleep(100);
+ c.getLocationOnScreen();
+ break;
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalComponentStateException e) {}
+ }
+ }
+ void waitForIdle() {
+ try {
+ robot.waitForIdle();
+ EventQueue.invokeAndWait( new Runnable() {
+ public void run() {} // Dummy implementation
+ });
+ } catch(InterruptedException ie) {
+ Sysout.println("waitForIdle, non-fatal exception caught:");
+ ie.printStackTrace();
+ } catch(InvocationTargetException ite) {
+ Sysout.println("waitForIdle, non-fatal exception caught:");
+ ite.printStackTrace();
+ }
+
+ // wait longer...
+ robot.delay(200);
+ }
+}
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+ chunk of code whose purpose is to make user
+ interaction uniform, and thereby make it simpler
+ to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+ for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+ WithInstructions method. Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+ with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+ as standalone.
+ */
+
+class Sysout
+{
+ static TestDialog dialog;
+
+ public static void createDialogWithInstructions( String[] instructions )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ dialog.printInstructions( instructions );
+ dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+ public static void createDialog( )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ String[] defInstr = { "Instructions will appear here. ", "" } ;
+ dialog.printInstructions( defInstr );
+ dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+
+ public static void printInstructions( String[] instructions )
+ {
+ dialog.printInstructions( instructions );
+ }
+
+
+ public static void println( String messageIn )
+ {
+ dialog.displayMessage( messageIn );
+ }
+
+}// Sysout class
+
+/**
+ This is part of the standard test machinery. It provides a place for the
+ test instructions to be displayed, and a place for interactive messages
+ to the user to be displayed.
+ To have the test instructions displayed, see Sysout.
+ To have a message to the user be displayed, see Sysout.
+ Do not call anything in this dialog directly.
+ */
+class TestDialog extends Dialog
+{
+
+ TextArea instructionsText;
+ TextArea messageText;
+ int maxStringLength = 80;
+
+ //DO NOT call this directly, go through Sysout
+ public TestDialog( Frame frame, String name )
+ {
+ super( frame, name );
+ int scrollBoth = TextArea.SCROLLBARS_BOTH;
+ instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+ add( "North", instructionsText );
+
+ messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+ add("Center", messageText);
+
+ pack();
+
+ setVisible(true);
+ }// TestDialog()
+
+ //DO NOT call this directly, go through Sysout
+ public void printInstructions( String[] instructions )
+ {
+ //Clear out any current instructions
+ instructionsText.setText( "" );
+
+ //Go down array of instruction strings
+
+ String printStr, remainingStr;
+ for( int i=0; i < instructions.length; i++ )
+ {
+ //chop up each into pieces maxSringLength long
+ remainingStr = instructions[ i ];
+ while( remainingStr.length() > 0 )
+ {
+ //if longer than max then chop off first max chars to print
+ if( remainingStr.length() >= maxStringLength )
+ {
+ //Try to chop on a word boundary
+ int posOfSpace = remainingStr.
+ lastIndexOf( ' ', maxStringLength - 1 );
+
+ if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+ printStr = remainingStr.substring( 0, posOfSpace + 1 );
+ remainingStr = remainingStr.substring( posOfSpace + 1 );
+ }
+ //else just print
+ else
+ {
+ printStr = remainingStr;
+ remainingStr = "";
+ }
+
+ instructionsText.append( printStr + "\n" );
+
+ }// while
+
+ }// for
+
+ }//printInstructions()
+
+ //DO NOT call this directly, go through Sysout
+ public void displayMessage( String messageIn )
+ {
+ messageText.append( messageIn + "\n" );
+ System.out.println(messageIn);
+ }
+
+}// TestDialog class
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/NonFocusableBlockedOwnerTest/NonFocusableBlockedOwnerTest.html Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,43 @@
+<!--
+ Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+ This code is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License version 2 only, as
+ published by the Free Software Foundation.
+
+ This code is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ version 2 for more details (a copy is included in the LICENSE file that
+ accompanied this code).
+
+ You should have received a copy of the GNU General Public License version
+ 2 along with this work; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ or visit www.oracle.com if you need additional information or have any
+ questions.
+-->
+
+<html>
+<!--
+ @test
+ @bug 6272324
+ @summary Modal excluded Window which decorated parent is blocked should be non-focusable.
+ @author anton.tarasov@sun.com: area=awt.focus
+ @run applet NonFocusableBlockedOwnerTest.html
+ -->
+<head>
+<title>NonFocusableBlockedOwnerTest</title>
+</head>
+<body>
+
+<h1>NonFocusableBlockedOwnerTest<br>Bug ID: 6272324</h1>
+
+<p> See the dialog box (usually in upper left corner) for instructions</p>
+
+<APPLET CODE="NonFocusableBlockedOwnerTest.class" WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/NonFocusableBlockedOwnerTest/NonFocusableBlockedOwnerTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,288 @@
+/*
+ * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ test
+ @bug 6272324
+ @summary Modal excluded Window which decorated parent is blocked should be non-focusable.
+ @author anton.tarasov@sun.com: area=awt.focus
+ @run applet NonFocusableBlockedOwnerTest.html
+*/
+
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.reflect.*;
+
+public class NonFocusableBlockedOwnerTest extends Applet {
+ Robot robot;
+ Frame frame = new Frame("Modal Blocked Frame");
+ Dialog dialog = new Dialog(frame, "Modal Dialog", true);
+ Window excluded = new Window(frame);
+ Button button = new Button("button");
+
+ public static void main(String[] args) {
+ NonFocusableBlockedOwnerTest app = new NonFocusableBlockedOwnerTest();
+ app.init();
+ app.start();
+ }
+
+ public void init() {
+ try {
+ robot = new Robot();
+ } catch (AWTException e) {
+ throw new RuntimeException("Error: unable to create robot", e);
+ }
+ // Create instructions for the user here, as well as set up
+ // the environment -- set the layout manager, add buttons,
+ // etc.
+ this.setLayout (new BorderLayout ());
+ Sysout.createDialogWithInstructions(new String[]
+ {"This is an AUTOMATIC test", "simply wait until it is done"});
+ }
+
+ public void start() {
+
+ if ("sun.awt.motif.MToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName())) {
+ Sysout.println("No testing on MToolkit.");
+ return;
+ }
+
+ try {
+ EventQueue.invokeLater(new Runnable() {
+ public void run() {
+ frame.setSize(300, 200);
+ frame.setVisible(true);
+
+ excluded.setSize(300, 200);
+ excluded.setLocation(0, 400);
+ excluded.setModalExclusionType(Dialog.ModalExclusionType.TOOLKIT_EXCLUDE);
+ excluded.setLayout(new FlowLayout());
+ excluded.add(button);
+ excluded.setVisible(true);
+
+ dialog.setSize(200, 100);
+ dialog.setLocation(0, 250);
+ dialog.setVisible(true);
+ }
+ });
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ waitTillShown(dialog);
+ clickOn(button);
+ if (frame == KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow()) {
+ throw new RuntimeException("Test failed!");
+ }
+ if (excluded == KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow()) {
+ throw new RuntimeException("Test failed!");
+ }
+ if (button == KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner()) {
+ throw new RuntimeException("Test failed!");
+ }
+ Sysout.println("Test passed.");
+ }
+
+ void clickOn(Component c) {
+ Point p = c.getLocationOnScreen();
+ Dimension d = c.getSize();
+
+ Sysout.println("Clicking " + c);
+
+ if (c instanceof Frame) {
+ robot.mouseMove(p.x + (int)(d.getWidth()/2), p.y + ((Frame)c).getInsets().top/2);
+ } else {
+ robot.mouseMove(p.x + (int)(d.getWidth()/2), p.y + (int)(d.getHeight()/2));
+ }
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ waitForIdle();
+ }
+
+ void waitTillShown(Component c) {
+ while (true) {
+ try {
+ Thread.sleep(100);
+ c.getLocationOnScreen();
+ break;
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalComponentStateException e) {}
+ }
+ }
+ void waitForIdle() {
+ try {
+ robot.waitForIdle();
+ EventQueue.invokeAndWait( new Runnable() {
+ public void run() {} // Dummy implementation
+ });
+ } catch(InterruptedException ie) {
+ Sysout.println("waitForIdle, non-fatal exception caught:");
+ ie.printStackTrace();
+ } catch(InvocationTargetException ite) {
+ Sysout.println("waitForIdle, non-fatal exception caught:");
+ ite.printStackTrace();
+ }
+
+ // wait longer...
+ robot.delay(200);
+ }
+}
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+ chunk of code whose purpose is to make user
+ interaction uniform, and thereby make it simpler
+ to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+ for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+ WithInstructions method. Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+ with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+ as standalone.
+ */
+
+class Sysout
+{
+ static TestDialog dialog;
+
+ public static void createDialogWithInstructions( String[] instructions )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ dialog.printInstructions( instructions );
+ dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+ public static void createDialog( )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ String[] defInstr = { "Instructions will appear here. ", "" } ;
+ dialog.printInstructions( defInstr );
+ dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+
+ public static void printInstructions( String[] instructions )
+ {
+ dialog.printInstructions( instructions );
+ }
+
+
+ public static void println( String messageIn )
+ {
+ dialog.displayMessage( messageIn );
+ }
+
+}// Sysout class
+
+/**
+ This is part of the standard test machinery. It provides a place for the
+ test instructions to be displayed, and a place for interactive messages
+ to the user to be displayed.
+ To have the test instructions displayed, see Sysout.
+ To have a message to the user be displayed, see Sysout.
+ Do not call anything in this dialog directly.
+ */
+class TestDialog extends Dialog
+{
+
+ TextArea instructionsText;
+ TextArea messageText;
+ int maxStringLength = 80;
+
+ //DO NOT call this directly, go through Sysout
+ public TestDialog( Frame frame, String name )
+ {
+ super( frame, name );
+ int scrollBoth = TextArea.SCROLLBARS_BOTH;
+ instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+ add( "North", instructionsText );
+
+ messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+ add("Center", messageText);
+
+ pack();
+
+ setVisible(true);
+ }// TestDialog()
+
+ //DO NOT call this directly, go through Sysout
+ public void printInstructions( String[] instructions )
+ {
+ //Clear out any current instructions
+ instructionsText.setText( "" );
+
+ //Go down array of instruction strings
+
+ String printStr, remainingStr;
+ for( int i=0; i < instructions.length; i++ )
+ {
+ //chop up each into pieces maxSringLength long
+ remainingStr = instructions[ i ];
+ while( remainingStr.length() > 0 )
+ {
+ //if longer than max then chop off first max chars to print
+ if( remainingStr.length() >= maxStringLength )
+ {
+ //Try to chop on a word boundary
+ int posOfSpace = remainingStr.
+ lastIndexOf( ' ', maxStringLength - 1 );
+
+ if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+ printStr = remainingStr.substring( 0, posOfSpace + 1 );
+ remainingStr = remainingStr.substring( posOfSpace + 1 );
+ }
+ //else just print
+ else
+ {
+ printStr = remainingStr;
+ remainingStr = "";
+ }
+
+ instructionsText.append( printStr + "\n" );
+
+ }// while
+
+ }// for
+
+ }//printInstructions()
+
+ //DO NOT call this directly, go through Sysout
+ public void displayMessage( String messageIn )
+ {
+ messageText.append( messageIn + "\n" );
+ System.out.println(messageIn);
+ }
+
+}// TestDialog class
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/WindowUpdateFocusabilityTest/WindowUpdateFocusabilityTest.html Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,43 @@
+<!--
+ Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+ This code is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License version 2 only, as
+ published by the Free Software Foundation.
+
+ This code is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ version 2 for more details (a copy is included in the LICENSE file that
+ accompanied this code).
+
+ You should have received a copy of the GNU General Public License version
+ 2 along with this work; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ or visit www.oracle.com if you need additional information or have any
+ questions.
+-->
+
+<html>
+<!--
+ @test
+ @bug 6253913
+ @summary Tests that a Window shown before its owner is focusable.
+ @author anton.tarasov@sun.com: area=awt-focus
+ @run applet WindowUpdateFocusabilityTest.html
+ -->
+<head>
+<title>WindowUpdateFocusabilityTest</title>
+</head>
+<body>
+
+<h1>WindowUpdateFocusabilityTest<br>Bug ID: 6253913</h1>
+
+<p>See the dialog box (usually in upper left corner) for instructions</p>
+
+<APPLET CODE=WindowUpdateFocusabilityTest.class WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/WindowUpdateFocusabilityTest/WindowUpdateFocusabilityTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,325 @@
+/*
+ * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ test
+ @bug 6253913
+ @summary Tests that a Window shown before its owner is focusable.
+ @author anton.tarasov@sun.com: area=awt-focus
+ @run applet WindowUpdateFocusabilityTest.html
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+import java.applet.Applet;
+import java.lang.reflect.*;
+
+public class WindowUpdateFocusabilityTest extends Applet {
+ Robot robot;
+ boolean focusGained = false;
+ final Object monitor = new Object();
+ FocusListener listener = new FocusAdapter () {
+ public void focusGained(FocusEvent e) {
+ Sysout.println(e.toString());
+ synchronized (monitor) {
+ focusGained = true;
+ monitor.notifyAll();
+ }
+ }
+ };
+
+ public static void main(String[] args) {
+ WindowUpdateFocusabilityTest app = new WindowUpdateFocusabilityTest();
+ app.init();
+ app.start();
+ }
+
+ public void init() {
+ try {
+ robot = new Robot();
+ } catch (AWTException e) {
+ throw new RuntimeException("Error: couldn't create robot");
+ }
+ // Create instructions for the user here, as well as set up
+ // the environment -- set the layout manager, add buttons,
+ // etc.
+ this.setLayout (new BorderLayout ());
+ Sysout.createDialogWithInstructions(new String[]
+ {"This is an automatic test. Simply wait until it's done."});
+ }
+
+ public void start() {
+ if ("sun.awt.motif.MToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName())) {
+ Sysout.println("No testing on Motif.");
+ return;
+ }
+
+ test(new Frame("Frame owner"));
+ Frame dialog_owner = new Frame("dialog's owner");
+ test(new Dialog(dialog_owner));
+ test(new Dialog(dialog_owner, Dialog.ModalityType.DOCUMENT_MODAL));
+ test(new Dialog(dialog_owner, Dialog.ModalityType.APPLICATION_MODAL));
+ test(new Dialog(dialog_owner, Dialog.ModalityType.TOOLKIT_MODAL));
+ test(new Dialog((Window) null, Dialog.ModalityType.MODELESS));
+ test(new Dialog((Window) null, Dialog.ModalityType.DOCUMENT_MODAL));
+ test(new Dialog((Window) null, Dialog.ModalityType.APPLICATION_MODAL));
+ test(new Dialog((Window) null, Dialog.ModalityType.TOOLKIT_MODAL));
+ dialog_owner.dispose();
+ }
+
+ private void test(final Window owner)
+ {
+ Window window0 = new Window(owner); // will not be shown
+ Window window1 = new Window(window0);
+ Window window2 = new Window(window1);
+ Button button1 = new Button("button1");
+ Button button2 = new Button("button2");
+ button1.addFocusListener(listener);
+ button2.addFocusListener(listener);
+
+ owner.setBounds(800, 0, 100, 100);
+ window1.setBounds(800, 300, 100, 100);
+ window2.setBounds(800, 150, 100, 100);
+
+ window1.add(button1);
+ window2.add(button2);
+
+ window2.setVisible(true);
+ window1.setVisible(true);
+ EventQueue.invokeLater(new Runnable() {
+ public void run() {
+ owner.setVisible(true);
+ }
+ });
+
+ try {
+ EventQueue.invokeAndWait(new Runnable() {
+ public void run() {
+ // do nothing just wait until previous invokeLater will be executed
+ }
+ });
+ } catch (InterruptedException ie) {
+ throw new RuntimeException(ie);
+ } catch (InvocationTargetException ite) {
+ throw new RuntimeException(ite);
+ }
+
+ robot.delay(1000);
+
+ clickOn(button1);
+
+ if (!isFocusGained()) {
+ throw new RuntimeException("Test failed: window1 is not focusable!");
+ }
+
+ focusGained = false;
+ clickOn(button2);
+
+ if (!isFocusGained()) {
+ throw new RuntimeException("Test failed: window2 is not focusable!");
+ }
+
+ Sysout.println("Test for " + owner.getName() + " passed.");
+ owner.dispose();
+ }
+
+ void clickOn(Component c) {
+ Point p = c.getLocationOnScreen();
+ Dimension d = c.getSize();
+
+ Sysout.println("Clicking " + c);
+
+ robot.mouseMove(p.x + (int)(d.getWidth()/2), p.y + (int)(d.getHeight()/2));
+
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ waitForIdle();
+ }
+
+ void waitForIdle() {
+ try {
+ robot.waitForIdle();
+ robot.delay(50);
+ EventQueue.invokeAndWait( new Runnable() {
+ public void run() {} // Dummy implementation
+ });
+ } catch(InterruptedException ie) {
+ Sysout.println("waitForIdle, non-fatal exception caught:");
+ ie.printStackTrace();
+ } catch(InvocationTargetException ite) {
+ Sysout.println("waitForIdle, non-fatal exception caught:");
+ ite.printStackTrace();
+ }
+ }
+
+ boolean isFocusGained() {
+ synchronized (monitor) {
+ if (!focusGained) {
+ try {
+ monitor.wait(3000);
+ } catch (InterruptedException e) {
+ Sysout.println("Interrupted unexpectedly!");
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ return focusGained;
+ }
+}
+
+/****************************************************
+ Standard Test Machinery
+ DO NOT modify anything below -- it's a standard
+ chunk of code whose purpose is to make user
+ interaction uniform, and thereby make it simpler
+ to read and understand someone else's test.
+ ****************************************************/
+
+/**
+ This is part of the standard test machinery.
+ It creates a dialog (with the instructions), and is the interface
+ for sending text messages to the user.
+ To print the instructions, send an array of strings to Sysout.createDialog
+ WithInstructions method. Put one line of instructions per array entry.
+ To display a message for the tester to see, simply call Sysout.println
+ with the string to be displayed.
+ This mimics System.out.println but works within the test harness as well
+ as standalone.
+ */
+
+class Sysout
+{
+ static TestDialog dialog;
+
+ public static void createDialogWithInstructions( String[] instructions )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ dialog.printInstructions( instructions );
+ dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+ public static void createDialog( )
+ {
+ dialog = new TestDialog( new Frame(), "Instructions" );
+ String[] defInstr = { "Instructions will appear here. ", "" } ;
+ dialog.printInstructions( defInstr );
+ dialog.setVisible(true);
+ println( "Any messages for the tester will display here." );
+ }
+
+
+ public static void printInstructions( String[] instructions )
+ {
+ dialog.printInstructions( instructions );
+ }
+
+
+ public static void println( String messageIn )
+ {
+ dialog.displayMessage( messageIn );
+ }
+
+}// Sysout class
+
+/**
+ This is part of the standard test machinery. It provides a place for the
+ test instructions to be displayed, and a place for interactive messages
+ to the user to be displayed.
+ To have the test instructions displayed, see Sysout.
+ To have a message to the user be displayed, see Sysout.
+ Do not call anything in this dialog directly.
+ */
+class TestDialog extends Dialog
+{
+
+ TextArea instructionsText;
+ TextArea messageText;
+ int maxStringLength = 80;
+
+ //DO NOT call this directly, go through Sysout
+ public TestDialog( Frame frame, String name )
+ {
+ super( frame, name );
+ int scrollBoth = TextArea.SCROLLBARS_BOTH;
+ instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+ add( "North", instructionsText );
+
+ messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+ add("Center", messageText);
+
+ pack();
+
+ setVisible(true);
+ }// TestDialog()
+
+ //DO NOT call this directly, go through Sysout
+ public void printInstructions( String[] instructions )
+ {
+ //Clear out any current instructions
+ instructionsText.setText( "" );
+
+ //Go down array of instruction strings
+
+ String printStr, remainingStr;
+ for( int i=0; i < instructions.length; i++ )
+ {
+ //chop up each into pieces maxSringLength long
+ remainingStr = instructions[ i ];
+ while( remainingStr.length() > 0 )
+ {
+ //if longer than max then chop off first max chars to print
+ if( remainingStr.length() >= maxStringLength )
+ {
+ //Try to chop on a word boundary
+ int posOfSpace = remainingStr.
+ lastIndexOf( ' ', maxStringLength - 1 );
+
+ if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+ printStr = remainingStr.substring( 0, posOfSpace + 1 );
+ remainingStr = remainingStr.substring( posOfSpace + 1 );
+ }
+ //else just print
+ else
+ {
+ printStr = remainingStr;
+ remainingStr = "";
+ }
+
+ instructionsText.append( printStr + "\n" );
+
+ }// while
+
+ }// for
+
+ }//printInstructions()
+
+ //DO NOT call this directly, go through Sysout
+ public void displayMessage( String messageIn )
+ {
+ messageText.append( messageIn + "\n" );
+ System.out.println(messageIn);
+ }
+
+}// TestDialog class
--- a/jdk/test/java/awt/KeyboardFocusmanager/TypeAhead/TestDialogTypeAhead.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/test/java/awt/KeyboardFocusmanager/TypeAhead/TestDialogTypeAhead.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -192,8 +192,7 @@
}
private void waitForIdle() {
try {
- Toolkit.getDefaultToolkit().sync();
- sun.awt.SunToolkit.flushPendingEvents();
+ robot.waitForIdle();
EventQueue.invokeAndWait( new Runnable() {
public void run() {
// dummy implementation
--- a/jdk/test/java/awt/SplashScreen/MultiResolutionSplash/MultiResolutionSplashTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/test/java/awt/SplashScreen/MultiResolutionSplash/MultiResolutionSplashTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -23,13 +23,16 @@
import java.awt.Color;
import java.awt.Dialog;
+import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Panel;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.SplashScreen;
+import java.awt.TextField;
import java.awt.Window;
+import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
@@ -37,7 +40,7 @@
/**
* @test
- * @bug 8043869
+ * @bug 8043869 8075244
* @author Alexander Scherbatiy
* @summary [macosx] java -splash does not honor 2x hi dpi notation for retina
* support
@@ -45,6 +48,7 @@
* @run main/othervm -splash:splash1.png MultiResolutionSplashTest TEST_SPLASH 0
* @run main/othervm -splash:splash2 MultiResolutionSplashTest TEST_SPLASH 1
* @run main/othervm -splash:splash3. MultiResolutionSplashTest TEST_SPLASH 2
+ * @run main/othervm -splash:splash1.png MultiResolutionSplashTest TEST_FOCUS
*/
public class MultiResolutionSplashTest {
@@ -69,6 +73,9 @@
int index = Integer.parseInt(args[1]);
testSplash(tests[index]);
break;
+ case "TEST_FOCUS":
+ testFocus();
+ break;
default:
throw new RuntimeException("Unknown test: " + test);
}
@@ -92,12 +99,49 @@
float scaleFactor = getScaleFactor();
Color testColor = (1 < scaleFactor) ? test.color2x : test.color1x;
- if (!testColor.equals(splashScreenColor)) {
+ if (!compare(testColor, splashScreenColor)) {
throw new RuntimeException(
"Image with wrong resolution is used for splash screen!");
}
}
+ static void testFocus() throws Exception {
+
+ System.out.println("Focus Test!");
+ Robot robot = new Robot();
+ robot.setAutoDelay(50);
+
+ Frame frame = new Frame();
+ frame.setSize(100, 100);
+ String test = "123";
+ TextField textField = new TextField(test);
+ frame.add(textField);
+ frame.setVisible(true);
+ robot.waitForIdle();
+
+ robot.keyPress(KeyEvent.VK_A);
+ robot.keyRelease(KeyEvent.VK_A);
+ robot.keyPress(KeyEvent.VK_B);
+ robot.keyRelease(KeyEvent.VK_B);
+ robot.waitForIdle();
+
+ frame.dispose();
+
+ if(!textField.getText().equals("ab")){
+ throw new RuntimeException("Focus is lost!");
+ }
+ }
+
+ static boolean compare(Color c1, Color c2){
+ return compare(c1.getRed(), c2.getRed())
+ && compare(c1.getGreen(), c2.getGreen())
+ && compare(c1.getBlue(), c2.getBlue());
+ }
+
+ static boolean compare(int n, int m){
+ return Math.abs(n - m) <= 50;
+ }
+
static float getScaleFactor() {
final Dialog dialog = new Dialog((Window) null);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Window/AlwaysOnTop/AutoTestOnTop.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,795 @@
+/*
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ @test
+ @bug 4632143
+ @summary Unit test for the RFE window/frame/dialog always on top
+ @author dom@sparc.spb.su: area=awt.toplevel
+ @run main AutoTestOnTop
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+import java.lang.reflect.*;
+import javax.swing.*;
+import java.util.Vector;
+
+/**
+ * @author tav@sparc.spb.su
+ * @author dom@sparc.spb.su
+ * Tests that always-on-top windows combine correctly with different kinds of window in different styles and conditions.
+ *
+ * !!! WARNING !!!
+ * The test fails sometimes because the toFront() method doesn't guarantee
+ * that after its invocation the frame will be placed above all other windows.
+ */
+public class AutoTestOnTop {
+ static Window topw;
+ static Frame parentw = new Frame();
+ static Window f;
+ static Frame parentf = new Frame();
+
+ static Object uncheckedSrc = new Object(); // used when no need to check event source
+ static Object eventSrc = uncheckedSrc;
+ static boolean dispatchedCond;
+
+ static Semaphore STATE_SEMA = new Semaphore();
+ static Semaphore VIS_SEMA = new Semaphore();
+ static Vector errors = new Vector();
+
+ static boolean isUnix = false;
+
+ static StringBuffer msgError = new StringBuffer();
+ static StringBuffer msgCase = new StringBuffer();
+ static StringBuffer msgAction = new StringBuffer();
+ static StringBuffer msgFunc = new StringBuffer();
+ static StringBuffer msgVisibility = new StringBuffer();
+
+ static volatile int stageNum;
+ static volatile int actNum;
+ static volatile int testResult = 0;
+
+ static volatile boolean doCheckEvents;
+ static volatile boolean eventsCheckPassed;
+ static boolean[] eventsCheckInitVals = new boolean[] { // Whether events are checked for abcence or precence
+ true, true, true, true, true, false, false, false, false
+ };
+ static String[] msgEventsChecks = new String[] {
+ null, null, null, null, null,
+ "expected WindowEvent.WINDOW_STATE_CHANGED hasn't been generated",
+ "expected WindowEvent.WINDOW_STATE_CHANGED hasn't been generated",
+ "expected WindowEvent.WINDOW_STATE_CHANGED hasn't been generated",
+ "expected WindowEvent.WINDOW_STATE_CHANGED hasn't been generated",
+ };
+
+ static final int stagesCount = 7;
+ static final int actionsCount = 9;
+
+ static Method[] preActions = new Method[actionsCount];
+ static Method[] postActions = new Method[actionsCount];
+ static Method[] isActionsAllowed = new Method[actionsCount];
+ static Method[] checksActionEvents = new Method[actionsCount];
+
+ static Robot robot;
+
+ static boolean doStartTest;
+ static String osName = System.getProperty("os.name");
+
+
+ public static void main(String[] args) {
+ checkTesting();
+
+ }
+
+ public static void performTesting() {
+ isUnix = osName.equals("Linux") || osName.equals("SunOS");
+
+ Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
+ public void eventDispatched(AWTEvent e) {
+ if (e.getID() == MouseEvent.MOUSE_CLICKED) {
+ if (eventSrc != null & eventSrc != uncheckedSrc && e.getSource() != eventSrc) {
+ error("Test failed: stage #" + stageNum + ", action # " + actNum + ": " + msgCase + ": " + msgAction + ": " + msgError);
+ testResult = -1;
+ }
+ synchronized (eventSrc) {
+ dispatchedCond = true;
+ eventSrc.notify();
+ }
+ }
+
+ if (doCheckEvents && (e.getSource() == topw || e.getSource() == f)) {
+
+ //System.err.println("AWTEventListener: catched the event " + e);
+
+ try {
+ checksActionEvents[actNum].invoke(null, new Object[] {e});
+ } catch (InvocationTargetException ite) {
+ ite.printStackTrace();
+ } catch (IllegalAccessException iae) {
+ iae.printStackTrace();
+ }
+ return;
+ }
+ }
+ }, 0xffffffffffffffffL);
+
+ Method[] allMethods;
+
+ try {
+ allMethods = AutoTestOnTop.class.getDeclaredMethods();
+ } catch (SecurityException se) {
+ throw new RuntimeException(se);
+ }
+
+ for (int i = 0; i < allMethods.length; i++) {
+ String name = allMethods[i].getName();
+ if (name.startsWith("preAction")) {
+ preActions[name.charAt(name.length() - 1) - '0'] = allMethods[i];
+ } else if (name.startsWith("postAction")) {
+ postActions[name.charAt(name.length() - 1) - '0'] = allMethods[i];
+ } else if (name.startsWith("isActionAllowed")) {
+ isActionsAllowed[name.charAt(name.length() - 1) - '0'] = allMethods[i];
+ } else if (name.startsWith("checkActionEvents")) {
+ checksActionEvents[name.charAt(name.length() - 1) - '0'] = allMethods[i];
+ }
+ }
+
+ f = new Frame("Auxiliary Frame");
+ f.setBounds(50, 0, 400, 50);
+ f.setVisible(true);
+ waitTillShown(f);
+
+ try {
+ robot = new Robot();
+ } catch (AWTException e) {
+ throw new RuntimeException("Error: unable to create robot", e);
+ }
+
+ mainTest();
+
+ if (testResult != 0) {
+ System.err.println("The following errors were encountered: ");
+ for (int i = 0; i < errors.size(); i++) {
+ System.err.println(errors.get(i).toString());
+ }
+ throw new RuntimeException("Test failed.");
+ } else {
+ System.err.println("Test PASSED.");
+ }
+ }
+
+ public static void mainTest() {
+// stageNum = 0;
+// for (int i = 0; i < 5; i++) {
+// actNum = 2;
+// System.err.println("************************* A C T I O N " + actNum + " *************************");
+// doStage(stageNum, actNum);
+// // pause(500);
+// actNum = 3;
+// System.err.println("************************* A C T I O N " + actNum + " *************************");
+// doStage(stageNum, actNum);
+// // pause(500);
+// }
+ for (stageNum = 0; stageNum < stagesCount; stageNum++) {
+ System.err.println("************************* S T A G E " + stageNum + " *************************");
+ for (actNum = 0; actNum < actionsCount; actNum++) {
+ System.err.println("************************* A C T I O N " + actNum + " *************************");
+ doStage(stageNum, actNum);
+ } // for thru actNum
+ } // fow thru stageNum
+
+ eventSrc = null;
+ }
+
+ private static void doStage(int stageNum, int actNum) {
+ try {
+
+ if (!((Boolean)isActionsAllowed[actNum].invoke(null, new Object[0])).booleanValue()) {
+ System.err.println("Action skipped due to a platform limitations");
+ return;
+ }
+
+ STATE_SEMA.reset();
+ createWindow(stageNum);
+
+ //*************************
+ // Set window always-on-top
+ //*************************
+
+ preActions[actNum].invoke(null, new Object[0]);
+ setAlwaysOnTop(topw, true);
+ waitForIdle(true);
+
+ if (!topw.isAlwaysOnTopSupported()) return;
+
+ postActions[actNum].invoke(null, new Object[0]);
+ waitForIdle(false);
+
+ STATE_SEMA.reset();
+
+ testForAlwaysOnTop();
+
+ //*****************************
+ // Set window not always-on-top
+ //*****************************
+
+ preActions[actNum].invoke(null, new Object[0]);
+ setAlwaysOnTop(topw, false);
+ waitForIdle(true);
+ postActions[actNum].invoke(null, new Object[0]);
+ waitForIdle(false);
+ STATE_SEMA.reset();
+
+ testForNotAlwaysOnTop();
+
+ } catch (InvocationTargetException ite) {
+ ite.printStackTrace();
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ private static void checkTesting() {
+ if (Toolkit.getDefaultToolkit().isAlwaysOnTopSupported()) {
+ performTesting();
+ }
+ }
+
+ public static void testForAlwaysOnTop() {
+ System.err.println("Checking for always-on-top " + topw);
+
+ ensureInitialWinPosition(topw);
+
+ // Check that always-on-top window is topmost.
+ // - Click on always-on-top window on the windows cross area.
+ clickOn(topw, f, 10, 30, "setting " + msgVisibility +
+ " window (1) always-on-top didn't make it topmost");
+
+ // Check that we can't change z-order of always-on-top window.
+ // - a) Try to put the other window on the top.
+ f.toFront();
+ clickOn(uncheckedSrc, f, 190, 30, ""); // coz toFront() works not always
+ pause(300);
+
+ // - b) Click on always-on-top window on the windows cross area.
+ clickOn(topw, f, 10, 30, "setting " + msgVisibility +
+ " window (1) always-on-top didn't make it such");
+
+ // Ask for always-on-top property
+ if (isAlwaysOnTop(topw) != true)
+ error("Test failed: stage #" + stageNum + ", action #" + actNum + ": " + msgCase + ": " + msgAction +
+ ": isAlwaysOnTop() returned 'false' for window (1) set always-on-top at state "
+ + msgVisibility);
+ }
+
+ public static void testForNotAlwaysOnTop() {
+ System.err.println("Checking for non always-on-top of " + topw);
+ ensureInitialWinPosition(topw);
+
+ if (msgVisibility.equals("visible") && actNum != 2) {
+ // Check that the window remains topmost.
+ // - click on the window on the windows cross area.
+ clickOn(topw, f, 10, 30, "setting " + msgVisibility +
+ " window (1) not always-on-top didn't keep it topmost");
+ }
+
+ // Check that we can change z-order of not always-on-top window.
+ // - a) try to put the other window on the top.
+ f.toFront();
+ clickOn(uncheckedSrc, f, 190, 30, ""); // coz toFront() works not always
+ pause(300);
+
+ // - b) click on not always-on-top window on the windows cross area.
+ clickOn(f, f, 10, 30, "setting " + msgVisibility +
+ " window (1) not always-on-top didn't make it such");
+
+ // Ask for always-on-top property
+ if (isAlwaysOnTop(topw) != false)
+ error("Test failed: stage #" + stageNum + ", action #" + actNum + ": " + msgCase + ": " + msgAction +
+ ": isAlwaysOnTop() returned 'true' for window (1) set not always-on-top at state "
+ + msgVisibility);
+ }
+
+
+ private static void createWindow(int stageNum) {
+ // Free native resourses
+ if (topw != null && topw.isVisible()) {
+ topw.dispose();
+ }
+
+ switch (stageNum) {
+ case 0:
+ topw = new Frame("Top Frame");
+ msgCase.replace(0, msgCase.length(), "Frame (1) over Frame (2)");
+ break;
+ case 1:
+ topw = new JFrame("Top JFrame");
+ msgCase.replace(0, msgCase.length(), "JFrame (1) over Frame (2)");
+ break;
+ case 2:
+ topw = new Dialog(parentw, "Top Dialog");
+ msgCase.replace(0, msgCase.length(), "Dialog (1) over Frame (2)");
+ break;
+ case 3:
+ topw = new JDialog(parentw, "Top JDialog");
+ msgCase.replace(0, msgCase.length(), "JDialog (1) over Frame (2)");
+ break;
+ case 4:
+ topw = new Frame("Top Frame");
+ f.dispose();
+ f = new Dialog(parentf, "Auxiliary Dialog");
+ f.setBounds(50, 0, 250, 50);
+ f.setVisible(true);
+ waitTillShown(f);
+ msgCase.replace(0, msgCase.length(), "Frame (1) over Dialog (2)");
+ break;
+ case 5:
+ topw = new Window(parentw);
+ msgCase.replace(0, msgCase.length(), "Window (1) over Frame (2)");
+ break;
+ case 6:
+ topw = new JWindow(parentw);
+ msgCase.replace(0, msgCase.length(), "JWindow (1) over Frame (2)");
+ break;
+ }
+ topw.addWindowStateListener(new WindowAdapter() {
+ public void windowStateChanged(WindowEvent e) {
+ System.err.println("* " + e);
+ STATE_SEMA.raise();
+ }
+ });
+ topw.setSize(200, 50);
+ }
+
+ /**
+ * 0: setting always-on-top to invisible window
+ * 1: setting always-on-top to visible window
+ * 2: always-on-top on visible non-focusable window
+ * 3: always-on-top on visible, dragging topw after that
+ * 4: always-on-top on visible, dragging f after that
+ * 5: always-on-top on (visible, maximized), make normal after that
+ * 6: always-on-top on (visible, iconified), make normal after that
+ * 7: always-on-top on visible, iconify/deiconify after that
+ * 8: always-on-top on visible, maximize/restore after that
+ */
+ public static void preAction_0() {
+ topw.setVisible(false);
+ }
+ public static void postAction_0() {
+ if (topw.isShowing()) {
+ error("Test failed: stage #" + stageNum + ", action #" + actNum + ": " + msgCase +
+ ": no actions with windows: changing always-on-top property at window (1) state 'invisible' makes window (1) visible");
+ }
+ setWindowVisible("no actions with windows", "invisible");
+ }
+ public static boolean isActionAllowed_0() {
+ // Window on Linux is always always-on-top!
+ return !((stageNum == 5 || stageNum == 6) && isUnix) && (stageNum < stagesCount);
+ }
+ public static void checkActionEvents_0(AWTEvent e) {
+ System.err.println(e.toString());
+ }
+
+ public static void preAction_1() {
+ setWindowVisible("no actions with windows", "visible");
+ }
+ public static void postAction_1() {}
+ public static boolean isActionAllowed_1() {
+ return !((stageNum == 5 || stageNum == 6) && isUnix) && (stageNum < stagesCount );
+ }
+ public static void checkActionEvents_1(AWTEvent e) {
+ System.err.println(e.toString());
+ if (e instanceof PaintEvent) {
+ return;
+ }
+ eventsCheckPassed = false;
+ error("Test failed: stage #" + stageNum + ", action # " + actNum + ": " + msgCase + ": " + msgAction + ": after call " + msgFunc +
+ ": unexpected event " + e + " was generated");
+ }
+
+ public static void preAction_2() {
+ setWindowVisible("when window (1) set not focusable", "visible");
+ topw.setFocusableWindowState(false);
+ f.toFront();
+ pause(300);
+ }
+ public static void postAction_2() {}
+ public static boolean isActionAllowed_2() {
+ return !((stageNum == 5 || stageNum == 6) && isUnix) && (stageNum < stagesCount);
+ }
+ public static void checkActionEvents_2(AWTEvent e) {
+ System.err.println(e.toString());
+ if ( (e.getID() >= FocusEvent.FOCUS_FIRST && e.getID() <= FocusEvent.FOCUS_LAST) ||
+ (e.getID() == WindowEvent.WINDOW_LOST_FOCUS && e.getID() == WindowEvent.WINDOW_GAINED_FOCUS)) {
+ eventsCheckPassed = false;
+ error("Test failed: stage #" + stageNum + ", action # " + actNum + ": " + msgCase + ": " +
+ msgAction + ": after call " + msgFunc +
+ ": unexpected event " + e + " was generated");
+ }
+ }
+
+ public static void preAction_3() {
+ setWindowVisible("after dragging", "visible");
+ }
+ public static void postAction_3() {
+ Point p = topw.getLocationOnScreen();
+ int x = p.x + 40, y = p.y + 5;
+
+ try { // Take a pause to avoid double click
+ Thread.sleep(500); // when called one after another.
+ } catch (InterruptedException ie) {
+ ie.printStackTrace();
+ } catch (IllegalComponentStateException e) {
+ e.printStackTrace();
+ }
+
+ // Drag the window.
+ robot.mouseMove(x, y);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseMove(200, 50);
+ robot.mouseMove(x, y);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ }
+ public static boolean isActionAllowed_3() {
+ return (stageNum < 5);
+ }
+ public static void checkActionEvents_3(AWTEvent e) {
+ System.err.println(e.toString());
+ }
+
+ public static void preAction_4() {
+ setWindowVisible("after dragging window (2)", "visible");
+ }
+ public static void postAction_4() {
+ Point p = f.getLocationOnScreen();
+ int x = p.x + 150, y = p.y + 5;
+
+ try { // Take a pause to avoid double click
+ Thread.sleep(500); // when called one after another.
+ } catch (InterruptedException ie) {
+ ie.printStackTrace();
+ } catch (IllegalComponentStateException e) {
+ e.printStackTrace();
+ }
+
+ // Drag the window.
+ robot.mouseMove(x, y);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseMove(200, 50);
+ robot.mouseMove(x, y);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+ ensureInitialWinPosition(f);
+ }
+ public static boolean isActionAllowed_4() {
+ return !((stageNum == 5 || stageNum == 6) && isUnix);
+ }
+ public static void checkActionEvents_4(AWTEvent e) {
+ System.err.println(e.toString());
+ }
+
+ // Metacity has a bug not allowing to set a window to NORMAL state!!!
+
+ public static void preAction_5() {
+ setWindowVisible("at state 'maximized'", "visible");
+ ((Frame)topw).setExtendedState(Frame.MAXIMIZED_BOTH);
+ waitForStateChange();
+ }
+ public static void postAction_5() {
+ ((Frame)topw).setExtendedState(Frame.NORMAL);
+ waitForStateChange();
+ }
+ public static boolean isActionAllowed_5() {
+ return (stageNum < 2);
+ }
+ public static void checkActionEvents_5(AWTEvent e) {
+ System.err.println("=" + e.toString());
+ if (e.getID() == WindowEvent.WINDOW_STATE_CHANGED) {
+ eventsCheckPassed = true;
+ }
+ }
+
+ public static void preAction_6() {
+ setWindowVisible("at state 'iconified'", "visible");
+ System.err.println("Iconifying " + topw);
+ ((Frame)topw).setExtendedState(Frame.ICONIFIED);
+ if (!waitForStateChange()) {
+ error("Test failed: stage #" + stageNum + ", action # " + actNum + ": " + msgCase + ": " + msgAction + ": after call " + msgFunc +
+ ": state change to ICONIFIED hasn't been generated");
+ }
+ }
+ public static void postAction_6() {
+ System.err.println("Restoring " + topw);
+ ((Frame)topw).setExtendedState(Frame.NORMAL);
+ if (!waitForStateChange()) {
+ error("Test failed: stage #" + stageNum + ", action # " + actNum + ": " + msgCase + ": " + msgAction + ": after call " + msgFunc +
+ ": state change to NORMAL hasn't been generated");
+ }
+ }
+ public static boolean isActionAllowed_6() {
+ return (stageNum < 2 );
+ }
+ public static void checkActionEvents_6(AWTEvent e) {
+ System.err.println("+" + e.toString());
+ if (e.getID() == WindowEvent.WINDOW_STATE_CHANGED) {
+ eventsCheckPassed = true;
+ }
+ }
+
+ public static void preAction_7() {
+ setWindowVisible("before state 'iconified'", "visible");
+ }
+ public static void postAction_7() {
+ System.err.println("Setting iconified");
+ ((Frame)topw).setExtendedState(Frame.ICONIFIED);
+ if (!waitForStateChange()) {
+ error("Test failed: stage #" + stageNum + ", action # " + actNum + ": " + msgCase + ": " + msgAction + ": after call " + msgFunc +
+ ": state change to ICONIFIED hasn't been generated");
+ }
+ System.err.println("Setting normal");
+ ((Frame)topw).setExtendedState(Frame.NORMAL);
+ if (!waitForStateChange()) {
+ error("Test failed: stage #" + stageNum + ", action # " + actNum + ": " + msgCase + ": " + msgAction + ": after call " + msgFunc +
+ ": state change to NORMAL hasn't been generated");
+ }
+ }
+ public static boolean isActionAllowed_7() {
+ return (stageNum < 2);
+ }
+ public static void checkActionEvents_7(AWTEvent e) {
+ System.err.println(e.toString());
+ if (e.getID() == WindowEvent.WINDOW_STATE_CHANGED) {
+ eventsCheckPassed = true;
+ }
+ }
+
+ public static void preAction_8() {
+ setWindowVisible("before state 'maximized'", "visible");
+ }
+ public static void postAction_8() {
+ ((Frame)topw).setExtendedState(Frame.MAXIMIZED_BOTH);
+ if (!waitForStateChange()) {
+ error("Test failed: stage #" + stageNum + ", action # " + actNum + ": " + msgCase + ": " + msgAction + ": after call " + msgFunc +
+ ": state change to MAXIMIZED hasn't been generated");
+ }
+ ((Frame)topw).setExtendedState(Frame.NORMAL);
+ if (!waitForStateChange()) {
+ error("Test failed: stage #" + stageNum + ", action # " + actNum + ": " + msgCase + ": " + msgAction + ": after call " + msgFunc +
+ ": state change to NORMAL hasn't been generated");
+ }
+ }
+ public static boolean isActionAllowed_8() {
+ return (stageNum < 2);
+ }
+ public static void checkActionEvents_8(AWTEvent e) {
+ System.err.println(e.toString());
+ if (e.getID() == WindowEvent.WINDOW_STATE_CHANGED) {
+ eventsCheckPassed = true;
+ }
+ }
+
+ //***************************************************************************
+
+ private static void setWindowVisible(String mAction, String mVisibility) {
+ msgAction.replace(0, msgAction.length(), mAction);
+ msgVisibility.replace(0, msgVisibility.length(), mVisibility);
+
+ topw.setVisible(true);
+ pause(100); // Needs for Sawfish
+ topw.setLocation(0, 0);
+ waitTillShown(topw);
+ f.toFront();
+ pause(300);
+ }
+
+ private static void clickOn(Object src, Window relwin, int x, int y, String errorStr) {
+ Point p = relwin.getLocationOnScreen();
+ int counter = 10;
+ while (--counter > 0) {
+ eventSrc = src;
+ msgError.replace(0, msgError.length(), errorStr);
+
+ robot.mouseMove(p.x + x, p.y + y);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+ synchronized (eventSrc) {
+ if (!dispatchedCond) {
+ try {
+ eventSrc.wait(1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ if (!dispatchedCond) {
+ //System.err.println("clickOn: MOUSE_CLICKED event losed, trying to generate it again...");
+ continue;
+ }
+ dispatchedCond = false;
+ }
+ break;
+ } // end while
+ if (counter <= 0) {
+ eventSrc = uncheckedSrc;
+ error("Test: internal error: could't catch MOUSE_CLICKED event. Skip testing this stage");
+ }
+ }
+
+ private static void setAlwaysOnTop(Window w, boolean value) {
+ System.err.println("Setting always on top on " + w + " to " + value);
+ robot.mouseMove(0, 100); // Move out of the window
+ msgFunc.replace(0, msgCase.length(), "setAlwaysOnTop()");
+ try {
+ w.setAlwaysOnTop(value);
+ } catch (Exception e) {
+ error("Test failed: stage#" + stageNum + "action #" + actNum + ": " + msgCase + ": " + msgAction +
+ ": setAlwaysOnTop(" + value + ") called at state " + msgVisibility +
+ " threw exeption " + e);
+ }
+ }
+
+ private static boolean isAlwaysOnTop(Window w) {
+ robot.mouseMove(0, 100); // Move out of the window
+ msgFunc.replace(0, msgCase.length(), "isAlwaysOnTop()");
+ boolean result = false;
+ try {
+ result = w.isAlwaysOnTop();
+ } catch (Exception e) {
+ error("Test failed: stage #" + stageNum + ", action # " + actNum + ": " + msgCase + ": " + msgAction +
+ ": isAlwaysOnTop() called at state " + msgVisibility +
+ " threw exeption " + e);
+ }
+ return result;
+ }
+
+ private static void waitTillShown(Component c) {
+ while (true) {
+ try {
+ Thread.sleep(100);
+ c.getLocationOnScreen();
+ break;
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ break;
+ }
+ }
+ }
+
+ private static void waitForIdle(boolean doCheck) {
+ try {
+ robot.waitForIdle();
+ EventQueue.invokeAndWait( new Runnable() {
+ public void run() {} // Dummy implementation
+ } );
+ } catch(InterruptedException ite) {
+ System.err.println("waitForIdle, non-fatal exception caught:");
+ ite.printStackTrace();
+ } catch(InvocationTargetException ine) {
+ System.err.println("waitForIdle, non-fatal exception caught:");
+ ine.printStackTrace();
+ }
+ doCheckEvents = doCheck;
+
+ if (doCheck) {
+ eventsCheckPassed = eventsCheckInitVals[actNum]; // Initialize
+ } else if (!eventsCheckPassed &&
+ msgEventsChecks[actNum] != null) {
+
+
+ // Some expected event hasn't been catched,
+ // so give it one more chance...
+ doCheckEvents = true;
+ pause(500);
+ doCheckEvents = false;
+
+ if (!eventsCheckPassed) {
+ testResult = -1;
+ error("Test failed: stage #" + stageNum + ", action # " + actNum + ": " + msgCase + ": " + msgAction + ": after call "
+ + msgFunc + ": " + msgEventsChecks[actNum]);
+ }
+ }
+ }
+
+ private static boolean waitForStateChange() {
+ System.err.println("------- Waiting for state change");
+ try {
+ STATE_SEMA.doWait(3000);
+ } catch (InterruptedException ie) {
+ System.err.println("Wait interrupted: " + ie);
+ }
+ boolean state = STATE_SEMA.getState();
+ STATE_SEMA.reset();
+ return state;
+ }
+
+ private static void ensureInitialWinPosition(Window w) {
+ int counter = 30;
+ while (w.getLocationOnScreen().y != 0 && --counter > 0) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ break;
+ }
+ }
+ if (counter <= 0) {
+ w.setLocation(0, 0);
+ pause(100);
+ System.err.println("Test: window set to initial position forcedly");
+ }
+ }
+
+ private static void pause(int mls) {
+ try {
+ Thread.sleep(mls);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private static void error(String msg) {
+ errors.add(msg);
+ System.err.println(msg);
+ }
+}
+
+class Semaphore {
+ boolean state = false;
+ int waiting = 0;
+ public Semaphore() {
+ }
+ public synchronized void doWait() throws InterruptedException {
+ if (state) {
+ return;
+ }
+ waiting++;
+ wait();
+ waiting--;
+ }
+ public synchronized void doWait(int timeout) throws InterruptedException {
+ if (state) {
+ return;
+ }
+ waiting++;
+ wait(timeout);
+ waiting--;
+ }
+ public synchronized void raise() {
+ state = true;
+ if (waiting > 0) {
+ notifyAll();
+ }
+ }
+
+ public synchronized void doNotify() {
+ notifyAll();
+ }
+ public synchronized boolean getState() {
+ return state;
+ }
+
+ public synchronized void reset() {
+ state = false;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/event/ComponentEvent/MovedResizedTardyEventTest/MovedResizedTardyEventTest.html Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,43 @@
+<!--
+ Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+ This code is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License version 2 only, as
+ published by the Free Software Foundation.
+
+ This code is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ version 2 for more details (a copy is included in the LICENSE file that
+ accompanied this code).
+
+ You should have received a copy of the GNU General Public License version
+ 2 along with this work; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ or visit www.oracle.com if you need additional information or have any
+ questions.
+-->
+
+<html>
+<!--
+ @test
+ @bug 4985250
+ @summary COMPONENT_MOVED/RESIZED tardy events shouldn't be generated.
+ @author tav@sparc.spb.su
+ @run applet MovedResizedTardyEventTest.html
+ -->
+<head>
+<title>MovedResizedTardyEventTest</title>
+</head>
+<body>
+
+<h1>MovedResizedTardyEventTest<br>Bug ID: 4985250</h1>
+
+<p> See the dialog box (usually in upper left corner) for instructions</p>
+
+<APPLET CODE="MovedResizedTardyEventTest.class" WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/event/ComponentEvent/MovedResizedTardyEventTest/MovedResizedTardyEventTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ test
+ @bug 4985250
+ @summary COMPONENT_MOVED/RESIZED tardy events shouldn't be generated.
+ @author tav@sparc.spb.su
+ @run applet MovedResizedTardyEventTest.html
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+import java.applet.Applet;
+import java.lang.reflect.InvocationTargetException;
+
+public class MovedResizedTardyEventTest extends Applet {
+ Frame f1 = new Frame("F-1");
+ Frame f2 = new Frame("F-2");
+
+ boolean eventFlag = false;
+
+ public static void main(String[] args) {
+ Applet a = new MovedResizedTardyEventTest();
+ a.start();
+ }
+
+ public void start() {
+ f1.setVisible(true);
+ f2.setVisible(true);
+
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {}
+
+ f1.addComponentListener(new ComponentAdapter() {
+ public void componentMoved(ComponentEvent e) {
+ MovedResizedTardyEventTest.this.eventFlag = true;
+ System.err.println(e);
+ }
+ public void componentResized(ComponentEvent e) {
+ MovedResizedTardyEventTest.this.eventFlag = true;
+ System.err.println(e);
+ }
+ });
+
+ f1.toFront();
+
+ waitForIdle();
+
+ try { // wait more...
+ Thread.sleep(500);
+ } catch (InterruptedException e) {}
+
+ if (eventFlag) {
+ throw new RuntimeException("Test failed!");
+ }
+ }
+
+ void waitForIdle() {
+ try {
+ (new Robot()).waitForIdle();
+ EventQueue.invokeAndWait( new Runnable() {
+ public void run() {} // Dummy implementation
+ });
+ } catch(InterruptedException ie) {
+ System.err.println("waitForIdle, non-fatal exception caught:");
+ ie.printStackTrace();
+ } catch(InvocationTargetException ite) {
+ System.err.println("waitForIdle, non-fatal exception caught:");
+ ite.printStackTrace();
+ } catch(AWTException rex) {
+ rex.printStackTrace();
+ throw new RuntimeException("unexpected exception");
+ }
+ }
+}
--- a/jdk/test/java/awt/event/KeyEvent/AltCharAcceleratorTest/AltCharAcceleratorTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/test/java/awt/event/KeyEvent/AltCharAcceleratorTest/AltCharAcceleratorTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -29,8 +29,6 @@
@run main AltCharAcceleratorTest
*/
-import sun.awt.SunToolkit;
-
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
@@ -103,13 +101,12 @@
}
void test() throws Exception {
- ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+ Robot robot = new Robot();
+ robot.setAutoDelay(100);
+ robot.waitForIdle();
focusLatch.await(5, TimeUnit.SECONDS);
- Robot robot = new Robot();
- robot.setAutoDelay(100);
-
robot.keyPress(KeyEvent.VK_ALT);
robot.keyPress(KeyEvent.VK_T);
robot.keyRelease(KeyEvent.VK_T);
@@ -133,4 +130,4 @@
AltCharAcceleratorTest t = new AltCharAcceleratorTest();
t.test();
}
-}
\ No newline at end of file
+}
--- a/jdk/test/java/awt/keyboard/EqualKeyCode/EqualKeyCode.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/test/java/awt/keyboard/EqualKeyCode/EqualKeyCode.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,18 +24,14 @@
/*
@test
@bug 6799551
- @library ../../regtesthelpers
- @build Util Sysout
@summary Extended key codes for small letters undefined
@author Andrei Dmitriev: area=awt.keyboard
@run main EqualKeyCode
*/
-import sun.awt.*;
import java.awt.*;
-import test.java.awt.regtesthelpers.Util;
-import test.java.awt.regtesthelpers.Sysout;
+import java.awt.event.KeyEvent;
public class EqualKeyCode {
@@ -46,13 +42,13 @@
char cSmall = LETTERS.charAt(i);
char cLarge = Character.toUpperCase(cSmall);
- int iSmall = ExtendedKeyCodes.getExtendedKeyCodeForChar(cSmall);
- int iLarge = ExtendedKeyCodes.getExtendedKeyCodeForChar(cLarge);
+ int iSmall = KeyEvent.getExtendedKeyCodeForChar(cSmall);
+ int iLarge = KeyEvent.getExtendedKeyCodeForChar(cLarge);
System.out.print(" " + cSmall + ":" + iSmall + " ---- ");
System.out.println(" " + cLarge + " : " + iLarge);
- if (ExtendedKeyCodes.getExtendedKeyCodeForChar(cSmall) !=
- ExtendedKeyCodes.getExtendedKeyCodeForChar(cLarge))
+ if (KeyEvent.getExtendedKeyCodeForChar(cSmall) !=
+ KeyEvent.getExtendedKeyCodeForChar(cLarge))
{
throw new RuntimeException("ExtendedKeyCode doesn't exist or doesn't match between capital and small letters.");
}
--- a/jdk/test/java/nio/channels/DatagramChannel/MulticastSendReceiveTests.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/test/java/nio/channels/DatagramChannel/MulticastSendReceiveTests.java Tue Apr 14 12:10:00 2015 -0700
@@ -97,7 +97,7 @@
// no datagram received
if (sa == null) {
if (expectedSender != null) {
- throw new RuntimeException("Expected message not recieved");
+ throw new RuntimeException("Expected message not received");
}
System.out.println("No message received (correct)");
return;
@@ -109,10 +109,15 @@
buf.flip();
byte[] bytes = new byte[buf.remaining()];
buf.get(bytes);
- int receivedId = Integer.parseInt(new String(bytes));
-
- System.out.format("Received message from %s (id=0x%x)\n",
- sender, receivedId);
+ String s = new String(bytes, "UTF-8");
+ int receivedId = -1;
+ try {
+ receivedId = Integer.parseInt(s);
+ System.out.format("Received message from %s (id=0x%x)\n",
+ sender, receivedId);
+ } catch (NumberFormatException x) {
+ System.out.format("Received message from %s (msg=%s)\n", sender, s);
+ }
if (expectedSender == null) {
if (receivedId == id)
--- a/jdk/test/java/util/BitSet/BitSetStreamTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/test/java/util/BitSet/BitSetStreamTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -43,7 +43,7 @@
/**
* @test
* @summary test BitSet stream
- * @bug 8012645
+ * @bug 8012645 8076442
* @run testng BitSetStreamTest
*/
public class BitSetStreamTest {
@@ -70,6 +70,7 @@
{ "step 5", IntStream.range(0, 255).map(f -> f * 5) },
{ "step 7", IntStream.range(0, 255).map(f -> f * 7) },
{ "1, 10, 100, 1000", IntStream.of(1, 10, 100, 1000) },
+ { "max int", IntStream.of(Integer.MAX_VALUE) },
{ "25 fibs", IntStream.generate(new Fibs()).limit(25) }
};
@@ -106,6 +107,8 @@
for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i+1)) {
assertTrue(it.hasNext());
assertEquals(it.nextInt(), i);
+ if (i == Integer.MAX_VALUE)
+ break; // or (i+1) would overflow
}
assertFalse(it.hasNext());
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/Calendar/Bug8075548.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8075548
+ * @summary Make sure that the format form of month names are produced when there are
+ * no stand-alone ones available.
+ */
+
+import java.text.*;
+import java.util.*;
+import static java.util.Calendar.*;
+
+public class Bug8075548 {
+ static int errors = 0;
+
+ public static void main(String[] args) throws Throwable {
+ Date date = new SimpleDateFormat("yyyy-MM-dd", Locale.US).parse("2010-09-15");
+ String[][] FORMAT_PAIRS = {
+ { "LLLL", "MMMM" },
+ { "LLL", "MMM" }
+ };
+ Locale[] LOCALES = {
+ Locale.ENGLISH, Locale.FRENCH, Locale.GERMAN, Locale.JAPANESE
+ };
+
+ for (Locale locale : LOCALES) {
+ for (String[] formats : FORMAT_PAIRS) {
+ String el = new SimpleDateFormat(formats[0], locale).format(date);
+ String em = new SimpleDateFormat(formats[1], locale).format(date);
+ if (!el.equals(em)) {
+ errors++;
+ System.err.println(locale + ": " +
+ formats[0] + " -> " + el + ", " +
+ formats[1] + " -> " + em);
+ }
+ }
+ }
+
+ // Test Calendar.getDisplayName() and .getDisplayNames().
+ for (Locale locale : LOCALES) {
+ testDisplayNames(locale, LONG_FORMAT, LONG_STANDALONE);
+ testDisplayNames(locale, SHORT_FORMAT, SHORT_STANDALONE);
+ testDisplayNames(locale, NARROW_FORMAT, NARROW_STANDALONE);
+ }
+
+ if (errors > 0) {
+ throw new RuntimeException("Failed");
+ }
+ }
+
+ private static void testDisplayNames(Locale locale, int formatStyle, int standaloneStyle) {
+ Map<String, Integer> map = new HashMap<>();
+ for (int month = JANUARY; month <= DECEMBER; month++) {
+ Calendar cal = new GregorianCalendar(2015, month, 1);
+ String format = cal.getDisplayName(MONTH, formatStyle, locale);
+ String standalone = cal.getDisplayName(MONTH, standaloneStyle, locale);
+ if (!format.equals(standalone)) {
+ System.err.println("Calendar.getDisplayName: " + (month+1) +
+ ", locale=" + locale +
+ ", format=" + format + ", standalone=" + standalone);
+ errors++;
+ }
+ if (standalone != null) {
+ map.put(standalone, month);
+ }
+ }
+ if (formatStyle == NARROW_FORMAT) {
+ // Narrow styles don't support unique names.
+ // (e.g., "J" for JANUARY, JUNE, and JULY)
+ return;
+ }
+ Calendar cal = new GregorianCalendar(2015, JANUARY, 1);
+ Map<String, Integer> mapStandalone = cal.getDisplayNames(MONTH, standaloneStyle, locale);
+ if (!map.equals(mapStandalone)) {
+ System.err.printf("Calendar.getDisplayNames: locale=%s%n map=%s%n mapStandalone=%s%n",
+ locale, map, mapStandalone);
+ errors++;
+ }
+ Map<String, Integer> mapAll = cal.getDisplayNames(MONTH, ALL_STYLES, locale);
+ if (!mapAll.entrySet().containsAll(map.entrySet())) {
+ System.err.printf("Calendar.getDisplayNames: locale=%s%n map=%s%n mapAll=%s%n",
+ locale, map, mapAll);
+ errors++;
+ }
+ }
+}
--- a/jdk/test/java/util/Calendar/NarrowNamesTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/test/java/util/Calendar/NarrowNamesTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -86,7 +86,19 @@
"\u6728",
"\u91d1",
"\u571f");
- testMap(THTH, MONTH, NARROW_FORMAT); // expect null
+ testMap(THTH, MONTH, NARROW_FORMAT,
+ "\u0e21.\u0e04.",
+ "\u0e01.\u0e1e.",
+ "\u0e21\u0e35.\u0e04.",
+ "\u0e40\u0e21.\u0e22.",
+ "\u0e1e.\u0e04.",
+ "\u0e21\u0e34.\u0e22", // no last dot
+ "\u0e01.\u0e04.",
+ "\u0e2a.\u0e04.",
+ "\u0e01.\u0e22.",
+ "\u0e15.\u0e04.",
+ "\u0e1e.\u0e22.",
+ "\u0e18.\u0e04.");
testMap(THTH, MONTH, NARROW_STANDALONE,
"\u0e21.\u0e04.",
"\u0e01.\u0e1e.",
@@ -146,7 +158,7 @@
Calendar cal = Calendar.getInstance(locale);
Map<String, Integer> got = cal.getDisplayNames(field, style, locale);
if (!(expectedMap == null && got == null)
- && !expectedMap.equals(got)) {
+ && !(expectedMap != null && expectedMap.equals(got))) {
System.err.printf("testMap: locale=%s, field=%d, style=%d, expected=%s, got=%s%n",
locale, field, style, expectedMap, got);
errors++;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/Map/FunctionalCMEs.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,147 @@
+/*
+ * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+import java.util.Arrays;
+import java.util.ConcurrentModificationException;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.function.BiFunction;
+
+import org.testng.annotations.Test;
+import org.testng.annotations.DataProvider;
+
+/**
+ * @test
+ * @bug 8071667
+ * @summary Ensure that ConcurrentModificationExceptions are thrown as specified from Map methods that accept Functions
+ * @author bchristi
+ * @build Defaults
+ * @run testng FunctionalCMEs
+ */
+public class FunctionalCMEs {
+ final static String KEY = "key";
+
+ @DataProvider(name = "Maps", parallel = true)
+ private static Iterator<Object[]> makeMaps() {
+ return Arrays.asList(
+ // Test maps that CME
+ new Object[]{new HashMap<>(), true},
+ new Object[]{new Hashtable<>(), true},
+ new Object[]{new LinkedHashMap<>(), true},
+ // Test default Map methods - no CME
+ new Object[]{new Defaults.ExtendsAbstractMap<>(), false}
+ ).iterator();
+ }
+
+ @Test(dataProvider = "Maps")
+ public void testComputeIfAbsent(Map<String,String> map, boolean expectCME) {
+ checkCME(() -> {
+ map.computeIfAbsent(KEY, k -> {
+ putToForceRehash(map);
+ return "computedValue";
+ });
+ }, expectCME);
+ }
+
+ @Test(dataProvider = "Maps")
+ public void testCompute(Map<String,String> map, boolean expectCME) {
+ checkCME(() -> {
+ map.compute(KEY, mkBiFunc(map));
+ }, expectCME);
+ }
+
+ @Test(dataProvider = "Maps")
+ public void testComputeWithKeyMapped(Map<String,String> map, boolean expectCME) {
+ map.put(KEY, "firstValue");
+ checkCME(() -> {
+ map.compute(KEY, mkBiFunc(map));
+ }, expectCME);
+ }
+
+ @Test(dataProvider = "Maps")
+ public void testComputeIfPresent(Map<String,String> map, boolean expectCME) {
+ map.put(KEY, "firstValue");
+ checkCME(() -> {
+ map.computeIfPresent(KEY, mkBiFunc(map));
+ }, expectCME);
+ }
+
+ @Test(dataProvider = "Maps")
+ public void testMerge(Map<String,String> map, boolean expectCME) {
+ map.put(KEY, "firstValue");
+ checkCME(() -> {
+ map.merge(KEY, "nextValue", mkBiFunc(map));
+ }, expectCME);
+ }
+
+ @Test(dataProvider = "Maps")
+ public void testForEach(Map<String,String> map, boolean ignored) {
+ checkCME(() -> {
+ map.put(KEY, "firstValue");
+ putToForceRehash(map);
+ map.forEach((k,v) -> {
+ map.remove(KEY);
+ });
+ }, true);
+ }
+
+ @Test(dataProvider = "Maps")
+ public void testReplaceAll(Map<String,String> map, boolean ignored) {
+ checkCME(() -> {
+ map.put(KEY, "firstValue");
+ putToForceRehash(map);
+ map.replaceAll((k,v) -> {
+ map.remove(KEY);
+ return "computedValue";
+ });
+ },true);
+ }
+
+ private static void checkCME(Runnable code, boolean expectCME) {
+ try {
+ code.run();
+ } catch (ConcurrentModificationException cme) {
+ if (expectCME) { return; } else { throw cme; }
+ }
+ if (expectCME) {
+ throw new RuntimeException("Expected CME, but wasn't thrown");
+ }
+ }
+
+ private static BiFunction<String,String,String> mkBiFunc(Map<String,String> map) {
+ return (k,v) -> {
+ putToForceRehash(map);
+ return "computedValue";
+ };
+ }
+
+ private static void putToForceRehash(Map<String,String> map) {
+ for (int i = 0; i < 64; ++i) {
+ map.put(i + "", "value");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/logging/LogManager/Configuration/InvalidEscapeConfigurationTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UncheckedIOException;
+import java.io.UnsupportedEncodingException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Properties;
+import java.util.logging.LogManager;
+
+
+/**
+ * @test
+ * @bug 8075810
+ * @run main/othervm InvalidEscapeConfigurationTest
+ * @author danielfuchs
+ */
+public class InvalidEscapeConfigurationTest {
+
+ public static void main(String[] args)
+ throws UnsupportedEncodingException, IOException {
+ String[] validEscapes = {
+ "com.f\\u006fo.level = INF\\u004f",
+ "com.f\\u006fo.level = INFO",
+ "com.foo.level = INF\\u004f"
+ };
+ String[] invalidEscapes = {
+ "com.fo\\u0O6f.level = INF\\u0O4f",
+ "com.fo\\u0O6f.level = INFO",
+ "com.foo.level = INF\\u0O4f"
+ };
+ for (String line : validEscapes) {
+ test(line, true);
+ }
+ for (String line : invalidEscapes) {
+ test(line, false);
+ }
+ try {
+ Properties props = new Properties();
+ props.load((InputStream)null);
+ throw new RuntimeException("Properties.load(null): "
+ + "NullPointerException exception not raised");
+ } catch (NullPointerException x) {
+ System.out.println("Properties.load(null): "
+ + "got expected exception: " + x);
+ }
+ try {
+ LogManager.getLogManager().readConfiguration(null);
+ throw new RuntimeException("LogManager.readConfiguration(null): "
+ + "NullPointerException exception not raised");
+ } catch (NullPointerException x) {
+ System.out.println("LogManager.readConfiguration(null): "
+ + "got expected exception: " + x);
+ }
+
+
+ }
+
+ public static void test(String line, boolean valid) throws IOException {
+ String test = (valid ? "valid" : "invalid")
+ + " line \"" +line + "\"";
+ System.out.println("Testing " + test);
+
+ // First verify that we get the expected result from Properties.load()
+ try {
+ ByteArrayInputStream bais =
+ new ByteArrayInputStream(line.getBytes("UTF-8"));
+ Properties props = new Properties();
+ props.load(bais);
+ if (!valid) {
+ throw new RuntimeException(test
+ + "\n\tProperties.load: expected exception not raised");
+ } else {
+ System.out.println("Properties.load passed for " + test);
+ }
+ } catch(IllegalArgumentException x) {
+ if (!valid) {
+ System.out.println(
+ "Properties.load: Got expected exception: "
+ + x + "\n\tfor " + test);
+ } else {
+ throw x;
+ }
+ }
+
+ // Then verify that we get the expected result from
+ // LogManager.readConfiguration
+ try {
+ String content = defaultConfiguration() + '\n' + line + '\n';
+ ByteArrayInputStream bais =
+ new ByteArrayInputStream(content.getBytes("UTF-8"));
+ LogManager.getLogManager().readConfiguration(bais);
+ if (!valid) {
+ throw new RuntimeException(test
+ + "\n\tLogManager.readConfiguration: "
+ + "expected exception not raised");
+ } else {
+ System.out.println("LogManager.readConfiguration passed for "
+ + test);
+ }
+ } catch(IOException x) {
+ if (!valid) {
+ System.out.println(
+ "LogManager.readConfiguration: Got expected exception: "
+ + x + "\n\tfor " + test);
+ } else {
+ throw x;
+ }
+ }
+ }
+
+ static String getConfigurationFileName() {
+ String fname = System.getProperty("java.util.logging.config.file");
+ if (fname == null) {
+ fname = System.getProperty("java.home");
+ if (fname == null) {
+ throw new Error("Can't find java.home ??");
+ }
+ fname = Paths.get(fname, "conf", "logging.properties")
+ .toAbsolutePath().normalize().toString();
+ }
+ return fname;
+ }
+
+ static String defaultConfiguration() throws IOException {
+ Properties props = new Properties();
+ String fileName = getConfigurationFileName();
+ if (Files.exists(Paths.get(fileName))) {
+ try (InputStream is = new FileInputStream(fileName);) {
+ props.load(is);
+ } catch(IOException x) {
+ throw new UncheckedIOException(x);
+ }
+ }
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ props.store(bos, null);
+ return bos.toString();
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/logging/LogManager/TestLoggerNames.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,239 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.Phaser;
+import java.util.concurrent.Semaphore;
+import java.util.logging.Handler;
+import java.util.logging.LogManager;
+import java.util.logging.Logger;
+
+
+/**
+ * @test
+ * @bug 7113878
+ * @summary This is not a test that will check that 7113878 is fixed, but
+ * rather a test that will invoke the modified code & try to verify
+ * that fixing 7113878 has not introduced some big regression.
+ * This test should pass, whether 7113878 is there or not.
+ * @run main/othervm TestLoggerNames
+ * @author danielfuchs
+ */
+public class TestLoggerNames {
+
+ static final class TestLogger extends java.util.logging.Logger {
+
+ final Semaphore sem = new Semaphore(0);
+ final Semaphore wait = new Semaphore(0);
+
+ public TestLogger(String name, String resourceBundleName) {
+ super(name, resourceBundleName);
+ }
+
+ @Override
+ public Handler[] getHandlers() {
+ boolean found = false;
+ try {
+ System.out.println("Entering "+getName()+" getHandlers()");
+ for (StackTraceElement ste : Thread.currentThread().getStackTrace()) {
+ if (LogManager.class.getName().equals(ste.getClassName())
+ && "reset".equals(ste.getMethodName())) {
+ found = true;
+ System.out.println(getName()+" getHandlers() called by " + ste);
+ }
+ }
+ sem.release();
+ try {
+ System.out.println("TestLogger: Acquiring wait for "+getName());
+ wait.acquire();
+ try {
+ System.out.println("TestLogger: Acquired wait for "+getName());
+ return super.getHandlers();
+ } finally {
+ System.out.println("TestLogger: Releasing wait for "+getName());
+ wait.release();
+ }
+ } finally {
+ System.out.println("Unblocking "+getName());
+ sem.acquire();
+ System.out.println("Unblocked "+getName());
+ if (found) {
+ System.out.println("Reset will proceed...");
+ }
+ }
+ } catch (InterruptedException x) {
+ throw new IllegalStateException(x);
+ }
+ }
+ }
+
+ static volatile boolean stop;
+ static volatile Throwable resetFailed;
+ static volatile Throwable checkLoggerNamesFailed;
+ static volatile Phaser phaser = new Phaser(2);
+
+
+ static void checkLoggerNames(List<Logger> loggers) {
+ Enumeration<String> names = LogManager.getLogManager().getLoggerNames();
+ if (names instanceof Iterator) {
+ for (Iterator<?> it = Iterator.class.cast(names); it.hasNext(); ) {
+ try {
+ it.remove();
+ throw new RuntimeException("Iterator supports remove!");
+ } catch (UnsupportedOperationException x) {
+ System.out.println("OK: Iterator doesn't support remove.");
+ }
+ }
+ }
+ List<String> loggerNames = Collections.list(names);
+ if (!loggerNames.contains("")) {
+ throw new RuntimeException("\"\"" +
+ " not found in " + loggerNames);
+ }
+ if (!loggerNames.contains("global")) {
+ throw new RuntimeException("global" +
+ " not found in " + loggerNames);
+ }
+ for (Logger l : loggers) {
+ if (!loggerNames.contains(l.getName())) {
+ throw new RuntimeException(l.getName() +
+ " not found in " + loggerNames);
+ }
+ }
+ System.out.println("Got all expected logger names");
+ }
+
+
+ public static void main(String[] args) throws InterruptedException {
+ LogManager.getLogManager().addLogger(new TestLogger("com.foo.bar.zzz", null));
+ try {
+ Logger.getLogger(null);
+ throw new RuntimeException("Logger.getLogger(null) didn't throw expected NPE");
+ } catch (NullPointerException x) {
+ System.out.println("Got expected NullPointerException for Logger.getLogger(null)");
+ }
+ List<Logger> loggers = new CopyOnWriteArrayList<>();
+ loggers.add(Logger.getLogger("one.two.addMeAChild"));
+ loggers.add(Logger.getLogger("aaa.bbb.replaceMe"));
+ loggers.add(Logger.getLogger("bbb.aaa.addMeAChild"));
+ TestLogger test = (TestLogger)Logger.getLogger("com.foo.bar.zzz");
+ loggers.add(Logger.getLogger("ddd.aaa.addMeAChild"));
+
+ checkLoggerNames(loggers);
+
+ Thread loggerNamesThread = new Thread(() -> {
+ try {
+ while (!stop) {
+ checkLoggerNames(loggers);
+ Thread.sleep(10);
+ if (!stop) {
+ phaser.arriveAndAwaitAdvance();
+ }
+ }
+ } catch (Throwable t) {
+ t.printStackTrace(System.err);
+ checkLoggerNamesFailed = t;
+ }
+ }, "loggerNames");
+
+ Thread resetThread = new Thread(() -> {
+ try {
+ System.out.println("Calling reset...");
+ LogManager.getLogManager().reset();
+ System.out.println("Reset done...");
+ System.out.println("Reset again...");
+ LogManager.getLogManager().reset();
+ System.out.println("Reset done...");
+ } catch(Throwable t) {
+ resetFailed = t;
+ System.err.println("Unexpected exception or error in reset Thread");
+ t.printStackTrace(System.err);
+ }
+ }, "reset");
+
+ resetThread.setDaemon(true);
+ resetThread.start();
+
+ System.out.println("Waiting for reset to get handlers");
+ test.sem.acquire();
+ try {
+ loggerNamesThread.start();
+ System.out.println("Reset has called getHandlers on " + test.getName());
+ int i = 0;
+ for (Enumeration<String> e = LogManager.getLogManager().getLoggerNames();
+ e.hasMoreElements();) {
+ String name = e.nextElement();
+ if (name.isEmpty()) continue;
+ if (name.endsWith(".addMeAChild")) {
+ Logger l = Logger.getLogger(name+".child");
+ loggers.add(l);
+ System.out.println("*** Added " + l.getName());
+ i++;
+ } else if (name.endsWith("replaceMe")) {
+ Logger l = Logger.getLogger(name);
+ loggers.remove(l);
+ l = Logger.getLogger(name.replace("replaceMe", "meReplaced"));
+ loggers.add(l);
+ System.gc();
+ if (LogManager.getLogManager().getLogger(name) == null) {
+ System.out.println("*** "+ name + " successfully replaced with " + l.getName());
+ }
+ i++;
+ } else {
+ System.out.println("Nothing to do for logger: " + name);
+ }
+ phaser.arriveAndAwaitAdvance();
+ if (i >= 3 && i++ == 3) {
+ System.out.println("Loggers are now: " +
+ Collections.list(LogManager.getLogManager().getLoggerNames()));
+ test.wait.release();
+ test.sem.release();
+ System.out.println("Joining " + resetThread);
+ resetThread.join();
+ }
+ }
+ } catch (RuntimeException | InterruptedException | Error x) {
+ test.wait.release();
+ test.sem.release();
+ throw x;
+ } finally {
+ stop = true;
+ phaser.arriveAndDeregister();
+ loggerNamesThread.join();
+ loggers.clear();
+ }
+
+
+ if (resetFailed != null || checkLoggerNamesFailed != null) {
+ RuntimeException r = new RuntimeException("Some of the concurrent threads failed");
+ if (resetFailed != null) r.addSuppressed(resetFailed);
+ if (checkLoggerNamesFailed != null) r.addSuppressed(checkLoggerNamesFailed);
+ throw r;
+ }
+
+ }
+
+}
--- a/jdk/test/java/util/zip/EntryCount64k.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/test/java/util/zip/EntryCount64k.java Tue Apr 14 12:10:00 2015 -0700
@@ -24,33 +24,76 @@
/**
* @test
* @summary Test java.util.zip behavior with ~64k entries
+ * @library /lib/testlibrary
* @run main/othervm EntryCount64k
* @run main/othervm -Djdk.util.zip.inhibitZip64=true EntryCount64k
* @run main/othervm -Djdk.util.zip.inhibitZip64=false EntryCount64k
*/
-import java.io.*;
-import java.util.*;
-import java.util.zip.*;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.nio.file.Files;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.RandomAccessFile;
+import java.nio.file.Paths;
+import java.util.Enumeration;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+import java.util.zip.ZipInputStream;
+import java.util.zip.ZipOutputStream;
+
+import jdk.testlibrary.OutputAnalyzer;
+import jdk.testlibrary.ProcessTools;
public class EntryCount64k {
+ public static class Main {
+ public static void main(String[] args) {
+ System.out.print("Main");
+ }
+ }
- public static void main(String[] args) throws Exception {
- for (int i = (1 << 16) - 2; i < (1 << 16) + 2; i++)
+ static final String MAIN_CLASS = "EntryCount64k$Main";
+ static final String THIS_CLASS = "EntryCount64k";
+ static final String[] SPECIAL_CLASSES = { MAIN_CLASS, THIS_CLASS };
+ // static final String[] SPECIAL_CLASSES = { MAIN_CLASS };
+ static final int SPECIAL_COUNT = 1 + SPECIAL_CLASSES.length;
+
+ public static void main(String[] args) throws Throwable {
+ for (int i = (1 << 16) - 3; i < (1 << 16) + 2; i++)
test(i);
}
- static void test(int entryCount) throws Exception {
+ static void test(int entryCount) throws Throwable {
File zipFile = new File("EntryCount64k-tmp.zip");
zipFile.delete();
- try (ZipOutputStream zos =
- new ZipOutputStream(
- new BufferedOutputStream(
- new FileOutputStream(zipFile)))) {
- for (int i = 0; i < entryCount; i++) {
- ZipEntry e = new ZipEntry(Integer.toString(i));
- zos.putNextEntry(e);
+ try (FileOutputStream fos = new FileOutputStream(zipFile);
+ BufferedOutputStream bos = new BufferedOutputStream(fos);
+ ZipOutputStream zos = new ZipOutputStream(bos)) {
+
+ // Add entries to allow the zip file to be used with "java -jar"
+ zos.putNextEntry(new ZipEntry("META-INF/MANIFEST.MF"));
+ for (String line : new String[] {
+ "Manifest-Version: 1.0",
+ "Main-Class: " + MAIN_CLASS,
+ })
+ zos.write((line + "\n").getBytes("US-ASCII"));
+ zos.closeEntry();
+
+ String testClasses = System.getProperty("test.classes");
+ for (String className : SPECIAL_CLASSES) {
+ String baseName = className + ".class";
+ ZipEntry ze = new ZipEntry(baseName);
+ File file = new File(testClasses, baseName);
+ zos.putNextEntry(ze);
+ Files.copy(file.toPath(), zos);
+ zos.closeEntry();
+ }
+
+ for (int i = SPECIAL_COUNT; i < entryCount; i++) {
+ zos.putNextEntry(new ZipEntry(Integer.toString(i)));
zos.closeEntry();
}
}
@@ -86,16 +129,16 @@
return false;
}
- static void checkCanRead(File zipFile, int entryCount) throws Exception {
+ static void checkCanRead(File zipFile, int entryCount) throws Throwable {
// Check ZipInputStream API
- try (ZipInputStream zis =
- new ZipInputStream(
- new BufferedInputStream(
- new FileInputStream(zipFile)))) {
+ try (FileInputStream fis = new FileInputStream(zipFile);
+ BufferedInputStream bis = new BufferedInputStream(fis);
+ ZipInputStream zis = new ZipInputStream(bis)) {
for (int i = 0; i < entryCount; i++) {
ZipEntry e = zis.getNextEntry();
- if (Integer.parseInt(e.getName()) != i)
- throw new AssertionError();
+ if (i >= SPECIAL_COUNT) // skip special entries
+ if (Integer.parseInt(e.getName()) != i)
+ throw new AssertionError(e.getName());
}
if (zis.getNextEntry() != null)
throw new AssertionError();
@@ -106,8 +149,9 @@
Enumeration<? extends ZipEntry> en = zf.entries();
for (int i = 0; i < entryCount; i++) {
ZipEntry e = en.nextElement();
- if (Integer.parseInt(e.getName()) != i)
- throw new AssertionError();
+ if (i >= SPECIAL_COUNT) // skip special entries
+ if (Integer.parseInt(e.getName()) != i)
+ throw new AssertionError();
}
if (en.hasMoreElements()
|| (zf.size() != entryCount)
@@ -115,5 +159,15 @@
|| (zf.getEntry(Integer.toString(entryCount)) != null))
throw new AssertionError();
}
+
+ // Check java -jar
+ String javaHome = System.getProperty("java.home");
+ String java = Paths.get(javaHome, "bin", "java").toString();
+ String[] cmd = { java, "-jar", zipFile.getName() };
+ ProcessBuilder pb = new ProcessBuilder(cmd);
+ OutputAnalyzer a = ProcessTools.executeProcess(pb);
+ a.shouldHaveExitValue(0);
+ a.stdoutShouldMatch("\\AMain\\Z");
+ a.stderrShouldMatch("\\A\\Z");
}
}
--- a/jdk/test/java/util/zip/TestExtraTime.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/test/java/util/zip/TestExtraTime.java Tue Apr 14 12:10:00 2015 -0700
@@ -23,7 +23,7 @@
/**
* @test
- * @bug 4759491 6303183 7012868 8015666 8023713 8068790
+ * @bug 4759491 6303183 7012868 8015666 8023713 8068790 8076641
* @summary Test ZOS and ZIS timestamp in extra field correctly
*/
@@ -40,7 +40,6 @@
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
-
public class TestExtraTime {
public static void main(String[] args) throws Throwable{
@@ -71,6 +70,7 @@
}
testNullHandling();
+ testTagOnlyHandling();
testTimeConversions();
}
@@ -208,4 +208,42 @@
}
}
}
+
+ static void check(ZipEntry ze, byte[] extra) {
+ if (extra != null) {
+ byte[] extra1 = ze.getExtra();
+ if (extra1 == null || extra1.length < extra.length ||
+ !Arrays.equals(Arrays.copyOfRange(extra1,
+ extra1.length - extra.length,
+ extra1.length),
+ extra)) {
+ throw new RuntimeException("Timestamp: storing extra field failed!");
+ }
+ }
+ }
+
+ static void testTagOnlyHandling() throws Throwable {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ byte[] extra = new byte[] { 0x0a, 0, 4, 0, 0, 0, 0, 0 };
+ try (ZipOutputStream zos = new ZipOutputStream(baos)) {
+ ZipEntry ze = new ZipEntry("TestExtraTime.java");
+ ze.setExtra(extra);
+ zos.putNextEntry(ze);
+ zos.write(new byte[] { 1,2 ,3, 4});
+ }
+ try (ZipInputStream zis = new ZipInputStream(
+ new ByteArrayInputStream(baos.toByteArray()))) {
+ ZipEntry ze = zis.getNextEntry();
+ check(ze, extra);
+ }
+ Path zpath = Paths.get(System.getProperty("test.dir", "."),
+ "TestExtraTime.zip");
+ Files.copy(new ByteArrayInputStream(baos.toByteArray()), zpath);
+ try (ZipFile zf = new ZipFile(zpath.toFile())) {
+ ZipEntry ze = zf.getEntry("TestExtraTime.java");
+ check(ze, extra);
+ } finally {
+ Files.delete(zpath);
+ }
+ }
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/crypto/Cipher/CipherInputStreamExceptions.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,415 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8064546
+ * @summary Throw exceptions during reading but not closing of a
+ * CipherInputStream:
+ * - Make sure authenticated algorithms continue to throwing exceptions
+ * when the authentication tag fails verification.
+ * - Make sure other algorithms do not throw exceptions when the stream
+ * calls close() and only throw when read() errors.
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.lang.Exception;
+import java.lang.RuntimeException;
+import java.lang.Throwable;
+import java.security.AlgorithmParameters;
+import javax.crypto.AEADBadTagException;
+import javax.crypto.Cipher;
+import javax.crypto.CipherInputStream;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+import javax.crypto.spec.GCMParameterSpec;
+
+public class CipherInputStreamExceptions {
+
+ static SecretKeySpec key = new SecretKeySpec(new byte[16], "AES");
+ static GCMParameterSpec gcmspec = new GCMParameterSpec(128, new byte[16]);
+ static IvParameterSpec iv = new IvParameterSpec(new byte[16]);
+ static boolean failure = false;
+
+ /* Full read stream, check that getMoreData() is throwing an exception
+ * This test
+ * 1) Encrypt 100 bytes with AES/GCM/PKCS5Padding
+ * 2) Changes the last byte to invalidate the authetication tag.
+ * 3) Fully reads CipherInputStream to decrypt the message and closes
+ */
+
+ static void gcm_AEADBadTag() throws Exception {
+ Cipher c;
+ byte[] read = new byte[200];
+
+ System.out.println("Running gcm_AEADBadTag");
+
+ // Encrypt 100 bytes with AES/GCM/PKCS5Padding
+ byte[] ct = encryptedText("GCM", 100);
+ // Corrupt the encrypted message
+ ct = corruptGCM(ct);
+ // Create stream for decryption
+ CipherInputStream in = getStream("GCM", ct);
+
+ try {
+ int size = in.read(read);
+ throw new RuntimeException("Fail: CipherInputStream.read() " +
+ "returned " + size + " and didn't throw an exception.");
+ } catch (IOException e) {
+ Throwable ec = e.getCause();
+ if (ec instanceof AEADBadTagException) {
+ System.out.println(" Pass.");
+ } else {
+ System.out.println(" Fail: " + ec.getMessage());
+ throw new RuntimeException(ec);
+ }
+ } finally {
+ in.close();
+ }
+ }
+
+ /* Short read stream,
+ * This test
+ * 1) Encrypt 100 bytes with AES/GCM/PKCS5Padding
+ * 2) Reads 100 bytes from stream to decrypt the message and closes
+ * 3) Make sure no value is returned by read()
+ * 4) Make sure no exception is thrown
+ */
+
+ static void gcm_shortReadAEAD() throws Exception {
+ Cipher c;
+ byte[] read = new byte[100];
+
+ System.out.println("Running gcm_shortReadAEAD");
+
+ byte[] pt = new byte[600];
+ pt[0] = 1;
+ // Encrypt provided 600 bytes with AES/GCM/PKCS5Padding
+ byte[] ct = encryptedText("GCM", pt);
+ // Create stream for decryption
+ CipherInputStream in = getStream("GCM", ct);
+
+ int size = 0;
+ try {
+ size = in.read(read);
+ in.close();
+ if (read.length != 100) {
+ throw new RuntimeException("Fail: read size = " + read.length +
+ "should be 100.");
+ }
+ if (read[0] != 1) {
+ throw new RuntimeException("Fail: The decrypted text does " +
+ "not match the plaintext: '" + read[0] +"'");
+ }
+ } catch (IOException e) {
+ System.out.println(" Fail: " + e.getMessage());
+ throw new RuntimeException(e.getCause());
+ }
+ System.out.println(" Pass.");
+ }
+
+ /*
+ * Verify doFinal() exception is suppressed when input stream is not
+ * read before it is closed.
+ * This test:
+ * 1) Encrypt 100 bytes with AES/GCM/PKCS5Padding
+ * 2) Changes the last byte to invalidate the authetication tag.
+ * 3) Opens a CipherInputStream and the closes it. Never reads from it.
+ *
+ * There should be no exception thrown.
+ */
+ static void gcm_suppressUnreadCorrupt() throws Exception {
+ Cipher c;
+ byte[] read = new byte[200];
+
+ System.out.println("Running supressUnreadCorrupt test");
+
+ // Encrypt 100 bytes with AES/GCM/PKCS5Padding
+ byte[] ct = encryptedText("GCM", 100);
+ // Corrupt the encrypted message
+ ct = corruptGCM(ct);
+ // Create stream for decryption
+ CipherInputStream in = getStream("GCM", ct);
+
+ try {
+ in.close();
+ System.out.println(" Pass.");
+ } catch (IOException e) {
+ System.out.println(" Fail: " + e.getMessage());
+ throw new RuntimeException(e.getCause());
+ }
+ }
+
+ /*
+ * Verify noexception thrown when 1 byte is read from a GCM stream
+ * and then closed
+ * This test:
+ * 1) Encrypt 100 bytes with AES/GCM/PKCS5Padding
+ * 2) Read one byte from the stream, expect no exception thrown.
+ * 4) Close stream,expect no exception thrown.
+ */
+ static void gcm_oneReadByte() throws Exception {
+
+ System.out.println("Running gcm_oneReadByte test");
+
+ // Encrypt 100 bytes with AES/GCM/PKCS5Padding
+ byte[] ct = encryptedText("GCM", 100);
+ // Create stream for decryption
+ CipherInputStream in = getStream("GCM", ct);
+
+ try {
+ in.read();
+ System.out.println(" Pass.");
+ } catch (Exception e) {
+ System.out.println(" Fail: " + e.getMessage());
+ throw new RuntimeException(e.getCause());
+ }
+ }
+
+ /*
+ * Verify exception thrown when 1 byte is read from a corrupted GCM stream
+ * and then closed
+ * This test:
+ * 1) Encrypt 100 bytes with AES/GCM/PKCS5Padding
+ * 2) Changes the last byte to invalidate the authetication tag.
+ * 3) Read one byte from the stream, expect exception thrown.
+ * 4) Close stream,expect no exception thrown.
+ */
+ static void gcm_oneReadByteCorrupt() throws Exception {
+
+ System.out.println("Running gcm_oneReadByteCorrupt test");
+
+ // Encrypt 100 bytes with AES/GCM/PKCS5Padding
+ byte[] ct = encryptedText("GCM", 100);
+ // Corrupt the encrypted message
+ ct = corruptGCM(ct);
+ // Create stream for decryption
+ CipherInputStream in = getStream("GCM", ct);
+
+ try {
+ in.read();
+ System.out.println(" Fail. No exception thrown.");
+ } catch (IOException e) {
+ Throwable ec = e.getCause();
+ if (ec instanceof AEADBadTagException) {
+ System.out.println(" Pass.");
+ } else {
+ System.out.println(" Fail: " + ec.getMessage());
+ throw new RuntimeException(ec);
+ }
+ }
+ }
+
+ /* Check that close() does not throw an exception with full message in
+ * CipherInputStream's ibuffer.
+ * This test:
+ * 1) Encrypts a 97 byte message with AES/CBC/PKCS5Padding
+ * 2) Create a stream that sends 96 bytes.
+ * 3) Read stream once,
+ * 4) Close and expect no exception
+ */
+
+ static void cbc_shortStream() throws Exception {
+ Cipher c;
+ AlgorithmParameters params;
+ byte[] read = new byte[200];
+
+ System.out.println("Running cbc_shortStream");
+
+ // Encrypt 97 byte with AES/CBC/PKCS5Padding
+ byte[] ct = encryptedText("CBC", 97);
+ // Create stream with only 96 bytes of encrypted data
+ CipherInputStream in = getStream("CBC", ct, 96);
+
+ try {
+ int size = in.read(read);
+ in.close();
+ if (size != 80) {
+ throw new RuntimeException("Fail: CipherInputStream.read() " +
+ "returned " + size + ". Should have been 80");
+ }
+ System.out.println(" Pass.");
+ } catch (IOException e) {
+ System.out.println(" Fail: " + e.getMessage());
+ throw new RuntimeException(e.getCause());
+ }
+ }
+
+ /* Check that close() does not throw an exception when the whole message is
+ * inside the internal buffer (ibuffer) in CipherInputStream and we read
+ * one byte and close the stream.
+ * This test:
+ * 1) Encrypts a 400 byte message with AES/CBC/PKCS5Padding
+ * 2) Read one byte from the stream
+ * 3) Close and expect no exception
+ */
+
+ static void cbc_shortRead400() throws Exception {
+ System.out.println("Running cbc_shortRead400");
+
+ // Encrypt 400 byte with AES/CBC/PKCS5Padding
+ byte[] ct = encryptedText("CBC", 400);
+ // Create stream with encrypted data
+ CipherInputStream in = getStream("CBC", ct);
+
+ try {
+ in.read();
+ in.close();
+ System.out.println(" Pass.");
+ } catch (IOException e) {
+ System.out.println(" Fail: " + e.getMessage());
+ throw new RuntimeException(e.getCause());
+ }
+ }
+
+ /* Check that close() does not throw an exception when the inside the
+ * internal buffer (ibuffer) in CipherInputStream does not contain the
+ * whole message.
+ * This test:
+ * 1) Encrypts a 600 byte message with AES/CBC/PKCS5Padding
+ * 2) Read one byte from the stream
+ * 3) Close and expect no exception
+ */
+
+ static void cbc_shortRead600() throws Exception {
+ System.out.println("Running cbc_shortRead600");
+
+ // Encrypt 600 byte with AES/CBC/PKCS5Padding
+ byte[] ct = encryptedText("CBC", 600);
+ // Create stream with encrypted data
+ CipherInputStream in = getStream("CBC", ct);
+
+ try {
+ in.read();
+ in.close();
+ System.out.println(" Pass.");
+ } catch (IOException e) {
+ System.out.println(" Fail: " + e.getMessage());
+ throw new RuntimeException(e.getCause());
+ }
+ }
+
+ /* Check that exception is thrown when message is fully read
+ * This test:
+ * 1) Encrypts a 96 byte message with AES/CBC/PKCS5Padding
+ * 2) Create a stream that sends 95 bytes.
+ * 3) Read stream to the end
+ * 4) Expect IllegalBlockSizeException thrown
+ */
+
+ static void cbc_readAllIllegalBlockSize() throws Exception {
+ byte[] read = new byte[200];
+
+ System.out.println("Running cbc_readAllIllegalBlockSize test");
+
+ // Encrypt 96 byte with AES/CBC/PKCS5Padding
+ byte[] ct = encryptedText("CBC", 96);
+ // Create a stream with only 95 bytes of encrypted data
+ CipherInputStream in = getStream("CBC", ct, 95);
+
+ try {
+ int s, size = 0;
+ while ((s = in.read(read)) != -1) {
+ size += s;
+ }
+ throw new RuntimeException("Fail: No IllegalBlockSizeException. " +
+ "CipherInputStream.read() returned " + size);
+
+ } catch (IOException e) {
+ Throwable ec = e.getCause();
+ if (ec instanceof IllegalBlockSizeException) {
+ System.out.println(" Pass.");
+ } else {
+ System.out.println(" Fail: " + ec.getMessage());
+ throw new RuntimeException(ec);
+ }
+ }
+ }
+
+ /* Generic method to create encrypted text */
+ static byte[] encryptedText(String mode, int length) throws Exception{
+ return encryptedText(mode, new byte[length]);
+ }
+
+ /* Generic method to create encrypted text */
+ static byte[] encryptedText(String mode, byte[] pt) throws Exception{
+ Cipher c;
+ if (mode.compareTo("GCM") == 0) {
+ c = Cipher.getInstance("AES/GCM/PKCS5Padding", "SunJCE");
+ c.init(Cipher.ENCRYPT_MODE, key, gcmspec);
+ } else if (mode.compareTo("CBC") == 0) {
+ c = Cipher.getInstance("AES/CBC/PKCS5Padding", "SunJCE");
+ c.init(Cipher.ENCRYPT_MODE, key, iv);
+ } else {
+ return null;
+ }
+
+ return c.doFinal(pt);
+ }
+
+ /* Generic method to get a properly setup CipherInputStream */
+ static CipherInputStream getStream(String mode, byte[] ct) throws Exception {
+ return getStream(mode, ct, ct.length);
+ }
+
+ /* Generic method to get a properly setup CipherInputStream */
+ static CipherInputStream getStream(String mode, byte[] ct, int length)
+ throws Exception {
+ Cipher c;
+
+ if (mode.compareTo("GCM") == 0) {
+ c = Cipher.getInstance("AES/GCM/PKCS5Padding", "SunJCE");
+ c.init(Cipher.DECRYPT_MODE, key, gcmspec);
+ } else if (mode.compareTo("CBC") == 0) {
+ c = Cipher.getInstance("AES/CBC/PKCS5Padding", "SunJCE");
+ c.init(Cipher.DECRYPT_MODE, key, iv);
+ } else {
+ return null;
+ }
+
+ return new CipherInputStream(new ByteArrayInputStream(ct, 0, length), c);
+
+ }
+
+ /* Generic method for corrupting a GCM message. Change the last
+ * byte on of the authentication tag
+ */
+ static byte[] corruptGCM(byte[] ct) {
+ ct[ct.length - 1] = (byte) (ct[ct.length - 1] + 1);
+ return ct;
+ }
+
+ public static void main(String[] args) throws Exception {
+ gcm_AEADBadTag();
+ gcm_shortReadAEAD();
+ gcm_suppressUnreadCorrupt();
+ gcm_oneReadByte();
+ gcm_oneReadByteCorrupt();
+ cbc_shortStream();
+ cbc_shortRead400();
+ cbc_shortRead600();
+ cbc_readAllIllegalBlockSize();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/imageio/stream/ShortStreamTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8074954
+ * @summary Test verifies that an IOException is triggered if input stream
+ * does not contain enough data to read a multi-byte type.
+ *
+ * @run main ShortStreamTest
+ */
+
+import javax.imageio.ImageIO;
+import javax.imageio.stream.ImageInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+
+public class ShortStreamTest {
+ public static void main(String[] args) throws IOException {
+ TestCase[] tests = createTests();
+
+ for (TestCase t : tests) {
+ t.test();
+ }
+ }
+
+ private static abstract class TestCase {
+ abstract void testRead(ImageInputStream iis) throws IOException;
+
+ public void test() {
+ boolean gotException = false;
+
+ ImageInputStream iis = createShortStream();
+
+ try {
+ testRead(iis);
+ } catch (IOException e) {
+ e.printStackTrace(System.out);
+ gotException = true;
+ }
+
+ if (!gotException) {
+ throw new RuntimeException("Test failed.");
+ }
+ System.out.println("Test PASSED");
+ }
+ }
+
+
+ private static ImageInputStream createShortStream() {
+ try {
+ byte[] integerTestArray = new byte[] { 80 };
+ ByteArrayInputStream bais = new ByteArrayInputStream(integerTestArray);
+
+ return ImageIO.createImageInputStream(bais);
+ } catch (IOException e) {
+ return null;
+ }
+ }
+
+ private static TestCase[] createTests() {
+ return new TestCase[]{
+ new TestCase() {
+ @Override
+ void testRead(ImageInputStream iis) throws IOException {
+ iis.readInt();
+ }
+ },
+ new TestCase() {
+ @Override
+ void testRead(ImageInputStream iis) throws IOException {
+ iis.readShort();
+ }
+ },
+ new TestCase() {
+ @Override
+ void testRead(ImageInputStream iis) throws IOException {
+ iis.readDouble();
+ }
+ },
+ new TestCase() {
+ @Override
+ void testRead(ImageInputStream iis) throws IOException {
+ iis.readFloat();
+ }
+ },
+ new TestCase() {
+ @Override
+ void testRead(ImageInputStream iis) throws IOException {
+ iis.readLong();
+ }
+ },
+ new TestCase() {
+ @Override
+ void testRead(ImageInputStream iis) throws IOException {
+ iis.readUnsignedInt();
+ }
+ },
+ new TestCase() {
+ @Override
+ void testRead(ImageInputStream iis) throws IOException {
+ iis.readUnsignedShort();
+ }
+ }
+ };
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/security/auth/spi/FirstLoginModule.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import javax.security.auth.Subject;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.login.LoginException;
+import javax.security.auth.spi.LoginModule;
+import java.util.Map;
+
+public class FirstLoginModule implements LoginModule {
+
+ @Override
+ public void initialize(Subject subject, CallbackHandler callbackHandler,
+ Map<String, ?> sharedState, Map<String, ?> options) {
+ // Nothing
+ }
+
+ @Override
+ public boolean login() throws LoginException {
+ return true;
+ }
+
+ @Override
+ public boolean commit() throws LoginException {
+ return true;
+ }
+
+ @Override
+ public boolean abort() throws LoginException {
+ return true;
+ }
+
+ @Override
+ public boolean logout() throws LoginException {
+ return true;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/security/auth/spi/Loader.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import javax.security.auth.login.LoginContext;
+import java.io.File;
+
+/*
+ * @test
+ * @bug 8047789
+ * @summary auth.login.LoginContext needs to be updated to work with modules
+ * @build FirstLoginModule SecondLoginModule
+ * @run main/othervm Loader
+ */
+public class Loader {
+
+ public static void main(String[] args) throws Exception {
+
+ System.setProperty("java.security.auth.login.config",
+ new File(System.getProperty("test.src"), "sl.conf").toString());
+ LoginContext lc = new LoginContext("me");
+
+ if (SecondLoginModule.isLoaded) {
+ throw new Exception();
+ }
+
+ lc.login();
+
+ // Although only FirstLoginModule is specified in the JAAS login
+ // config file, LoginContext will first create all LoginModule
+ // implementations that are registered as services, which include
+ // SecondLoginModule.
+ if (!SecondLoginModule.isLoaded) {
+ throw new Exception();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/security/auth/spi/META-INF/services/javax.security.auth.spi.LoginModule Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,1 @@
+SecondLoginModule
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/security/auth/spi/SecondLoginModule.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import javax.security.auth.Subject;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.login.LoginException;
+import javax.security.auth.spi.LoginModule;
+import java.util.Map;
+
+public class SecondLoginModule implements LoginModule {
+
+ public static boolean isLoaded;
+
+ public SecondLoginModule() {
+ isLoaded = true;
+ }
+
+ @Override
+ public void initialize(Subject subject, CallbackHandler callbackHandler,
+ Map<String, ?> sharedState, Map<String, ?> options) {
+ // Nothing
+ }
+
+ @Override
+ public boolean login() throws LoginException {
+ return true;
+ }
+
+ @Override
+ public boolean commit() throws LoginException {
+ return true;
+ }
+
+ @Override
+ public boolean abort() throws LoginException {
+ return true;
+ }
+
+ @Override
+ public boolean logout() throws LoginException {
+ return true;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/security/auth/spi/sl.conf Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,3 @@
+me {
+ FirstLoginModule required;
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JTableHeader/4473075/bug4473075.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ @bug 4473075
+ @summary JTable header rendering problem (after setting preferred size)
+ @author Semyon Sadetsky
+*/
+
+import javax.swing.*;
+import javax.swing.table.DefaultTableModel;
+import java.awt.*;
+import java.awt.event.InputEvent;
+
+public class bug4473075 {
+ public static final int USER_HEADER_HEIGHT = 40;
+ private static JTable table;
+ private static JScrollPane scpScroll;
+ private static Point point;
+ private static JFrame frame;
+
+ public static void main(String[] args) throws Exception {
+ Robot robot = new Robot();
+ robot.setAutoDelay(20);
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ frame = new JFrame();
+ frame.setUndecorated(true);
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ table = new JTable();
+ String t = "a cell text";
+ table.setModel(new DefaultTableModel(
+ new Object[][]{new Object[]{t, t, t, t, t}},
+ new Object[]{t, t, t, t, t}));
+ table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
+ scpScroll = new JScrollPane(table);
+
+ // Manually set preferred size of header...
+ Dimension preferredSize = new Dimension(table.getSize().width,
+ USER_HEADER_HEIGHT);
+ table.getTableHeader().setPreferredSize(preferredSize);
+
+ frame.setContentPane(scpScroll);
+ frame.setSize(250, 480);
+ frame.setLocationRelativeTo(null);
+ frame.setVisible(true);
+ point = scpScroll.getHorizontalScrollBar()
+ .getLocationOnScreen();
+ }
+ });
+ robot.waitForIdle();
+
+ robot.mouseMove(point.x + 100, point.y + 5);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseMove(point.x + 150, point.y + 5);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+ int headerH = table.getTableHeader().getHeight();
+ if (headerH != USER_HEADER_HEIGHT) {
+ throw new RuntimeException("TableHeader height was not set: "
+ + headerH + " !=" + USER_HEADER_HEIGHT);
+ }
+
+ double tableX = table.getX();
+ int headerX = table.getTableHeader().getX();
+ if (tableX != headerX) {
+ throw new RuntimeException("TableHeader X position is wrong: "
+ + tableX + " !=" + headerX);
+ }
+
+ double tableW = table.getWidth();
+ int headerW = table.getTableHeader().getWidth();
+ if (tableW != headerW) {
+ throw new RuntimeException("TableHeader width is wrong: "
+ + tableW + " !=" + headerW);
+ }
+
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ frame.dispose();
+ }
+ });
+ System.out.println("ok");
+ }
+}
--- a/jdk/test/javax/swing/ToolTipManager/7123767/bug7123767.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/test/javax/swing/ToolTipManager/7123767/bug7123767.java Tue Apr 14 12:10:00 2015 -0700
@@ -28,8 +28,6 @@
@run main bug7123767
*/
-import sun.awt.SunToolkit;
-
import javax.swing.*;
import javax.swing.plaf.metal.MetalLookAndFeel;
import java.awt.*;
@@ -160,8 +158,10 @@
// Moves mouse pointer to the corners of every GraphicsConfiguration
private static void testToolTip() throws AWTException {
- SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
- toolkit.realSync();
+
+ robot = new Robot();
+ robot.setAutoDelay(20);
+ robot.waitForIdle();
GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] devices = environment.getScreenDevices();
@@ -169,28 +169,28 @@
GraphicsConfiguration[] configs = device.getConfigurations();
for (GraphicsConfiguration config : configs) {
Rectangle rect = config.getBounds();
- Insets insets = toolkit.getScreenInsets(config);
+ Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(config);
adjustInsets(rect, insets);
// Upper left
glide(rect.x + rect.width / 2, rect.y + rect.height / 2,
rect.x + MARGIN, rect.y + MARGIN);
- toolkit.realSync();
+ robot.waitForIdle();
// Lower left
glide(rect.x + rect.width / 2, rect.y + rect.height / 2,
rect.x + MARGIN, rect.y + rect.height - MARGIN);
- toolkit.realSync();
+ robot.waitForIdle();
// Upper right
glide(rect.x + rect.width / 2, rect.y + rect.height / 2,
rect.x + rect.width - MARGIN, rect.y + MARGIN);
- toolkit.realSync();
+ robot.waitForIdle();
// Lower right
glide(rect.x + rect.width / 2, rect.y + rect.height / 2,
rect.x + rect.width - MARGIN, rect.y + rect.height - MARGIN);
- toolkit.realSync();
+ robot.waitForIdle();
}
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/plaf/synth/8040328/bug8040328.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ @bug 8040328
+ @summary JSlider has wrong preferred size with Synth LAF
+ @author Semyon Sadetsky
+*/
+
+import javax.swing.*;
+import javax.swing.plaf.synth.SynthLookAndFeel;
+import java.awt.*;
+import java.io.ByteArrayInputStream;
+
+public class bug8040328 {
+ private static String synthXml = "<synth>" +
+ " <style id=\"all\">" +
+ " <font name=\"Segoe UI\" size=\"12\"/>" +
+ " </style>" +
+ " <bind style=\"all\" type=\"REGION\" key=\".*\"/>" +
+ " <style id=\"slider\">" +
+ " <insets top=\"10\" left=\"5\" bottom=\"10\" right=\"5\"/>" +
+ " </style>" +
+ " <bind style=\"slider\" type=\"region\" key=\"Slider\"/>" +
+ "</synth>";
+
+ public static void main(String[] args) throws Exception {
+ SynthLookAndFeel lookAndFeel = new SynthLookAndFeel();
+ lookAndFeel.load(new ByteArrayInputStream(synthXml.getBytes("UTF8")),
+ bug8040328.class);
+ UIManager.setLookAndFeel(lookAndFeel);
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ final JFrame frame = new JFrame();
+ try {
+ frame.setUndecorated(true);
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.setVisible(true);
+ test(frame);
+ } finally {
+ frame.dispose();
+ }
+ }
+ });
+ System.out.println("ok");
+ }
+
+ static void test(JFrame frame) {
+ JSlider hslider = new JSlider(JSlider.HORIZONTAL);
+ hslider.setBackground(Color.DARK_GRAY);
+ frame.getContentPane().add(hslider, BorderLayout.CENTER);
+ frame.getContentPane().setBackground(Color.CYAN);
+ frame.pack();
+ Insets insets = hslider.getInsets();
+ if (hslider.getWidth() != 200 + insets.left + insets.right) {
+ throw new RuntimeException(
+ "Horizontal slider width is wrong " + hslider.getWidth());
+ }
+ if (hslider.getHeight() != hslider.getMinimumSize().height) {
+ throw new RuntimeException(
+ "Horizontal slider height is wrong " + hslider.getHeight());
+ }
+ frame.getContentPane().remove(hslider);
+
+ JSlider vslider = new JSlider(JSlider.VERTICAL);
+ frame.getContentPane().add(vslider);
+ frame.pack();
+ insets = vslider.getInsets();
+ if (vslider.getWidth() != vslider.getMinimumSize().width) {
+ throw new RuntimeException(
+ "Verical slider width is wrong " + vslider.getWidth());
+ }
+ if (vslider.getHeight() != 200 + insets.top + insets.bottom) {
+ throw new RuntimeException(
+ "Verical slider height is wrong " + vslider.getHeight());
+ }
+ }
+}
--- a/jdk/test/javax/xml/jaxp/transform/8062923/XslSubstringTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/test/javax/xml/jaxp/transform/8062923/XslSubstringTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -23,10 +23,11 @@
/**
* @test
- * @bug 8062923 8062924
+ * @bug 8062923 8062924 8074297 8076290
* @run testng XslSubstringTest
* @summary Test xsl substring function with negative, Inf and
- * NaN length and few other use cases
+ * NaN length and few other use cases. Also test proper
+ * processing of supplementary characters by substring function.
*/
import java.io.StringReader;
@@ -39,6 +40,7 @@
import javax.xml.transform.stream.StreamSource;
import static org.testng.Assert.assertEquals;
+import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
public class XslSubstringTest {
@@ -50,6 +52,36 @@
+ "<xsl:template match='/'><t>";
final String xslPost = "</t></xsl:template></xsl:stylesheet>";
+ @DataProvider(name = "GeneralTestsData")
+ private Object[][] xmls() {
+ return new Object[][] {
+ { "|<xsl:value-of select=\"substring('asdf',2, 1)\"/>|", "<t>|s|</t>"},
+ { "|<xsl:value-of select=\"substring('asdf',2, 1 div 0)\"/>|", "<t>|sdf|</t>"},
+ { "|<xsl:value-of select=\"substring('asdf',2, -0 div 0)\"/>|", "<t>||</t>" },
+ { "|<xsl:value-of select=\"substring('asdf',2, 1 div 0)\"/>|", "<t>|sdf|</t>" },
+ // 8076290 bug test case
+ { "|<xsl:value-of select=\"substring('123', 0, 3)\"/>|", "<t>|12|</t>"},
+ };
+ }
+
+ @DataProvider(name = "SupplementaryCharactersTestData")
+ private Object[][] dataSupplementaryCharacters() {
+ return new Object[][] {
+ // 8074297 bug test cases
+ { "|<xsl:value-of select=\"substring('𠀋ABC', 3)\"/>|", "<t>|BC|</t>"},
+ { "|<xsl:value-of select=\"substring('𠀋ABC', 3, 1)\"/>|", "<t>|B|</t>" },
+ { "|<xsl:value-of select=\"substring('𠀋ABC', 2, 2)\"/>|", "<t>|AB|</t>"},
+ { "|<xsl:value-of select=\"substring('𠀋ABC', 3, 2)\"/>|", "<t>|BC|</t>"},
+ { "|<xsl:value-of select=\"substring('𠀋ABC', 3, 4)\"/>|", "<t>|BC|</t>"},
+ { "|<xsl:value-of select=\"substring('𠀋ABC', 1, 1)\"/>|", "<t>|𠀋|</t>"},
+ { "|<xsl:value-of select=\"substring('𠀋ABC', 2, 1)\"/>|", "<t>|A|</t>"},
+ { "|<xsl:value-of select=\"substring('𠀋ABC', 1, 1 div 0)\"/>|", "<t>|𠀋ABC|</t>"},
+ { "|<xsl:value-of select=\"substring('𠀋ABC', -10, 1 div 0)\"/>|", "<t>|𠀋ABC|</t>"},
+ // 8076290 bug test case
+ { "|<xsl:value-of select=\"substring('𠀋ABC', 0, 2)\"/>|", "<t>|𠀋|</t>"},
+ };
+ }
+
private String testTransform(String xsl) throws Exception {
//Prepare sources for transormation
Source src = new StreamSource(new StringReader(xml));
@@ -78,27 +110,14 @@
"<t>||</t>");
}
- @Test
- public void testGeneral1() throws Exception {
- assertEquals(testTransform("|<xsl:value-of select=\"substring('asdf',2, 1)\"/>|"),
- "<t>|s|</t>");
- }
-
- @Test
- public void testGeneral2() throws Exception {
- assertEquals(testTransform("|<xsl:value-of select=\"substring('asdf',2, 1 div 0)\"/>|"),
- "<t>|sdf|</t>");
+ @Test(dataProvider = "GeneralTestsData")
+ public void testGeneralAll(String xsl, String result) throws Exception {
+ assertEquals(testTransform(xsl), result);
}
- @Test
- public void testGeneral3() throws Exception {
- assertEquals(testTransform("|<xsl:value-of select=\"substring('asdf',2, -0 div 0)\"/>|"),
- "<t>||</t>");
+ @Test(dataProvider = "SupplementaryCharactersTestData")
+ public void testSupplementCharacters(String xsl, String result) throws Exception {
+ assertEquals(testTransform(xsl), result);
}
- @Test
- public void testGeneral4() throws Exception {
- assertEquals(testTransform("|<xsl:value-of select=\"substring('asdf',2, 0 div 0)\"/>|"),
- "<t>||</t>");
- }
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/jdk/internal/jimage/JImageTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+/*
+ * @test
+ * @library /lib/testlibrary
+ * @build jdk.testlibrary.*
+ * @summary Test to see if jimage tool extracts and recreates correctly.
+ * @run main/timeout=360 JImageTest
+ */
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import jdk.testlibrary.ProcessTools;
+
+
+/**
+ * Basic test for jimage tool.
+ */
+public class JImageTest {
+ private static void jimage(String... jimageArgs) throws Exception {
+ ArrayList<String> args = new ArrayList<>();
+ args.add("-ms8m");
+ args.add("jdk.tools.jimage.Main");
+ args.addAll(Arrays.asList(jimageArgs));
+
+ ProcessBuilder builder = ProcessTools.createJavaProcessBuilder(args.toArray(new String[args.size()]));
+ int res = builder.inheritIO().start().waitFor();
+
+ if (res != 0) {
+ throw new RuntimeException("JImageTest tool FAILED");
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ final String JAVA_HOME = System.getProperty("java.home");
+ Path jimagePath = Paths.get(JAVA_HOME, "bin", "jimage");
+ Path bootimagePath = Paths.get(JAVA_HOME, "lib", "modules", "bootmodules.jimage");
+
+ if (Files.exists(jimagePath) && Files.exists(bootimagePath)) {
+ String jimage = jimagePath.toAbsolutePath().toString();
+ String bootimage = bootimagePath.toAbsolutePath().toString();
+ String extractDir = Paths.get(".", "extract").toAbsolutePath().toString();
+ String recreateImage = Paths.get(".", "recreate.jimage").toAbsolutePath().toString();
+
+ jimage("extract", "--dir", extractDir, bootimage);
+ jimage("recreate", "--dir", extractDir, recreateImage);
+
+ System.out.println("Test successful");
+ } else {
+ System.out.println("Test skipped, no module image");
+ }
+
+ }
+}
--- a/jdk/test/jdk/lambda/FDTest.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,192 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-import shapegen.*;
-
-import com.sun.source.util.JavacTask;
-import com.sun.tools.javac.util.Pair;
-
-import java.net.URI;
-import java.util.Arrays;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import javax.tools.Diagnostic;
-import javax.tools.JavaCompiler;
-import javax.tools.JavaFileObject;
-import javax.tools.SimpleJavaFileObject;
-import javax.tools.StandardJavaFileManager;
-import javax.tools.ToolProvider;
-
-import org.testng.annotations.Test;
-import org.testng.annotations.BeforeSuite;
-import org.testng.annotations.DataProvider;
-import static org.testng.Assert.*;
-
-public class FDTest {
-
- public enum TestKind {
- POSITIVE,
- NEGATIVE;
-
- Collection<Hierarchy> getHierarchy(HierarchyGenerator hg) {
- return this == POSITIVE ?
- hg.getOK() : hg.getErr();
- }
- }
-
- public static JavaCompiler comp;
- public static StandardJavaFileManager fm;
-
- @BeforeSuite
- static void init() {
- // create default shared JavaCompiler - reused across multiple
- // compilations
-
- comp = ToolProvider.getSystemJavaCompiler();
- fm = comp.getStandardFileManager(null, null, null);
- }
-
- public static void main(String[] args) throws Exception {
- init();
-
- for (Pair<TestKind,Hierarchy> fdtest : generateCases()) {
- runTest(fdtest.fst, fdtest.snd, comp, fm);
- }
- }
-
- @Test(dataProvider = "fdCases")
- public void testOneCase(TestKind tk, Hierarchy hs)
- throws Exception {
- FDTest.runTest(tk, hs, comp, fm);
- }
-
- @DataProvider(name = "fdCases")
- public Object[][] caseGenerator() {
- List<Pair<TestKind, Hierarchy>> cases = generateCases();
- Object[][] fdCases = new Object[cases.size()][];
- for (int i = 0; i < cases.size(); ++i) {
- fdCases[i] = new Object[2];
- fdCases[i][0] = cases.get(i).fst;
- fdCases[i][1] = cases.get(i).snd;
- }
- return fdCases;
- }
-
- public static List<Pair<TestKind, Hierarchy>> generateCases() {
- ArrayList<Pair<TestKind,Hierarchy>> list = new ArrayList<>();
- HierarchyGenerator hg = new HierarchyGenerator();
- for (TestKind tk : TestKind.values()) {
- for (Hierarchy hs : tk.getHierarchy(hg)) {
- list.add(new Pair<>(tk, hs));
- }
- }
- return list;
- }
-
- public static void runTest(TestKind tk, Hierarchy hs,
- JavaCompiler comp, StandardJavaFileManager fm) throws Exception {
- new FDTest(tk, hs).run(comp, fm);
- }
-
- TestKind tk;
- Hierarchy hs;
- DefenderTestSource source;
- DiagnosticChecker diagChecker;
-
- public FDTest() {}
-
- FDTest(TestKind tk, Hierarchy hs) {
- this.tk = tk;
- this.hs = hs;
- this.source = new DefenderTestSource();
- this.diagChecker = new DiagnosticChecker();
- }
-
- void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
- JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
- null, null, Arrays.asList(source));
- try {
- ct.analyze();
- } catch (Throwable ex) {
- fail("Error thrown when analyzing the following source:\n" + source.getCharContent(true));
- }
- check();
- }
-
- void check() {
- boolean errorExpected = tk == TestKind.NEGATIVE;
- if (errorExpected != diagChecker.errorFound) {
- fail("problem in source: \n" +
- "\nerror found = " + diagChecker.errorFound +
- "\nerror expected = " + errorExpected +
- "\n" + dumpHierarchy() +
- "\n" + source.getCharContent(true));
- }
- }
-
- String dumpHierarchy() {
- StringBuilder buf = new StringBuilder();
- buf.append("root = " + hs.root + "\n");
- for (ClassCase cc : hs.all) {
- buf.append(" class name = " + cc.getName() + "\n");
- buf.append(" class OK = " + cc.get_OK() + "\n");
- buf.append(" prov = " + cc.get_mprov() + "\n");
-
- }
- return buf.toString();
- }
-
- class DefenderTestSource extends SimpleJavaFileObject {
-
- String source;
-
- public DefenderTestSource() {
- super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
- StringBuilder buf = new StringBuilder();
- List<ClassCase> defaultRef = new ArrayList<>();
- for (ClassCase cc : hs.all) {
- Hierarchy.genClassDef(buf, cc, null, defaultRef);
- }
- source = buf.toString();
- }
-
- @Override
- public CharSequence getCharContent(boolean ignoreEncodingErrors) {
- return source;
- }
- }
-
- static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
-
- boolean errorFound;
-
- public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
- if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
- errorFound = true;
- }
- }
- }
-}
--- a/jdk/test/jdk/lambda/LambdaTranslationInInterface.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import static org.testng.Assert.assertEquals;
-import org.testng.annotations.Test;
-
-/**
- * @author Robert Field
- */
-
-interface LTII {
-
- interface ILsp1 {
- String m();
- }
-
- interface ILsp2 {
- String m(String x);
- }
-
- default ILsp1 t1() {
- return () -> { return "yo"; };
- }
-
- default ILsp2 t2() {
- return (x) -> { return "snur" + x; };
- }
-
-}
-
-@Test
-public class LambdaTranslationInInterface implements LTII {
-
- public void testLambdaInDefaultMethod() {
- assertEquals(t1().m(), "yo");
- assertEquals(t2().m("p"), "snurp");
- }
-
-}
--- a/jdk/test/jdk/lambda/LambdaTranslationInnerConstructor.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import static org.testng.Assert.assertEquals;
-import org.testng.annotations.Test;
-
-/**
- * @author Robert Field
- */
-
-@Test
-public class LambdaTranslationInnerConstructor {
-
- public void testLambdaWithInnerConstructor() {
- assertEquals(seq1().m().toString(), "Cbl:nada");
- assertEquals(seq2().m("rats").toString(), "Cbl:rats");
- }
-
- Ib1 seq1() {
- return () -> { return new Cbl(); };
- }
-
- Ib2 seq2() {
- return (x) -> { return new Cbl(x); };
- }
-
- class Cbl {
- String val;
-
- Cbl() {
- this.val = "nada";
- }
-
- Cbl(String z) {
- this.val = z;
- }
-
- public String toString() {
- return "Cbl:" + val;
- }
- }
-
- interface Ib1 {
- Object m();
- }
-
- interface Ib2 {
- Object m(String x);
- }
-}
\ No newline at end of file
--- a/jdk/test/jdk/lambda/MethodReferenceTestFDCCE.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,146 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import org.testng.annotations.Test;
-import java.lang.reflect.Array;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
-
-/**
- * Method references and raw types.
- * @author Robert Field
- */
-
-@Test
-@SuppressWarnings({"rawtypes", "unchecked"})
-public class MethodReferenceTestFDCCE {
-
- static void assertCCE(Throwable t) {
- assertEquals(t.getClass().getName(), "java.lang.ClassCastException");
- }
-
- interface Pred<T> { boolean accept(T x); }
-
- interface Ps { boolean accept(short x); }
-
- interface Oo { Object too(int x); }
-
- interface Reto<T> { T m(); }
-
- class A {}
- class B extends A {}
-
- static boolean isMinor(int x) {
- return x < 18;
- }
-
- static boolean tst(A x) {
- return true;
- }
-
- static Object otst(Object x) {
- return x;
- }
-
- static boolean stst(Short x) {
- return x < 18;
- }
-
- static short ritst() {
- return 123;
- }
-
- public void testMethodReferenceFDPrim1() {
- Pred<Byte> p = MethodReferenceTestFDCCE::isMinor;
- Pred p2 = p;
- assertTrue(p2.accept((Byte)(byte)15));
- }
-
- public void testMethodReferenceFDPrim2() {
- Pred<Byte> p = MethodReferenceTestFDCCE::isMinor;
- Pred p2 = p;
- assertTrue(p2.accept((byte)15));
- }
-
- public void testMethodReferenceFDPrimICCE() {
- Pred<Byte> p = MethodReferenceTestFDCCE::isMinor;
- Pred p2 = p;
- try {
- p2.accept(15); // should throw CCE
- fail("Exception should have been thrown");
- } catch (Throwable t) {
- assertCCE(t);
- }
- }
-
- public void testMethodReferenceFDPrimOCCE() {
- Pred<Byte> p = MethodReferenceTestFDCCE::isMinor;
- Pred p2 = p;
- try {
- p2.accept(new Object()); // should throw CCE
- fail("Exception should have been thrown");
- } catch (Throwable t) {
- assertCCE(t);
- }
- }
-
- public void testMethodReferenceFDRef() {
- Pred<B> p = MethodReferenceTestFDCCE::tst;
- Pred p2 = p;
- assertTrue(p2.accept(new B()));
- }
-
- public void testMethodReferenceFDRefCCE() {
- Pred<B> p = MethodReferenceTestFDCCE::tst;
- Pred p2 = p;
- try {
- p2.accept(new A()); // should throw CCE
- fail("Exception should have been thrown");
- } catch (Throwable t) {
- assertCCE(t);
- }
- }
-
- public void testMethodReferenceFDPrimPrim() {
- Ps p = MethodReferenceTestFDCCE::isMinor;
- assertTrue(p.accept((byte)15));
- }
-
- public void testMethodReferenceFDPrimBoxed() {
- Ps p = MethodReferenceTestFDCCE::stst;
- assertTrue(p.accept((byte)15));
- }
-
- public void testMethodReferenceFDPrimRef() {
- Oo p = MethodReferenceTestFDCCE::otst;
- assertEquals(p.too(15).getClass().getName(), "java.lang.Integer");
- }
-
- public void testMethodReferenceFDRet1() {
- Reto<Short> p = MethodReferenceTestFDCCE::ritst;
- assertEquals(p.m(), (Short)(short)123);
- }
-
-}
\ No newline at end of file
--- a/jdk/test/jdk/lambda/MethodReferenceTestInnerDefault.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import org.testng.annotations.Test;
-
-import static org.testng.Assert.assertEquals;
-
-/**
- * @author Robert Field
- */
-
-interface IDSs { String m(String a); }
-
-interface InDefA {
- default String xsA__(String s) {
- return "A__xsA:" + s;
- }
-
- default String xsAB_(String s) {
- return "AB_xsA:" + s;
- }
-
-}
-
-interface InDefB extends InDefA {
-
- default String xsAB_(String s) {
- return "AB_xsB:" + s;
- }
-
- default String xs_B_(String s) {
- return "_B_xsB:" + s;
- }
-}
-
-@Test
-public class MethodReferenceTestInnerDefault implements InDefB {
-
- public void testMethodReferenceInnerDefault() {
- (new In()).testMethodReferenceInnerDefault();
- }
-
- class In {
-
- public void testMethodReferenceInnerDefault() {
- IDSs q;
-
- q = MethodReferenceTestInnerDefault.this::xsA__;
- assertEquals(q.m("*"), "A__xsA:*");
-
- q = MethodReferenceTestInnerDefault.this::xsAB_;
- assertEquals(q.m("*"), "AB_xsB:*");
-
- q = MethodReferenceTestInnerDefault.this::xs_B_;
- assertEquals(q.m("*"), "_B_xsB:*");
- }
- }
-
-}
--- a/jdk/test/jdk/lambda/MethodReferenceTestInnerInstance.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import org.testng.annotations.Test;
-
-import static org.testng.Assert.assertEquals;
-
-/**
- * @author Robert Field
- */
-
-@Test
-public class MethodReferenceTestInnerInstance {
-
- public void testMethodReferenceInnerInstance() {
- cia().cib().testMethodReferenceInstance();
- }
-
- public void testMethodReferenceInnerExternal() {
- cia().cib().testMethodReferenceExternal();
- }
-
- interface SI {
- String m(Integer a);
- }
-
- class CIA {
-
- String xI(Integer i) {
- return "xI:" + i;
- }
-
- public class CIB {
-
- public void testMethodReferenceInstance() {
- SI q;
-
- q = CIA.this::xI;
- assertEquals(q.m(55), "xI:55");
- }
-
- public void testMethodReferenceExternal() {
- SI q;
-
- q = (new E())::xI;
- assertEquals(q.m(77), "ExI:77");
- }
- }
-
- CIB cib() {
- return new CIB();
- }
-
- class E {
-
- String xI(Integer i) {
- return "ExI:" + i;
- }
- }
-
- }
-
- CIA cia() {
- return new CIA();
- }
-}
--- a/jdk/test/jdk/lambda/MethodReferenceTestInnerVarArgsThis.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,241 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import org.testng.annotations.Test;
-import java.lang.reflect.Array;
-
-import static org.testng.Assert.assertEquals;
-
-/**
- * @author Robert Field
- */
-
-@Test
-public class MethodReferenceTestInnerVarArgsThis {
-
- interface NsII {
-
- String m(Integer a, Integer b);
- }
-
- interface Nsiii {
-
- String m(int a, int b, int c);
- }
-
- interface Nsi {
-
- String m(int a);
- }
-
- interface NsaO {
-
- String m(Object[] a);
- }
-
- interface Nsai {
-
- String m(int[] a);
- }
-
- interface Nsvi {
-
- String m(int... va);
- }
-
- class CIA {
-
- String xvI(Integer... vi) {
- StringBuilder sb = new StringBuilder("xvI:");
- for (Integer i : vi) {
- sb.append(i);
- sb.append("-");
- }
- return sb.toString();
- }
-
- String xIvI(Integer f, Integer... vi) {
- StringBuilder sb = new StringBuilder("xIvI:");
- sb.append(f);
- for (Integer i : vi) {
- sb.append(i);
- sb.append("-");
- }
- return sb.toString();
- }
-
- String xvi(int... vi) {
- int sum = 0;
- for (int i : vi) {
- sum += i;
- }
- return "xvi:" + sum;
- }
-
- String xIvi(Integer f, int... vi) {
- int sum = 0;
- for (int i : vi) {
- sum += i;
- }
- return "xIvi:(" + f + ")" + sum;
- }
-
- String xvO(Object... vi) {
- StringBuilder sb = new StringBuilder("xvO:");
- for (Object i : vi) {
- if (i.getClass().isArray()) {
- sb.append("[");
- int len = Array.getLength(i);
- for (int x = 0; x < len; ++x) {
- sb.append(Array.get(i, x));
- sb.append(",");
- }
- sb.append("]");
-
- } else {
- sb.append(i);
- }
- sb.append("*");
- }
- return sb.toString();
- }
-
- public class CIB {
-
- // These should be processed as var args
- public void testVarArgsNsSuperclass() {
- NsII q;
-
- q = CIA.this::xvO;
- assertEquals(q.m(55, 66), "xvO:55*66*");
- }
-
- public void testVarArgsNsArray() {
- Nsai q;
-
- q = CIA.this::xvO;
- assertEquals(q.m(new int[]{55, 66}), "xvO:[55,66,]*");
- }
-
- public void testVarArgsNsII() {
- NsII q;
-
- q = CIA.this::xvI;
- assertEquals(q.m(33, 7), "xvI:33-7-");
-
- q = CIA.this::xIvI;
- assertEquals(q.m(50, 40), "xIvI:5040-");
-
- q = CIA.this::xvi;
- assertEquals(q.m(100, 23), "xvi:123");
-
- q = CIA.this::xIvi;
- assertEquals(q.m(9, 21), "xIvi:(9)21");
- }
-
- public void testVarArgsNsiii() {
- Nsiii q;
-
- q = CIA.this::xvI;
- assertEquals(q.m(3, 2, 1), "xvI:3-2-1-");
-
- q = CIA.this::xIvI;
- assertEquals(q.m(888, 99, 2), "xIvI:88899-2-");
-
- q = CIA.this::xvi;
- assertEquals(q.m(900, 80, 7), "xvi:987");
-
- q = CIA.this::xIvi;
- assertEquals(q.m(333, 27, 72), "xIvi:(333)99");
- }
-
- public void testVarArgsNsi() {
- Nsi q;
-
- q = CIA.this::xvI;
- assertEquals(q.m(3), "xvI:3-");
-
- q = CIA.this::xIvI;
- assertEquals(q.m(888), "xIvI:888");
-
- q = CIA.this::xvi;
- assertEquals(q.m(900), "xvi:900");
-
- q = CIA.this::xIvi;
- assertEquals(q.m(333), "xIvi:(333)0");
- }
-
- // These should NOT be processed as var args
- public void testVarArgsNsaO() {
- NsaO q;
-
- q = CIA.this::xvO;
- assertEquals(q.m(new String[]{"yo", "there", "dude"}), "xvO:yo*there*dude*");
- }
- }
-
- CIB cib() {
- return new CIB();
- }
-
- class E {
-
- String xI(Integer i) {
- return "ExI:" + i;
- }
- }
- }
-
- CIA cia() {
- return new CIA();
- }
-
- // These should be processed as var args
- public void testVarArgsNsSuperclass() {
- cia().cib().testVarArgsNsSuperclass();
- }
-
- public void testVarArgsNsArray() {
- cia().cib().testVarArgsNsArray();
- }
-
- public void testVarArgsNsII() {
- cia().cib().testVarArgsNsII();
- }
-
- public void testVarArgsNsiii() {
- cia().cib().testVarArgsNsiii();
- }
-
- public void testVarArgsNsi() {
- cia().cib().testVarArgsNsi();
- }
-
- // These should NOT be processed as var args
-
- public void testVarArgsNsaO() {
- cia().cib().testVarArgsNsaO();
- }
-
-
-}
--- a/jdk/test/jdk/lambda/MethodReferenceTestInstance.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import org.testng.annotations.Test;
-
-import static org.testng.Assert.assertEquals;
-
-/**
- * @author Robert Field
- */
-
-class MethodReferenceTestInstance_E {
- String xI(Integer i) {
- return "ExI:" + i;
- }
-}
-
-@Test
-public class MethodReferenceTestInstance {
-
- interface SI { String m(Integer a); }
-
- String xI(Integer i) {
- return "xI:" + i;
- }
-
- public void testMethodReferenceInstance() {
- SI q;
-
- q = this::xI;
- assertEquals(q.m(55), "xI:55");
- }
-
- public void testMethodReferenceExternal() {
- SI q;
-
- q = (new MethodReferenceTestInstance_E())::xI;
- assertEquals(q.m(77), "ExI:77");
- }
-
-}
--- a/jdk/test/jdk/lambda/MethodReferenceTestKinds.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,173 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-import org.testng.annotations.Test;
-
-import static org.testng.Assert.assertEquals;
-
-/**
- * @author Robert Field
- */
-
-@Test
-public class MethodReferenceTestKinds extends MethodReferenceTestKindsSup {
-
- interface S0 { String get(); }
- interface S1 { String get(MethodReferenceTestKinds x); }
- interface S2 { String get(MethodReferenceTestKinds x, MethodReferenceTestKinds y); }
-
- interface SXN0 { MethodReferenceTestKindsBase make(MethodReferenceTestKinds x); }
- interface SXN1 { MethodReferenceTestKindsBase make(MethodReferenceTestKinds x, String str); }
-
- interface SN0 { MethodReferenceTestKindsBase make(); }
- interface SN1 { MethodReferenceTestKindsBase make(String x); }
-
- class In extends MethodReferenceTestKindsBase {
- In(String val) {
- this.val = val;
- }
-
- In() {
- this("blank");
- }
- }
-
- String instanceMethod0() { return "IM:0-" + this; }
- String instanceMethod1(MethodReferenceTestKinds x) { return "IM:1-" + this + x; }
-
- static String staticMethod0() { return "SM:0"; }
- static String staticMethod1(MethodReferenceTestKinds x) { return "SM:1-" + x; }
-
- MethodReferenceTestKinds(String val) {
- super(val);
- }
-
- MethodReferenceTestKinds() {
- super("blank");
- }
-
- MethodReferenceTestKinds inst(String val) {
- return new MethodReferenceTestKinds(val);
- }
-
- public void testMRBound() {
- S0 var = this::instanceMethod0;
- assertEquals(var.get(), "IM:0-MethodReferenceTestKinds(blank)");
- }
-
- public void testMRBoundArg() {
- S1 var = this::instanceMethod1;
- assertEquals(var.get(inst("arg")), "IM:1-MethodReferenceTestKinds(blank)MethodReferenceTestKinds(arg)");
- }
-
- public void testMRUnbound() {
- S1 var = MethodReferenceTestKinds::instanceMethod0;
- assertEquals(var.get(inst("rcvr")), "IM:0-MethodReferenceTestKinds(rcvr)");
- }
-
- public void testMRUnboundArg() {
- S2 var = MethodReferenceTestKinds::instanceMethod1;
- assertEquals(var.get(inst("rcvr"), inst("arg")), "IM:1-MethodReferenceTestKinds(rcvr)MethodReferenceTestKinds(arg)");
- }
-
- public void testMRSuper() {
- S0 var = super::instanceMethod0;
- assertEquals(var.get(), "SIM:0-MethodReferenceTestKinds(blank)");
- }
-
- public void testMRSuperArg() {
- S1 var = super::instanceMethod1;
- assertEquals(var.get(inst("arg")), "SIM:1-MethodReferenceTestKinds(blank)MethodReferenceTestKinds(arg)");
- }
-
- public void testMRStatic() {
- S0 var = MethodReferenceTestKinds::staticMethod0;
- assertEquals(var.get(), "SM:0");
- }
-
- public void testMRStaticArg() {
- S1 var = MethodReferenceTestKinds::staticMethod1;
- assertEquals(var.get(inst("arg")), "SM:1-MethodReferenceTestKinds(arg)");
- }
-
- public void testMRTopLevel() {
- SN0 var = MethodReferenceTestKindsBase::new;
- assertEquals(var.make().toString(), "MethodReferenceTestKindsBase(blank)");
- }
-
- public void testMRTopLevelArg() {
- SN1 var = MethodReferenceTestKindsBase::new;
- assertEquals(var.make("name").toString(), "MethodReferenceTestKindsBase(name)");
- }
-/* unbound inner case not supported anymore (dropped by EG)
- public void testMRUnboundInner() {
- SXN0 var = MethodReferenceTestKinds.In::new;
- assertEquals(var.make(inst("out")).toString(), "In(blank)");
- }
-
- public void testMRUnboundInnerArg() {
- SXN1 var = MethodReferenceTestKinds.In::new;
- assertEquals(var.make(inst("out"), "name").toString(), "In(name)");
- }
-*/
- public void testMRImplicitInner() {
- SN0 var = MethodReferenceTestKinds.In::new;
- assertEquals(var.make().toString(), "In(blank)");
- }
-
- public void testMRImplicitInnerArg() {
- SN1 var = MethodReferenceTestKinds.In::new;
- assertEquals(var.make("name").toString(), "In(name)");
- }
-
-}
-
-
-class MethodReferenceTestKindsBase {
- String val = "unset";
-
- public String toString() {
- return getClass().getSimpleName() + "(" + val + ")";
- }
-
- MethodReferenceTestKindsBase(String val) {
- this.val = val;
- }
-
- MethodReferenceTestKindsBase() {
- this("blank");
- }
-
-}
-
-class MethodReferenceTestKindsSup extends MethodReferenceTestKindsBase {
- String instanceMethod0() { return "SIM:0-" + this; }
- String instanceMethod1(MethodReferenceTestKinds x) { return "SIM:1-" + this + x; }
-
- MethodReferenceTestKindsSup(String val) {
- super(val);
- }
-
-}
-
--- a/jdk/test/jdk/lambda/MethodReferenceTestNew.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,130 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import org.testng.annotations.Test;
-
-import static org.testng.Assert.assertEquals;
-
-/**
- * @author Robert Field
- */
-
-@Test
-public class MethodReferenceTestNew {
-
- interface M0<T> {
-
- T m();
- }
-
- static class N0 {
-
- N0() {
- }
- }
-
- interface M1<T> {
-
- T m(Integer a);
- }
-
- static class N1 {
-
- int i;
-
- N1(int i) {
- this.i = i;
- }
- }
-
- interface M2<T> {
-
- T m(Integer n, String o);
- }
-
- static class N2 {
-
- Number n;
- Object o;
-
- N2(Number n, Object o) {
- this.n = n;
- this.o = o;
- }
-
- public String toString() {
- return "N2(" + n + "," + o + ")";
- }
- }
-
- interface MV {
-
- NV m(Integer ai, int i);
- }
-
- static class NV {
-
- int i;
-
- NV(int... v) {
- i = 0;
- for (int x : v) {
- i += x;
- }
- }
-
- public String toString() {
- return "NV(" + i + ")";
- }
- }
-
- public void testConstructorReference0() {
- M0<N0> q;
-
- q = N0::new;
- assertEquals(q.m().getClass().getSimpleName(), "N0");
- }
-
- public void testConstructorReference1() {
- M1<N1> q;
-
- q = N1::new;
- assertEquals(q.m(14).getClass().getSimpleName(), "N1");
- }
-
- public void testConstructorReference2() {
- M2<N2> q;
-
- q = N2::new;
- assertEquals(q.m(7, "hi").toString(), "N2(7,hi)");
- }
-
- public void testConstructorReferenceVarArgs() {
- MV q;
-
- q = NV::new;
- assertEquals(q.m(5, 45).toString(), "NV(50)");
- }
-
-}
-
--- a/jdk/test/jdk/lambda/MethodReferenceTestNewInner.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,150 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import org.testng.annotations.Test;
-
-import static org.testng.Assert.assertEquals;
-
-/**
- * @author Robert Field
- */
-
-@Test
-public class MethodReferenceTestNewInner {
-
- String note = "NO NOTE";
-
- interface M0<T> {
-
- T m();
- }
-
- interface MP<T> {
-
- T m(MethodReferenceTestNewInner m);
- }
-
- class N0 {
-
- N0() {
- }
- }
-
- interface M1<T> {
-
- T m(Integer a);
- }
-
- class N1 {
-
- int i;
-
- N1(int i) {
- this.i = i;
- }
- }
-
- interface M2<T> {
-
- T m(Integer n, String o);
- }
-
- class N2 {
-
- Number n;
- Object o;
-
- N2(Number n, Object o) {
- this.n = n;
- this.o = o;
- }
-
- public String toString() {
- return note + ":N2(" + n + "," + o + ")";
- }
- }
-
- interface MV {
-
- NV m(Integer ai, int i);
- }
-
- class NV {
-
- int i;
-
- NV(int... v) {
- i = 0;
- for (int x : v) {
- i += x;
- }
- }
-
- public String toString() {
- return note + ":NV(" + i + ")";
- }
- }
-
-/* unbound constructor case not supported anymore (dropped by EG)
- public static void testConstructorReferenceP() {
- MP<N0> q;
-
- q = N0::new;
- assertEquals(q.m(new MethodReferenceTestNewInner()).getClass().getSimpleName(), "N0");
- }
-*/
- public void testConstructorReference0() {
- M0<N0> q;
-
- q = N0::new;
- assertEquals(q.m().getClass().getSimpleName(), "N0");
- }
-
- public void testConstructorReference1() {
- M1<N1> q;
-
- q = N1::new;
- assertEquals(q.m(14).getClass().getSimpleName(), "N1");
- }
-
- public void testConstructorReference2() {
- M2<N2> q;
-
- note = "T2";
- q = N2::new;
- assertEquals(q.m(7, "hi").toString(), "T2:N2(7,hi)");
- }
-
- /***
- public void testConstructorReferenceVarArgs() {
- MV q;
-
- note = "TVA";
- q = NV::new;
- assertEquals(q.m(5, 45).toString(), "TNV:NV(50)");
- }
- ***/
-
-}
-
-
--- a/jdk/test/jdk/lambda/MethodReferenceTestSueCase1.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-import org.testng.annotations.Test;
-
-import static org.testng.Assert.assertEquals;
-
-/**
- * @author Robert Field
- */
-
-@Test
-public class MethodReferenceTestSueCase1 {
-
- public interface Sam2<T> { public String get(T target, String s); }
-
- String instanceMethod(String s) { return "2"; }
- Sam2<MethodReferenceTestSueCase1> var = MethodReferenceTestSueCase1::instanceMethod;
-
- String m() { return var.get(new MethodReferenceTestSueCase1(), ""); }
-
- public void testSueCase1() {
- assertEquals(m(), "2");
- }
-}
\ No newline at end of file
--- a/jdk/test/jdk/lambda/MethodReferenceTestSueCase2.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-import org.testng.annotations.Test;
-
-import static org.testng.Assert.assertEquals;
-
-/**
- * @author Robert Field
- */
-
-@Test
-public class MethodReferenceTestSueCase2 {
-
- public interface Sam2<T> { public String get(T target, String s); }
-
- String instanceMethod(String s) { return "2"; }
- static Sam2<MethodReferenceTestSueCase2> var = MethodReferenceTestSueCase2::instanceMethod;
-
- String m() { return var.get(new MethodReferenceTestSueCase2(), ""); }
-
- public void testSueCase2() {
- assertEquals(m(), "2");
- }
-
-}
\ No newline at end of file
--- a/jdk/test/jdk/lambda/MethodReferenceTestSueCase4.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-import org.testng.annotations.Test;
-
-import static org.testng.Assert.assertEquals;
-
-/**
- * @author Robert Field
- */
-
-@Test
-public class MethodReferenceTestSueCase4 {
-
- public interface Sam2<T> { public String get(T target, String s); }
-
- Sam2<Target> var = new Object().equals(new Object()) ? Target::instanceMethod : Target::instanceMethod;
-
- String m() {
- return var.get(new Target(), "");
- }
-
- static class Target {
- String instanceMethod(String s) { return "2"; }
- }
-
- public void testSueCase4() {
- assertEquals(m(), "2");
- }
-
-}
\ No newline at end of file
--- a/jdk/test/jdk/lambda/MethodReferenceTestSuper.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,113 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import org.testng.annotations.Test;
-
-import static org.testng.Assert.assertEquals;
-
-
-
-/**
- * @author Robert Field
- */
-
-interface SPRI { String m(String a); }
-
-class SPRA {
- String xsA__(String s) {
- return "A__xsA:" + s;
- }
-
- String xsA_M(String s) {
- return "A_MxsA:" + s;
- }
-
- String xsAB_(String s) {
- return "AB_xsA:" + s;
- }
-
- String xsABM(String s) {
- return "ABMxsA:" + s;
- }
-
-}
-
-class SPRB extends SPRA {
-
- String xsAB_(String s) {
- return "AB_xsB:" + s;
- }
-
- String xsABM(String s) {
- return "ABMxsB:" + s;
- }
-
- String xs_B_(String s) {
- return "_B_xsB:" + s;
- }
-
- String xs_BM(String s) {
- return "_BMxsB:" + s;
- }
-
-}
-
-@Test
-public class MethodReferenceTestSuper extends SPRB {
-
- String xsA_M(String s) {
- return "A_MxsM:" + s;
- }
-
-
- String xsABM(String s) {
- return "ABMxsM:" + s;
- }
-
- String xs_BM(String s) {
- return "_BMxsM:" + s;
- }
-
- public void testMethodReferenceSuper() {
- SPRI q;
-
- q = super::xsA__;
- assertEquals(q.m("*"), "A__xsA:*");
-
- q = super::xsA_M;
- assertEquals(q.m("*"), "A_MxsA:*");
-
- q = super::xsAB_;
- assertEquals(q.m("*"), "AB_xsB:*");
-
- q = super::xsABM;
- assertEquals(q.m("*"), "ABMxsB:*");
-
- q = super::xs_B_;
- assertEquals(q.m("*"), "_B_xsB:*");
-
- q = super::xs_BM;
- assertEquals(q.m("*"), "_BMxsB:*");
- }
-
-}
--- a/jdk/test/jdk/lambda/MethodReferenceTestSuperDefault.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import org.testng.annotations.Test;
-
-import static org.testng.Assert.assertEquals;
-
-
-/**
- * @author Robert Field
- */
-
-interface DSPRI { String m(String a); }
-
-interface DSPRA {
- default String xsA__(String s) {
- return "A__xsA:" + s;
- }
-
- default String xsAB_(String s) {
- return "AB_xsA:" + s;
- }
-
-}
-
-interface DSPRB extends DSPRA {
-
- default String xsAB_(String s) {
- return "AB_xsB:" + s;
- }
-
- default String xs_B_(String s) {
- return "_B_xsB:" + s;
- }
-
-}
-
-@Test
-public class MethodReferenceTestSuperDefault implements DSPRB {
-
- public void testMethodReferenceSuper() {
- DSPRI q;
-
- q = DSPRB.super::xsA__;
- assertEquals(q.m("*"), "A__xsA:*");
-
- q = DSPRB.super::xsAB_;
- assertEquals(q.m("*"), "AB_xsB:*");
-
- q = DSPRB.super::xs_B_;
- assertEquals(q.m("*"), "_B_xsB:*");
- }
-
-}
--- a/jdk/test/jdk/lambda/MethodReferenceTestTypeConversion.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import org.testng.annotations.Test;
-
-import static org.testng.Assert.assertEquals;
-
-/**
- * @author Robert Field
- */
-
-class MethodReferenceTestTypeConversion_E<T> {
- T xI(T t) { return t; }
-}
-
-@Test
-public class MethodReferenceTestTypeConversion {
-
- interface ISi { int m(Short a); }
-
- interface ICc { char m(Character a); }
-
- public void testUnboxObjectToNumberWiden() {
- ISi q = (new MethodReferenceTestTypeConversion_E<Short>())::xI;
- assertEquals(q.m((short)77), (short)77);
- }
-
- public void testUnboxObjectToChar() {
- ICc q = (new MethodReferenceTestTypeConversion_E<Character>())::xI;
- assertEquals(q.m('@'), '@');
- }
-
-}
--- a/jdk/test/jdk/lambda/MethodReferenceTestVarArgs.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,195 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import org.testng.annotations.Test;
-import java.lang.reflect.Array;
-
-import static org.testng.Assert.assertEquals;
-
-/**
- * @author Robert Field
- */
-
-@Test
-public class MethodReferenceTestVarArgs {
-
- interface SII {
-
- String m(Integer a, Integer b);
- }
-
- interface Siii {
-
- String m(int a, int b, int c);
- }
-
- interface Si {
-
- String m(int a);
- }
-
- interface SaO {
-
- String m(Object[] a);
- }
-
- interface Sai {
-
- String m(int[] a);
- }
-
- interface Svi {
-
- String m(int... va);
- }
-
- // These should be processed as var args
-
- static String xvI(Integer... vi) {
- StringBuilder sb = new StringBuilder("xvI:");
- for (Integer i : vi) {
- sb.append(i);
- sb.append("-");
- }
- return sb.toString();
- }
-
- static String xIvI(Integer f, Integer... vi) {
- StringBuilder sb = new StringBuilder("xIvI:");
- sb.append(f);
- for (Integer i : vi) {
- sb.append(i);
- sb.append("-");
- }
- return sb.toString();
- }
-
- static String xvi(int... vi) {
- int sum = 0;
- for (int i : vi) {
- sum += i;
- }
- return "xvi:" + sum;
- }
-
- static String xIvi(Integer f, int... vi) {
- int sum = 0;
- for (int i : vi) {
- sum += i;
- }
- return "xIvi:(" + f + ")" + sum;
- }
-
- static String xvO(Object... vi) {
- StringBuilder sb = new StringBuilder("xvO:");
- for (Object i : vi) {
- if (i.getClass().isArray()) {
- sb.append("[");
- int len = Array.getLength(i);
- for (int x = 0; x < len; ++x) {
- sb.append(Array.get(i, x));
- sb.append(",");
- }
- sb.append("]");
-
- } else {
- sb.append(i);
- }
- sb.append("*");
- }
- return sb.toString();
- }
-
- public void testVarArgsSuperclass() {
- SII q;
-
- q = MethodReferenceTestVarArgs::xvO;
- assertEquals(q.m(55,66), "xvO:55*66*");
- }
-
- public void testVarArgsArray() {
- Sai q;
-
- q = MethodReferenceTestVarArgs::xvO;
- assertEquals(q.m(new int[] { 55,66 } ), "xvO:[55,66,]*");
- }
-
- public void testVarArgsII() {
- SII q;
-
- q = MethodReferenceTestVarArgs::xvI;
- assertEquals(q.m(33,7), "xvI:33-7-");
-
- q = MethodReferenceTestVarArgs::xIvI;
- assertEquals(q.m(50,40), "xIvI:5040-");
-
- q = MethodReferenceTestVarArgs::xvi;
- assertEquals(q.m(100,23), "xvi:123");
-
- q = MethodReferenceTestVarArgs::xIvi;
- assertEquals(q.m(9,21), "xIvi:(9)21");
- }
-
- public void testVarArgsiii() {
- Siii q;
-
- q = MethodReferenceTestVarArgs::xvI;
- assertEquals(q.m(3, 2, 1), "xvI:3-2-1-");
-
- q = MethodReferenceTestVarArgs::xIvI;
- assertEquals(q.m(888, 99, 2), "xIvI:88899-2-");
-
- q = MethodReferenceTestVarArgs::xvi;
- assertEquals(q.m(900,80,7), "xvi:987");
-
- q = MethodReferenceTestVarArgs::xIvi;
- assertEquals(q.m(333,27, 72), "xIvi:(333)99");
- }
-
- public void testVarArgsi() {
- Si q;
-
- q = MethodReferenceTestVarArgs::xvI;
- assertEquals(q.m(3), "xvI:3-");
-
- q = MethodReferenceTestVarArgs::xIvI;
- assertEquals(q.m(888), "xIvI:888");
-
- q = MethodReferenceTestVarArgs::xvi;
- assertEquals(q.m(900), "xvi:900");
-
- q = MethodReferenceTestVarArgs::xIvi;
- assertEquals(q.m(333), "xIvi:(333)0");
- }
-
- // These should NOT be processed as var args
-
- public void testVarArgsaO() {
- SaO q;
-
- q = MethodReferenceTestVarArgs::xvO;
- assertEquals(q.m(new String[] { "yo", "there", "dude" }), "xvO:yo*there*dude*");
- }
-
-
-}
--- a/jdk/test/jdk/lambda/MethodReferenceTestVarArgsExt.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,182 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import org.testng.annotations.Test;
-import java.lang.reflect.Array;
-
-import static org.testng.Assert.assertEquals;
-
-/**
- * @author Robert Field
- */
-
-interface NXII { String m(Integer a, Integer b); }
-
-interface NXiii { String m(int a, int b, int c); }
-
-interface NXi { String m(int a); }
-
-interface NXaO { String m(Object[] a); }
-
-interface NXai { String m(int[] a); }
-
-interface NXvi { String m(int... va); }
-
-@Test
-public class MethodReferenceTestVarArgsExt {
-
- // These should be processed as var args
-
- public void testVarArgsNXSuperclass() {
- NXII q;
-
- q = (new Ext())::xvO;
- assertEquals(q.m(55,66), "xvO:55*66*");
- }
-
- public void testVarArgsNXArray() {
- NXai q;
-
- q = (new Ext())::xvO;
- assertEquals(q.m(new int[] { 55,66 } ), "xvO:[55,66,]*");
- }
-
- public void testVarArgsNXII() {
- NXII q;
-
- q = (new Ext())::xvI;
- assertEquals(q.m(33,7), "xvI:33-7-");
-
- q = (new Ext())::xIvI;
- assertEquals(q.m(50,40), "xIvI:5040-");
-
- q = (new Ext())::xvi;
- assertEquals(q.m(100,23), "xvi:123");
-
- q = (new Ext())::xIvi;
- assertEquals(q.m(9,21), "xIvi:(9)21");
- }
-
- public void testVarArgsNXiii() {
- NXiii q;
-
- q = (new Ext())::xvI;
- assertEquals(q.m(3, 2, 1), "xvI:3-2-1-");
-
- q = (new Ext())::xIvI;
- assertEquals(q.m(888, 99, 2), "xIvI:88899-2-");
-
- q = (new Ext())::xvi;
- assertEquals(q.m(900,80,7), "xvi:987");
-
- q = (new Ext())::xIvi;
- assertEquals(q.m(333,27, 72), "xIvi:(333)99");
- }
-
- public void testVarArgsNXi() {
- NXi q;
-
- q = (new Ext())::xvI;
- assertEquals(q.m(3), "xvI:3-");
-
- q = (new Ext())::xIvI;
- assertEquals(q.m(888), "xIvI:888");
-
- q = (new Ext())::xvi;
- assertEquals(q.m(900), "xvi:900");
-
- q = (new Ext())::xIvi;
- assertEquals(q.m(333), "xIvi:(333)0");
- }
-
- // These should NOT be processed as var args
-
- public void testVarArgsNXaO() {
- NXaO q;
-
- q = (new Ext())::xvO;
- assertEquals(q.m(new String[] { "yo", "there", "dude" }), "xvO:yo*there*dude*");
- }
-
-
-}
-
-class Ext {
-
- String xvI(Integer... vi) {
- StringBuilder sb = new StringBuilder("xvI:");
- for (Integer i : vi) {
- sb.append(i);
- sb.append("-");
- }
- return sb.toString();
- }
-
- String xIvI(Integer f, Integer... vi) {
- StringBuilder sb = new StringBuilder("xIvI:");
- sb.append(f);
- for (Integer i : vi) {
- sb.append(i);
- sb.append("-");
- }
- return sb.toString();
- }
-
- String xvi(int... vi) {
- int sum = 0;
- for (int i : vi) {
- sum += i;
- }
- return "xvi:" + sum;
- }
-
- String xIvi(Integer f, int... vi) {
- int sum = 0;
- for (int i : vi) {
- sum += i;
- }
- return "xIvi:(" + f + ")" + sum;
- }
-
- String xvO(Object... vi) {
- StringBuilder sb = new StringBuilder("xvO:");
- for (Object i : vi) {
- if (i.getClass().isArray()) {
- sb.append("[");
- int len = Array.getLength(i);
- for (int x = 0; x < len; ++x) {
- sb.append(Array.get(i, x));
- sb.append(",");
- }
- sb.append("]");
-
- } else {
- sb.append(i);
- }
- sb.append("*");
- }
- return sb.toString();
- }
-
-
-}
--- a/jdk/test/jdk/lambda/MethodReferenceTestVarArgsSuper.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,200 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import org.testng.annotations.Test;
-import java.lang.reflect.Array;
-
-import static org.testng.Assert.assertEquals;
-
-
-/**
- * @author Robert Field
- */
-
-class MethodReferenceTestVarArgsSuper_Sub {
-
- String xvI(Integer... vi) {
- StringBuilder sb = new StringBuilder("xvI:");
- for (Integer i : vi) {
- sb.append(i);
- sb.append("-");
- }
- return sb.toString();
- }
-
- String xIvI(Integer f, Integer... vi) {
- StringBuilder sb = new StringBuilder("xIvI:");
- sb.append(f);
- for (Integer i : vi) {
- sb.append(i);
- sb.append("-");
- }
- return sb.toString();
- }
-
- String xvi(int... vi) {
- int sum = 0;
- for (int i : vi) {
- sum += i;
- }
- return "xvi:" + sum;
- }
-
- String xIvi(Integer f, int... vi) {
- int sum = 0;
- for (int i : vi) {
- sum += i;
- }
- return "xIvi:(" + f + ")" + sum;
- }
-
- String xvO(Object... vi) {
- StringBuilder sb = new StringBuilder("xvO:");
- for (Object i : vi) {
- if (i.getClass().isArray()) {
- sb.append("[");
- int len = Array.getLength(i);
- for (int x = 0; x < len; ++x) {
- sb.append(Array.get(i, x));
- sb.append(",");
- }
- sb.append("]");
-
- } else {
- sb.append(i);
- }
- sb.append("*");
- }
- return sb.toString();
- }
-}
-
-@Test
-public class MethodReferenceTestVarArgsSuper extends MethodReferenceTestVarArgsSuper_Sub {
-
- interface SPRII { String m(Integer a, Integer b); }
-
- interface SPRiii { String m(int a, int b, int c); }
-
- interface SPRi { String m(int a); }
-
- interface SPRaO { String m(Object[] a); }
-
- interface SPRai { String m(int[] a); }
-
- interface SPRvi { String m(int... va); }
-
- String xvI(Integer... vi) {
- return "ERROR";
- }
-
- String xIvI(Integer f, Integer... vi) {
- return "ERROR";
- }
-
- String xvi(int... vi) {
- return "ERROR";
- }
-
- String xIvi(Integer f, int... vi) {
- return "ERROR";
- }
-
- String xvO(Object... vi) {
- return "ERROR";
- }
-
- // These should be processed as var args
-
- public void testVarArgsSPRSuperclass() {
- SPRII q;
-
- q = super::xvO;
- assertEquals(q.m(55,66), "xvO:55*66*");
- }
-
- public void testVarArgsSPRArray() {
- SPRai q;
-
- q = super::xvO;
- assertEquals(q.m(new int[] { 55,66 } ), "xvO:[55,66,]*");
- }
-
- public void testVarArgsSPRII() {
- SPRII q;
-
- q = super::xvI;
- assertEquals(q.m(33,7), "xvI:33-7-");
-
- q = super::xIvI;
- assertEquals(q.m(50,40), "xIvI:5040-");
-
- q = super::xvi;
- assertEquals(q.m(100,23), "xvi:123");
-
- q = super::xIvi;
- assertEquals(q.m(9,21), "xIvi:(9)21");
- }
-
- public void testVarArgsSPRiii() {
- SPRiii q;
-
- q = super::xvI;
- assertEquals(q.m(3, 2, 1), "xvI:3-2-1-");
-
- q = super::xIvI;
- assertEquals(q.m(888, 99, 2), "xIvI:88899-2-");
-
- q = super::xvi;
- assertEquals(q.m(900,80,7), "xvi:987");
-
- q = super::xIvi;
- assertEquals(q.m(333,27, 72), "xIvi:(333)99");
- }
-
- public void testVarArgsSPRi() {
- SPRi q;
-
- q = super::xvI;
- assertEquals(q.m(3), "xvI:3-");
-
- q = super::xIvI;
- assertEquals(q.m(888), "xIvI:888");
-
- q = super::xvi;
- assertEquals(q.m(900), "xvi:900");
-
- q = super::xIvi;
- assertEquals(q.m(333), "xIvi:(333)0");
- }
-
- // These should NOT be processed as var args
-
- public void testVarArgsSPRaO() {
- SPRaO q;
-
- q = super::xvO;
- assertEquals(q.m(new String[] { "yo", "there", "dude" }), "xvO:yo*there*dude*");
- }
-}
-
--- a/jdk/test/jdk/lambda/MethodReferenceTestVarArgsSuperDefault.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,181 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import org.testng.annotations.Test;
-import java.lang.reflect.Array;
-
-import static org.testng.Assert.assertEquals;
-
-/**
- * @author Robert Field
- */
-
-interface MethodReferenceTestVarArgsSuperDefault_I {
-
- default String xvI(Integer... vi) {
- StringBuilder sb = new StringBuilder("xvI:");
- for (Integer i : vi) {
- sb.append(i);
- sb.append("-");
- }
- return sb.toString();
- }
-
- default String xIvI(Integer f, Integer... vi) {
- StringBuilder sb = new StringBuilder("xIvI:");
- sb.append(f);
- for (Integer i : vi) {
- sb.append(i);
- sb.append("-");
- }
- return sb.toString();
- }
-
- default String xvi(int... vi) {
- int sum = 0;
- for (int i : vi) {
- sum += i;
- }
- return "xvi:" + sum;
- }
-
- default String xIvi(Integer f, int... vi) {
- int sum = 0;
- for (int i : vi) {
- sum += i;
- }
- return "xIvi:(" + f + ")" + sum;
- }
-
- default String xvO(Object... vi) {
- StringBuilder sb = new StringBuilder("xvO:");
- for (Object i : vi) {
- if (i.getClass().isArray()) {
- sb.append("[");
- int len = Array.getLength(i);
- for (int x = 0; x < len; ++x) {
- sb.append(Array.get(i, x));
- sb.append(",");
- }
- sb.append("]");
-
- } else {
- sb.append(i);
- }
- sb.append("*");
- }
- return sb.toString();
- }
-}
-
-@Test
-public class MethodReferenceTestVarArgsSuperDefault implements MethodReferenceTestVarArgsSuperDefault_I {
-
- interface DSPRII { String m(Integer a, Integer b); }
-
- interface DSPRiii { String m(int a, int b, int c); }
-
- interface DSPRi { String m(int a); }
-
- interface DSPRaO { String m(Object[] a); }
-
- interface DSPRai { String m(int[] a); }
-
- interface DSPRvi { String m(int... va); }
-
- // These should be processed as var args
-
- public void testVarArgsSPRSuperclass() {
- DSPRII q;
-
- q = MethodReferenceTestVarArgsSuperDefault_I.super::xvO;
- assertEquals(q.m(55,66), "xvO:55*66*");
- }
-
- public void testVarArgsSPRArray() {
- DSPRai q;
-
- q = MethodReferenceTestVarArgsSuperDefault_I.super::xvO;
- assertEquals(q.m(new int[] { 55,66 } ), "xvO:[55,66,]*");
- }
-
- public void testVarArgsSPRII() {
- DSPRII q;
-
- q = MethodReferenceTestVarArgsSuperDefault_I.super::xvI;
- assertEquals(q.m(33,7), "xvI:33-7-");
-
- q = MethodReferenceTestVarArgsSuperDefault_I.super::xIvI;
- assertEquals(q.m(50,40), "xIvI:5040-");
-
- q = MethodReferenceTestVarArgsSuperDefault_I.super::xvi;
- assertEquals(q.m(100,23), "xvi:123");
-
- q = MethodReferenceTestVarArgsSuperDefault_I.super::xIvi;
- assertEquals(q.m(9,21), "xIvi:(9)21");
- }
-
- public void testVarArgsSPRiii() {
- DSPRiii q;
-
- q = MethodReferenceTestVarArgsSuperDefault_I.super::xvI;
- assertEquals(q.m(3, 2, 1), "xvI:3-2-1-");
-
- q = MethodReferenceTestVarArgsSuperDefault_I.super::xIvI;
- assertEquals(q.m(888, 99, 2), "xIvI:88899-2-");
-
- q = MethodReferenceTestVarArgsSuperDefault_I.super::xvi;
- assertEquals(q.m(900,80,7), "xvi:987");
-
- q = MethodReferenceTestVarArgsSuperDefault_I.super::xIvi;
- assertEquals(q.m(333,27, 72), "xIvi:(333)99");
- }
-
- public void testVarArgsSPRi() {
- DSPRi q;
-
- q = MethodReferenceTestVarArgsSuperDefault_I.super::xvI;
- assertEquals(q.m(3), "xvI:3-");
-
- q = MethodReferenceTestVarArgsSuperDefault_I.super::xIvI;
- assertEquals(q.m(888), "xIvI:888");
-
- q = MethodReferenceTestVarArgsSuperDefault_I.super::xvi;
- assertEquals(q.m(900), "xvi:900");
-
- q = MethodReferenceTestVarArgsSuperDefault_I.super::xIvi;
- assertEquals(q.m(333), "xIvi:(333)0");
- }
-
- // These should NOT be processed as var args
-
- public void testVarArgsSPRaO() {
- DSPRaO q;
-
- q = MethodReferenceTestVarArgsSuperDefault_I.super::xvO;
- assertEquals(q.m(new String[] { "yo", "there", "dude" }), "xvO:yo*there*dude*");
- }
-
-
-}
-
--- a/jdk/test/jdk/lambda/MethodReferenceTestVarArgsThis.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,177 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import org.testng.annotations.Test;
-import java.lang.reflect.Array;
-
-import static org.testng.Assert.assertEquals;
-
-/**
- * @author Robert Field
- */
-
-interface NsII { String m(Integer a, Integer b); }
-
-interface Nsiii { String m(int a, int b, int c); }
-
-interface Nsi { String m(int a); }
-
-interface NsaO { String m(Object[] a); }
-
-interface Nsai { String m(int[] a); }
-
-interface Nsvi { String m(int... va); }
-
-@Test
-public class MethodReferenceTestVarArgsThis {
-
- // These should be processed as var args
-
- String xvI(Integer... vi) {
- StringBuilder sb = new StringBuilder("xvI:");
- for (Integer i : vi) {
- sb.append(i);
- sb.append("-");
- }
- return sb.toString();
- }
-
- String xIvI(Integer f, Integer... vi) {
- StringBuilder sb = new StringBuilder("xIvI:");
- sb.append(f);
- for (Integer i : vi) {
- sb.append(i);
- sb.append("-");
- }
- return sb.toString();
- }
-
- String xvi(int... vi) {
- int sum = 0;
- for (int i : vi) {
- sum += i;
- }
- return "xvi:" + sum;
- }
-
- String xIvi(Integer f, int... vi) {
- int sum = 0;
- for (int i : vi) {
- sum += i;
- }
- return "xIvi:(" + f + ")" + sum;
- }
-
- String xvO(Object... vi) {
- StringBuilder sb = new StringBuilder("xvO:");
- for (Object i : vi) {
- if (i.getClass().isArray()) {
- sb.append("[");
- int len = Array.getLength(i);
- for (int x = 0; x < len; ++x) {
- sb.append(Array.get(i, x));
- sb.append(",");
- }
- sb.append("]");
-
- } else {
- sb.append(i);
- }
- sb.append("*");
- }
- return sb.toString();
- }
-
- public void testVarArgsNsSuperclass() {
- NsII q;
-
- q = this::xvO;
- assertEquals(q.m(55,66), "xvO:55*66*");
- }
-
- public void testVarArgsNsArray() {
- Nsai q;
-
- q = this::xvO;
- assertEquals(q.m(new int[] { 55,66 } ), "xvO:[55,66,]*");
- }
-
- public void testVarArgsNsII() {
- NsII q;
-
- q = this::xvI;
- assertEquals(q.m(33,7), "xvI:33-7-");
-
- q = this::xIvI;
- assertEquals(q.m(50,40), "xIvI:5040-");
-
- q = this::xvi;
- assertEquals(q.m(100,23), "xvi:123");
-
- q = this::xIvi;
- assertEquals(q.m(9,21), "xIvi:(9)21");
- }
-
- public void testVarArgsNsiii() {
- Nsiii q;
-
- q = this::xvI;
- assertEquals(q.m(3, 2, 1), "xvI:3-2-1-");
-
- q = this::xIvI;
- assertEquals(q.m(888, 99, 2), "xIvI:88899-2-");
-
- q = this::xvi;
- assertEquals(q.m(900,80,7), "xvi:987");
-
- q = this::xIvi;
- assertEquals(q.m(333,27, 72), "xIvi:(333)99");
- }
-
- public void testVarArgsNsi() {
- Nsi q;
-
- q = this::xvI;
- assertEquals(q.m(3), "xvI:3-");
-
- q = this::xIvI;
- assertEquals(q.m(888), "xIvI:888");
-
- q = this::xvi;
- assertEquals(q.m(900), "xvi:900");
-
- q = this::xIvi;
- assertEquals(q.m(333), "xIvi:(333)0");
- }
-
- // These should NOT be processed as var args
-
- public void testVarArgsNsaO() {
- NsaO q;
-
- q = this::xvO;
- assertEquals(q.m(new String[] { "yo", "there", "dude" }), "xvO:yo*there*dude*");
- }
-
-
-}
--- a/jdk/test/jdk/lambda/shapegen/ClassCase.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,310 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package shapegen;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- *
- * @author Robert Field
- */
-public class ClassCase {
-
- public enum Kind {
- IVAC (true, "v"),
- IPRESENT (true, "p"),
- IDEFAULT (true, "d"),
- CNONE (false, "n"),
- CABSTRACT (false, "a"),
- CCONCRETE (false, "c");
-
- private final String prefix;
- public final boolean isInterface;
-
- Kind(boolean isInterface, String prefix) {
- this.isInterface = isInterface;
- this.prefix = prefix;
- }
-
- public String getPrefix() { return prefix; }
- }
-
- public final Kind kind;
- private final ClassCase superclass;
- private final List<ClassCase> supertypes;
-
- private String name;
- private boolean _OK;
- private boolean _HasClassMethod;
- private Set<ClassCase> _mprov;
- private boolean _IsConcrete;
- private boolean _HasDefault;
- private ClassCase _mres;
- private ClassCase _mdefend;
-
- private Set<RuleGroup> executed = new HashSet<RuleGroup>();
-
- public ClassCase(Kind kind, ClassCase superclass, List<ClassCase> interfaces) {
- this.kind = kind;
- this.superclass = superclass;
-
- // Set supertypes from superclass (if any) and interfaces
- List<ClassCase> lc;
- if (superclass == null) {
- lc = interfaces;
- } else {
- lc = new ArrayList<>();
- lc.add(superclass);
- lc.addAll(interfaces);
- }
- this.supertypes = lc;
- }
-
- public final boolean isInterface() { return kind.isInterface; }
- public final boolean isClass() { return !kind.isInterface; }
-
- public Set<ClassCase> get_mprov() {
- exec(RuleGroup.PROVENENCE);
- return _mprov;
- }
-
- public void set_mprov(ClassCase cc) {
- Set<ClassCase> s = new HashSet<>();
- s.add(cc);
- _mprov = s;
- }
-
- public void set_mprov(Set<ClassCase> s) {
- _mprov = s;
- }
-
- public ClassCase get_mres() {
- exec(RuleGroup.RESOLUTION);
- return _mres;
- }
-
- public void set_mres(ClassCase cc) {
- _mres = cc;
- }
-
- public ClassCase get_mdefend() {
- exec(RuleGroup.DEFENDER);
- return _mdefend;
- }
-
- public void set_mdefend(ClassCase cc) {
- _mdefend = cc;
- }
-
- public boolean get_HasClassMethod() {
- exec(RuleGroup.PROVENENCE);
- return _HasClassMethod;
- }
-
- public void set_HasClassMethod(boolean bool) {
- _HasClassMethod = bool;
- }
-
- public boolean get_HasDefault() {
- exec(RuleGroup.MARKER);
- return _HasDefault;
- }
-
- public void set_HasDefault(boolean bool) {
- _HasDefault = bool;
- }
-
- public boolean get_IsConcrete() {
- exec(RuleGroup.MARKER);
- return _IsConcrete;
- }
-
- public void set_IsConcrete(boolean bool) {
- _IsConcrete = bool;
- }
-
- public boolean get_OK() {
- exec(RuleGroup.CHECKING);
- return _OK;
- }
-
- public void set_OK(boolean bool) {
- _OK = bool;
- }
-
- public boolean isMethodDefined() {
- for (ClassCase cc : supertypes) {
- if (cc.isMethodDefined()) {
- return true;
- }
- }
- switch (kind) {
- case CCONCRETE:
- case CABSTRACT:
- case IPRESENT:
- case IDEFAULT:
- return true;
- default:
- return false;
- }
- }
-
- public boolean isAbstract() {
- return isMethodDefined() && (get_mres()==null);
- }
-
- public boolean hasSuperclass() {
- return superclass != null;
- }
-
- public ClassCase getSuperclass() {
- return superclass;
- }
-
- public List<ClassCase> getSupertypes() {
- return supertypes;
- }
-
- public List<ClassCase> getInterfaces() {
- if (superclass != null) {
- if (supertypes.get(0) != superclass) {
- throw new AssertionError("superclass missing from supertypes");
- }
- return supertypes.subList(1, supertypes.size());
- } else {
- return supertypes;
- }
- }
-
- public boolean isSubtypeOf(ClassCase cc) {
- // S-Refl
- if (cc.equals(this)) {
- return true;
- }
-
- // S-Def
- for (ClassCase sp : getSupertypes()) {
- if (cc.equals(sp)) {
- return true;
- }
- }
-
- // _S-Trans
- for (ClassCase sp : getSupertypes()) {
- if (sp.isSubtypeOf(cc)) {
- return true;
- }
- }
-
- return false;
- }
-
- public void init(Map<String, Integer> namingContext) {
- if (name != null) {
- return; // Already inited
- }
-
- for (ClassCase sup : supertypes) {
- sup.init(namingContext);
- }
-
- // Build name
- StringBuilder sb = new StringBuilder();
- if (!supertypes.isEmpty()) {
- sb.append(isInterface() ? "I" : "C");
- for (ClassCase cc : supertypes) {
- sb.append(cc.getName());
- }
- sb.append(kind.isInterface ? "i" : "c");
- }
- sb.append(kind.prefix);
- String pname = sb.toString();
- Integer icnt = namingContext.get(pname);
- int cnt = icnt == null ? 0 : icnt;
- ++cnt;
- namingContext.put(pname, cnt);
- if (cnt > 1) {
- sb.append(cnt);
- }
- this.name = sb.toString();
- }
-
- public boolean isa(Kind... kinds) {
- for (Kind k : kinds) {
- if (kind == k) {
- return true;
- }
- }
- return false;
- }
-
- private void exec(RuleGroup rg ) {
- if (!executed.contains(rg)) {
- rg.exec(this);
- executed.add(rg);
- }
- }
-
- public void collectClasses(Set<ClassCase> seen) {
- seen.add(this);
- for (ClassCase cc : supertypes) {
- cc.collectClasses(seen);
- }
- }
-
- public String getID() {
- if (name == null) {
- throw new Error("Access to uninitialized ClassCase");
- } else {
- return name;
- }
- }
-
- public final String getName() {
- if (name == null) {
- return "ClassCase uninited@" + hashCode();
- } else {
- return name;
- }
- }
-
- @Override
- public boolean equals(Object obj) {
- return obj instanceof ClassCase && getID().equals(((ClassCase)obj).getID());
- }
-
- @Override
- public int hashCode() {
- return getID().hashCode();
- }
-
- @Override
- public String toString() {
- return getName();
- }
-}
--- a/jdk/test/jdk/lambda/shapegen/Hierarchy.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,207 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package shapegen;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import static shapegen.ClassCase.Kind.*;
-
-/**
- *
- * @author Robert Field
- */
-public class Hierarchy {
-
- public final ClassCase root;
- public final Set<ClassCase> all;
-
- public Hierarchy(ClassCase root) {
- this.root = root;
- root.init(new HashMap<String,Integer>());
- Set<ClassCase> allClasses = new HashSet<>();
- root.collectClasses(allClasses);
- this.all = allClasses;
- }
-
- public boolean anyDefaults() {
- for (ClassCase cc : all) {
- if (cc.kind == IDEFAULT) {
- return true;
- }
- }
- return false;
- }
-
- public boolean get_OK() {
- return root.get_OK();
- }
-
- public String testName() {
- return root + "Test";
- }
-
- private static void genInterfaceList(StringBuilder buf, String prefix, List<ClassCase> interfaces) {
- if (!interfaces.isEmpty()) {
- buf.append(" ");
- buf.append(prefix);
- buf.append(" ");
- buf.append(interfaces.get(0));
- for (int i = 1; i < interfaces.size(); ++i) {
- buf.append(", " + interfaces.get(i));
- }
- }
- }
-
- public static void genClassDef(StringBuilder buf, ClassCase cc, String implClass, List<ClassCase> defaultRef) {
- if (cc.isInterface()) {
- buf.append("interface ");
- buf.append(cc.getName() + " ");
- genInterfaceList(buf, "extends", cc.getInterfaces());
- buf.append(" {\n");
-
- switch (cc.kind) {
- case IDEFAULT:
- buf.append(" default String m() { return \"\"; }\n");
- defaultRef.add(cc);
- break;
- case IPRESENT:
- buf.append(" String m();\n");
- break;
- case IVAC:
- break;
- default:
- throw new AssertionError("Unexpected kind");
- }
- buf.append("}\n\n");
- } else {
- buf.append((cc.isAbstract()? "abstract " : ""));
- buf.append(" class " + cc.getName());
- if (cc.getSuperclass() != null) {
- buf.append(" extends " + cc.getSuperclass());
- }
-
- genInterfaceList(buf, "implements", cc.getInterfaces());
- buf.append(" {\n");
-
- switch (cc.kind) {
- case CCONCRETE:
- buf.append(" public String m() { return \"\"; }\n");
- break;
- case CABSTRACT:
- buf.append(" public abstract String m();\n");
- break;
- case CNONE:
- break;
- default:
- throw new AssertionError("Unexpected kind");
- }
- buf.append("}\n\n");
- }
- }
-
- @Override
- public boolean equals(Object obj) {
- return obj instanceof Hierarchy && root.getID().equals(((Hierarchy)obj).root.getID());
- }
-
- @Override
- public int hashCode() {
- return root.getID().hashCode();
- }
-
- @Override
- public String toString() {
- return root.getName();
- }
-
- private static String classNames[] = {
- "C", "D", "E", "F", "G", "H", "S", "T", "U", "V"
- };
-
- private static String interfaceNames[] = {
- "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R"
- };
-
- private static int CLASS_INDEX = 0;
- private static int INTERFACE_INDEX = 1;
- private static int NUM_INDICIES = 2;
-
- public List<String> getDescription() {
- Map<ClassCase,String> nameMap = new HashMap<>();
- assignNames(root, new int[NUM_INDICIES], nameMap);
-
- ArrayList<String> res = new ArrayList<>();
- if (root.getSupertypes().size() == 0) {
- res.add(nameMap.get(root) + root.kind.getPrefix() + "()");
- } else {
- genCaseDescription(root, res, new HashSet<ClassCase>(), nameMap);
- }
- return res;
- }
-
- private static void assignNames(
- ClassCase cc, int indices[], Map<ClassCase,String> names) {
- String name = names.get(cc);
- if (name == null) {
- if (cc.isInterface()) {
- names.put(cc, interfaceNames[indices[INTERFACE_INDEX]++]);
- } else {
- names.put(cc, classNames[indices[CLASS_INDEX]++]);
- }
- for (int i = 0; i < cc.getSupertypes().size(); ++i) {
- assignNames(cc.getSupertypes().get(i), indices, names);
- }
- }
- }
-
- private static void genCaseDescription(
- ClassCase cc, List<String> res, Set<ClassCase> alreadyDone,
- Map<ClassCase,String> nameMap) {
- if (!alreadyDone.contains(cc)) {
- if (cc.getSupertypes().size() > 0) {
- StringBuilder sb = new StringBuilder();
- sb.append(nameMap.get(cc));
- sb.append(cc.kind.getPrefix());
- sb.append("(");
- for (int i = 0; i < cc.getSupertypes().size(); ++i) {
- ClassCase supertype = cc.getSupertypes().get(i);
- if (i != 0) {
- sb.append(",");
- }
- genCaseDescription(supertype, res, alreadyDone, nameMap);
- sb.append(nameMap.get(supertype));
- sb.append(supertype.kind.getPrefix());
- }
- sb.append(")");
- res.add(sb.toString());
- }
- }
- alreadyDone.add(cc);
- }
-}
--- a/jdk/test/jdk/lambda/shapegen/HierarchyGenerator.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,190 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package shapegen;
-
-import shapegen.ClassCase.Kind;
-
-import java.util.Collection;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Collections;
-import java.util.ArrayList;
-import java.util.List;
-
-import static shapegen.ClassCase.Kind.*;
-
-import static java.lang.Math.pow;
-
-/**
- *
- * @author Robert Field
- */
-public final class HierarchyGenerator {
-
- private int okcnt = 0;
- private int errcnt = 0;
- private Set<Hierarchy> uniqueOK = new HashSet<>();
- private Set<Hierarchy> uniqueErr = new HashSet<>();
-
- /**
- * @param args the command line arguments
- */
- public HierarchyGenerator() {
- organize("exhaustive interface", iExhaustive(2));
- organize("exhaustive class", cExhaustive());
- organize("shapes interface", iShapes());
- organize("shapes class/interface", ciShapes());
-
- System.out.printf("\nExpect OK: %d -- unique %d", okcnt, uniqueOK.size());
- System.out.printf("\nExpect Error: %d -- unique %d\n", errcnt, uniqueErr.size());
- }
-
- public Collection<Hierarchy> getOK() {
- return uniqueOK;
- }
-
- public Collection<Hierarchy> getErr() {
- return uniqueErr;
- }
-
- private void organize(String tname, List<Hierarchy> totest) {
- System.out.printf("\nGenerating %s....\n", tname);
- int nodefault = 0;
- List<Hierarchy> ok = new ArrayList<>();
- List<Hierarchy> err = new ArrayList<>();
- for (Hierarchy cc : totest) {
- if (cc.anyDefaults()) {
- //System.out.printf(" %s\n", cc);
- if (cc.get_OK()) {
- ok.add(cc);
- } else {
- err.add(cc);
- }
- } else {
- ++nodefault;
- }
- }
-
- errcnt += err.size();
- okcnt += ok.size();
- uniqueErr.addAll(err);
- uniqueOK.addAll(ok);
-
- System.out.printf(" %5d No default\n %5d Error\n %5d OK\n %5d Total\n",
- nodefault, err.size(), ok.size(), totest.size());
- }
-
- public List<Hierarchy> iExhaustive(int idepth) {
- List<ClassCase> current = new ArrayList<>();
- for (int i = 0; i < idepth; ++i) {
- current = ilayer(current);
- }
- return wrapInClassAndHierarchy(current);
- }
-
- private List<ClassCase> ilayer(List<ClassCase> srcLayer) {
- List<ClassCase> lay = new ArrayList<>();
- for (int i = (int) pow(2, srcLayer.size()) - 1; i >= 0; --i) {
- List<ClassCase> itfs = new ArrayList<>();
- for (int b = srcLayer.size() - 1; b >= 0; --b) {
- if ((i & (1<<b)) != 0) {
- itfs.add(srcLayer.get(b));
- }
- }
- lay.add(new ClassCase(IVAC, null, itfs));
- lay.add(new ClassCase(IPRESENT, null, itfs));
- lay.add(new ClassCase(IDEFAULT, null, itfs));
- lay.add(new ClassCase(IDEFAULT, null, itfs));
- }
- return lay;
- }
-
- public List<Hierarchy> cExhaustive() {
- final Kind[] iKinds = new Kind[]{IDEFAULT, IVAC, IPRESENT, null};
- final Kind[] cKinds = new Kind[]{CNONE, CABSTRACT, CCONCRETE};
- List<Hierarchy> totest = new ArrayList<>();
- for (int i1 = 0; i1 < iKinds.length; ++i1) {
- for (int i2 = 0; i2 < iKinds.length; ++i2) {
- for (int i3 = 0; i3 < iKinds.length; ++i3) {
- for (int c1 = 0; c1 < cKinds.length; ++c1) {
- for (int c2 = 0; c2 < cKinds.length; ++c2) {
- for (int c3 = 0; c3 < cKinds.length; ++c3) {
- totest.add( new Hierarchy(
- new ClassCase(cKinds[c1],
- new ClassCase(cKinds[c2],
- new ClassCase(cKinds[c3],
- null,
- iList(iKinds[i1])
- ),
- iList(iKinds[i2])
- ),
- iList(iKinds[i3])
- )));
- }
- }
- }
- }
- }
- }
- return totest;
- }
-
- public static final List<ClassCase> EMPTY_LIST = new ArrayList<>();
-
- private List<ClassCase> iList(Kind kind) {
- if (kind == null) {
- return EMPTY_LIST;
- } else {
- List<ClassCase> itfs = new ArrayList<>();
- itfs.add(new ClassCase(kind, null, EMPTY_LIST));
- return itfs;
- }
- }
-
- public List<Hierarchy> ciShapes() {
- return wrapInHierarchy(TTShape.allCases(true));
- }
-
- public List<Hierarchy> iShapes() {
- return wrapInClassAndHierarchy(TTShape.allCases(false));
- }
-
- public List<Hierarchy> wrapInClassAndHierarchy(List<ClassCase> ihs) {
- List<Hierarchy> totest = new ArrayList<>();
- for (ClassCase cc : ihs) {
- List<ClassCase> interfaces = new ArrayList<>();
- interfaces.add(cc);
- totest.add(new Hierarchy(new ClassCase(CNONE, null, interfaces)));
- }
- return totest;
- }
-
- public List<Hierarchy> wrapInHierarchy(List<ClassCase> ihs) {
- List<Hierarchy> totest = new ArrayList<>();
- for (ClassCase cc : ihs) {
- totest.add(new Hierarchy(cc));
- }
- return totest;
- }
-}
--- a/jdk/test/jdk/lambda/shapegen/Rule.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package shapegen;
-
-/**
- *
- * @author Robert Field
- */
-public abstract class Rule {
-
- public final String name;
-
- public Rule(String name) {
- this.name = name;
- }
-
- abstract boolean guard(ClassCase cc);
-
- abstract void eval(ClassCase cc);
-
- @Override
- public String toString() {
- return name;
- }
-}
--- a/jdk/test/jdk/lambda/shapegen/RuleGroup.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,204 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package shapegen;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import static shapegen.ClassCase.Kind.*;
-
-/**
- *
- * @author Robert Field
- */
-public class RuleGroup {
-
- final String name;
- private final Rule[] rules;
-
- public RuleGroup(String name, Rule[] rules) {
- this.name = name;
- this.rules = rules;
- }
-
- public boolean exec(ClassCase cc) {
- boolean found = false;
- for (Rule rule : rules) {
- if (rule.guard(cc)) {
- if (found) {
- throw new RuntimeException("Bad rules -- multiple matches " + toString() + " for " + cc);
- } else {
- rule.eval(cc);
- found = true;
- }
- }
- }
- return found;
- }
-
- @Override
- public String toString() {
- return name;
- }
-
- public static RuleGroup PROVENENCE = new RuleGroup("Provenence", new Rule[] {
- new Rule("P-CDeclare") {
- boolean guard(ClassCase cc) {
- return cc.isa(CCONCRETE, CABSTRACT);
- }
-
- void eval(ClassCase cc) {
- cc.set_mprov(cc);
- cc.set_HasClassMethod(true);
- }
- },
-
- new Rule("P-IDeclare") {
- boolean guard(ClassCase cc) {
- return cc.isa(IDEFAULT, IPRESENT);
- }
-
- void eval(ClassCase cc) {
- cc.set_mprov(cc);
- }
- },
-
- new Rule("P-IntfInh") {
- boolean guard(ClassCase cc) {
- return cc.isa(IVAC, CNONE) && !(cc.hasSuperclass() && cc.getSuperclass().get_HasClassMethod());
- }
-
- void eval(ClassCase cc) {
- Set<ClassCase> _S = new HashSet<>();
- for (ClassCase t : cc.getSupertypes()) {
- _S.addAll(t.get_mprov());
- }
- Set<ClassCase> tops = new HashSet<>();
- for (ClassCase _W : _S) {
- for (ClassCase _V : _S) {
- if (_V.equals(_W) || !(_V.isSubtypeOf(_W))) {
- tops.add(_W);
- }
- }
- }
- cc.set_mprov(tops);
- }
- },
-
- new Rule("P-ClassInh") {
- boolean guard(ClassCase cc) {
- return cc.isa(CNONE) && (cc.hasSuperclass() && cc.getSuperclass().get_HasClassMethod());
- }
-
- void eval(ClassCase cc) {
- cc.set_mprov(cc.getSuperclass());
- cc.set_HasClassMethod(true);
- }
- },
-
- });
-
- public static RuleGroup MARKER = new RuleGroup("Marker", new Rule[] {
- new Rule("M-Default") {
- boolean guard(ClassCase cc) {
- return cc.isa(IDEFAULT);
- }
-
- void eval(ClassCase cc) {
- cc.set_HasDefault(true);
- }
- },
-
- new Rule("M-Conc") {
- boolean guard(ClassCase cc) {
- return cc.isa(CCONCRETE);
- }
-
- void eval(ClassCase cc) {
- cc.set_IsConcrete(true);
- }
- },
-
- });
-
- public static RuleGroup RESOLUTION = new RuleGroup("Resolution", new Rule[] {
- new Rule("R-Resolve") {
- boolean guard(ClassCase cc) {
- if (!(cc.isClass() && cc.get_mprov().size() == 1)) {
- return false;
- }
- ClassCase _V = cc.get_mprov().iterator().next();
- return _V.get_IsConcrete() || _V.get_HasDefault();
- }
-
- void eval(ClassCase cc) {
- ClassCase _V = cc.get_mprov().iterator().next();
- cc.set_mres(_V);
- }
- },
-
- });
-
- public static RuleGroup DEFENDER = new RuleGroup("Defender", new Rule[] {
- new Rule("D-Defend") {
- boolean guard(ClassCase cc) {
- ClassCase mresSuper = cc.hasSuperclass() ? cc.getSuperclass().get_mres() : null;
- boolean eq = cc.get_mres() == null ? mresSuper == null : cc.get_mres().equals(mresSuper);
- return cc.isa(CNONE) && !eq;
- }
-
- void eval(ClassCase cc) {
- cc.set_mdefend(cc.get_mres());
- }
- },
-
- });
-
- public static RuleGroup CHECKING = new RuleGroup("Checking", new Rule[] {
- new Rule("C-Check") {
- boolean guard(ClassCase cc) {
- for (ClassCase t : cc.getSupertypes()) {
- if (! t.get_OK()) {
- return false;
- }
- }
- int defenderCount = 0;
- int provCount = 0;
- for (ClassCase prov : cc.get_mprov()) {
- if (prov.get_HasDefault()) {
- defenderCount++;
- }
- provCount++;
- }
- return provCount <= 1 || defenderCount == 0;
- }
-
- void eval(ClassCase cc) {
- cc.set_OK(true);
- }
- },
-
- });
-
-}
--- a/jdk/test/jdk/lambda/shapegen/TTNode.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,124 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package shapegen;
-
-import shapegen.ClassCase.Kind;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import static shapegen.ClassCase.Kind.*;
-
-/**
- * Type Template Node
- *
- * @author Robert Field
- */
-public class TTNode {
-
- final List<TTNode> supertypes;
- final boolean canBeClass;
-
- private int currentKindIndex;
- private Kind[] kinds;
-
- public TTNode(List<TTNode> subtypes, boolean canBeClass) {
- this.supertypes = subtypes;
- this.canBeClass = canBeClass;
- }
-
- public void start(boolean includeClasses) {
- kinds =
- supertypes.isEmpty()?
- (new Kind[]{IDEFAULT, IPRESENT})
- : ((includeClasses && canBeClass)?
- new Kind[]{CNONE, IVAC, IDEFAULT, IPRESENT}
- : new Kind[]{IVAC, IDEFAULT, IPRESENT});
- currentKindIndex = 0;
-
- for (TTNode sub : supertypes) {
- sub.start(includeClasses);
- }
- }
-
- public boolean next() {
- ++currentKindIndex;
- if (currentKindIndex >= kinds.length) {
- currentKindIndex = 0;
- return false;
- } else {
- return true;
- }
- }
-
- public void collectAllSubtypes(Set<TTNode> subs) {
- subs.add(this);
- for (TTNode n : supertypes) {
- n.collectAllSubtypes(subs);
- }
- }
-
- private Kind getKind() {
- return kinds[currentKindIndex];
- }
-
- boolean isInterface() {
- return getKind().isInterface;
- }
-
- boolean isClass() {
- return !isInterface();
- }
-
- boolean hasDefault() {
- return getKind() == IDEFAULT;
- }
-
- public boolean isValid() {
- for (TTNode n : supertypes) {
- if (!n.isValid() || (isInterface() && n.isClass())) {
- return false;
- }
- }
- return true;
- }
-
- public ClassCase genCase() {
- ClassCase subclass;
- List<TTNode> ttintfs;
- if (isClass() && !supertypes.isEmpty() && supertypes.get(0).isClass()) {
- subclass = supertypes.get(0).genCase();
- ttintfs = supertypes.subList(1, supertypes.size());
- } else {
- subclass = null;
- ttintfs = supertypes;
- }
- List<ClassCase> intfs = new ArrayList<>();
- for (TTNode node : ttintfs) {
- intfs.add(node.genCase());
- }
- return new ClassCase(getKind(), subclass, intfs);
- }
-}
--- a/jdk/test/jdk/lambda/shapegen/TTParser.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,98 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package shapegen;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.io.IOException;
-import java.io.StringReader;
-
-import static java.lang.Character.isLetter;
-import static java.lang.Character.isUpperCase;
-import static java.lang.Character.isWhitespace;
-
-/**
- * Parse a type template definition string
- *
- * input :: classDef
- * classDef :: letter [ ( classDef* ) ]
- *
- * @author Robert Field
- */
-public class TTParser extends StringReader {
-
- private Map<Character, TTNode> letterMap = new HashMap<>();
- private char ch;
-
- private final String def;
-
- public TTParser(String s) {
- super(s);
- this.def = s;
- }
-
- private void advance() throws IOException {
- do {
- ch = (char)read();
- } while (isWhitespace(ch));
- }
-
- public TTNode parse() {
- try {
- advance();
- return classDef();
- } catch (IOException t) {
- throw new RuntimeException(t);
- }
- }
-
- private TTNode classDef() throws IOException {
- if (!isLetter(ch)) {
- if (ch == (char)-1) {
- throw new IOException("Unexpected end of type template in " + def);
- } else {
- throw new IOException("Unexpected character in type template: " + (Character)ch + " in " + def);
- }
- }
- char nodeCh = ch;
- TTNode node = letterMap.get(nodeCh);
- boolean canBeClass = isUpperCase(nodeCh);
- advance();
- if (node == null) {
- List<TTNode> subtypes = new ArrayList<>();
- if (ch == '(') {
- advance();
- while (ch != ')') {
- subtypes.add(classDef());
- }
- advance();
- }
- node = new TTNode(subtypes, canBeClass);
- letterMap.put(nodeCh, node);
- }
- return node;
- }
-}
--- a/jdk/test/jdk/lambda/shapegen/TTShape.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,102 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package shapegen;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- *
- * @author Robert Field
- */
-public class TTShape {
-
- private final TTNode root;
- private final TTNode[] nodes;
-
- TTShape(TTNode root) {
- this.root = root;
- Set<TTNode> subs = new HashSet<>();
- root.collectAllSubtypes(subs);
- nodes = subs.toArray(new TTNode[subs.size()]);
- }
-
- private List<ClassCase> toCases(boolean includeClasses) {
- List<ClassCase> ccs = new ArrayList<>();
- root.start(includeClasses);
- int i;
- outer:
- while (true) {
- if (root.isValid()) {
- ClassCase cc = root.genCase();
- //System.out.println(cc);
- ccs.add(cc);
- }
-
- i = 0;
- do {
- if (i >= nodes.length) {
- break outer;
- }
- } while(!nodes[i++].next());
- }
- return ccs;
- }
-
- public static List<ClassCase> allCases(boolean includeClasses) {
- List<ClassCase> ccs = new ArrayList<>();
- for (TTShape shape : SHAPES) {
- ccs.addAll(shape.toCases(includeClasses));
- }
- return ccs;
- }
-
- public static TTShape parse(String s) {
- return new TTShape(new TTParser(s).parse());
- }
-
- public static final TTShape[] SHAPES = new TTShape[] {
- parse("a"),
- parse("a(b)"),
- parse("A(bb)"),
- parse("A(B(d)c(d))"),
- parse("A(b(c))"),
- parse("A(B(cd)d)"),
- parse("A(B(c)c)"),
- parse("A(B(Ce)d(e))"),
- parse("A(B(C)d(e))"),
- parse("A(Bc(d))"),
- parse("A(B(d)dc)"),
- parse("A(B(dc)dc)"),
- parse("A(B(c(d))d)"),
- parse("A(B(C(d))d)"),
- parse("A(B(C(e)d(e))e)"),
- parse("A(B(c(d))c)"),
- parse("A(B(dc(d))c)"),
- parse("A(B(C(d))d)"),
- };
-
-}
--- a/jdk/test/sun/util/calendar/zi/tzdata/VERSION Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/test/sun/util/calendar/zi/tzdata/VERSION Tue Apr 14 12:10:00 2015 -0700
@@ -21,4 +21,4 @@
# or visit www.oracle.com if you need additional information or have any
# questions.
#
-tzdata2015a
+tzdata2015b
--- a/jdk/test/sun/util/calendar/zi/tzdata/asia Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/test/sun/util/calendar/zi/tzdata/asia Tue Apr 14 12:10:00 2015 -0700
@@ -1927,6 +1927,13 @@
# was at the start of 2008-03-31 (the day of Steffen Thorsen's report);
# this is almost surely wrong.
+# From Ganbold Tsagaankhuu (2015-03-10):
+# It seems like yesterday Mongolian Government meeting has concluded to use
+# daylight saving time in Mongolia.... Starting at 2:00AM of last Saturday of
+# March 2015, daylight saving time starts. And 00:00AM of last Saturday of
+# September daylight saving time ends. Source:
+# http://zasag.mn/news/view/8969
+
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Mongol 1983 1984 - Apr 1 0:00 1:00 S
Rule Mongol 1983 only - Oct 1 0:00 0 -
@@ -1947,6 +1954,8 @@
Rule Mongol 2001 only - Apr lastSat 2:00 1:00 S
Rule Mongol 2001 2006 - Sep lastSat 2:00 0 -
Rule Mongol 2002 2006 - Mar lastSat 2:00 1:00 S
+Rule Mongol 2015 max - Mar lastSat 2:00 1:00 S
+Rule Mongol 2015 max - Sep lastSat 0:00 0 -
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
# Hovd, a.k.a. Chovd, Dund-Us, Dzhargalant, Khovd, Jirgalanta
@@ -2365,13 +2374,19 @@
# official source...:
# http://www.palestinecabinet.gov.ps/ar/Views/ViewDetails.aspx?pid=1252
-# From Paul Eggert (2013-09-24):
-# For future dates, guess the last Thursday in March at 24:00 through
-# the first Friday on or after September 21 at 00:00. This is consistent with
-# the predictions in today's editions of the following URLs,
-# which are for Gaza and Hebron respectively:
-# http://www.timeanddate.com/worldclock/timezone.html?n=702
-# http://www.timeanddate.com/worldclock/timezone.html?n=2364
+# From Steffen Thorsen (2015-03-03):
+# Sources such as http://www.alquds.com/news/article/view/id/548257
+# and http://www.raya.ps/ar/news/890705.html say Palestine areas will
+# start DST on 2015-03-28 00:00 which is one day later than expected.
+#
+# From Paul Eggert (2015-03-03):
+# http://www.timeanddate.com/time/change/west-bank/ramallah?year=2014
+# says that the fall 2014 transition was Oct 23 at 24:00.
+# For future dates, guess the last Friday in March at 24:00 through
+# the first Friday on or after October 21 at 00:00. This is consistent with
+# the predictions in today's editions of the following URLs:
+# http://www.timeanddate.com/time/change/gaza-strip/gaza
+# http://www.timeanddate.com/time/change/west-bank/hebron
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule EgyptAsia 1957 only - May 10 0:00 1:00 S
@@ -2397,9 +2412,11 @@
Rule Palestine 2011 only - Aug 1 0:00 0 -
Rule Palestine 2011 only - Aug 30 0:00 1:00 S
Rule Palestine 2011 only - Sep 30 0:00 0 -
-Rule Palestine 2012 max - Mar lastThu 24:00 1:00 S
+Rule Palestine 2012 2014 - Mar lastThu 24:00 1:00 S
Rule Palestine 2012 only - Sep 21 1:00 0 -
-Rule Palestine 2013 max - Sep Fri>=21 0:00 0 -
+Rule Palestine 2013 only - Sep Fri>=21 0:00 0 -
+Rule Palestine 2014 max - Oct Fri>=21 0:00 0 -
+Rule Palestine 2015 max - Mar lastFri 24:00 1:00 S
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Asia/Gaza 2:17:52 - LMT 1900 Oct
--- a/jdk/test/sun/util/calendar/zi/tzdata/australasia Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/test/sun/util/calendar/zi/tzdata/australasia Tue Apr 14 12:10:00 2015 -0700
@@ -396,6 +396,7 @@
9:39:00 - LMT 1901 # Agana
10:00 - GST 2000 Dec 23 # Guam
10:00 - ChST # Chamorro Standard Time
+Link Pacific/Guam Pacific/Saipan # N Mariana Is
# Kiribati
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
@@ -411,12 +412,7 @@
14:00 - LINT
# N Mariana Is
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Pacific/Saipan -14:17:00 - LMT 1844 Dec 31
- 9:43:00 - LMT 1901
- 9:00 - MPT 1969 Oct # N Mariana Is Time
- 10:00 - MPT 2000 Dec 23
- 10:00 - ChST # Chamorro Standard Time
+# See Pacific/Guam.
# Marshall Is
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
@@ -586,6 +582,7 @@
-11:00 - NST 1967 Apr # N=Nome
-11:00 - BST 1983 Nov 30 # B=Bering
-11:00 - SST # S=Samoa
+Link Pacific/Pago_Pago Pacific/Midway # in US minor outlying islands
# Samoa (formerly and also known as Western Samoa)
@@ -767,23 +764,7 @@
# uninhabited
# Midway
-#
-# From Mark Brader (2005-01-23):
-# [Fallacies and Fantasies of Air Transport History, by R.E.G. Davies,
-# published 1994 by Paladwr Press, McLean, VA, USA; ISBN 0-9626483-5-3]
-# reproduced a Pan American Airways timetable from 1936, for their weekly
-# "Orient Express" flights between San Francisco and Manila, and connecting
-# flights to Chicago and the US East Coast. As it uses some time zone
-# designations that I've never seen before:....
-# Fri. 6:30A Lv. HONOLOLU (Pearl Harbor), H.I. H.L.T. Ar. 5:30P Sun.
-# " 3:00P Ar. MIDWAY ISLAND . . . . . . . . . M.L.T. Lv. 6:00A "
-#
-Zone Pacific/Midway -11:49:28 - LMT 1901
- -11:00 - NST 1956 Jun 3
- -11:00 1:00 NDT 1956 Sep 2
- -11:00 - NST 1967 Apr # N=Nome
- -11:00 - BST 1983 Nov 30 # B=Bering
- -11:00 - SST # S=Samoa
+# See Pacific/Pago_Pago.
# Palmyra
# uninhabited since World War II; was probably like Pacific/Kiritimati
--- a/jdk/test/sun/util/calendar/zi/tzdata/europe Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/test/sun/util/calendar/zi/tzdata/europe Tue Apr 14 12:10:00 2015 -0700
@@ -2423,7 +2423,7 @@
4:00 Russia VOL%sT 1989 Mar 26 2:00s # Volgograd T
3:00 Russia VOL%sT 1991 Mar 31 2:00s
4:00 - VOLT 1992 Mar 29 2:00s
- 3:00 Russia MSK 2011 Mar 27 2:00s
+ 3:00 Russia MSK/MSD 2011 Mar 27 2:00s
4:00 - MSK 2014 Oct 26 2:00s
3:00 - MSK
--- a/jdk/test/sun/util/calendar/zi/tzdata/northamerica Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/test/sun/util/calendar/zi/tzdata/northamerica Tue Apr 14 12:10:00 2015 -0700
@@ -2335,8 +2335,24 @@
# "...the new time zone will come into effect at two o'clock on the first Sunday
# of February, when we will have to advance the clock one hour from its current
# time..."
+# Also, the new zone will not use DST.
#
-# Also, the new zone will not use DST.
+# From Carlos Raúl Perasso (2015-02-02):
+# The decree that modifies the Mexican Hour System Law has finally
+# been published at the Diario Oficial de la Federación
+# http://www.dof.gob.mx/nota_detalle.php?codigo=5380123&fecha=31/01/2015
+# It establishes 5 zones for Mexico:
+# 1- Zona Centro (Central Zone): Corresponds to longitude 90 W,
+# includes most of Mexico, excluding what's mentioned below.
+# 2- Zona PacÃfico (Pacific Zone): Longitude 105 W, includes the
+# states of Baja California Sur; Chihuahua; Nayarit (excluding BahÃa
+# de Banderas which lies in Central Zone); Sinaloa and Sonora.
+# 3- Zona Noroeste (Northwest Zone): Longitude 120 W, includes the
+# state of Baja California.
+# 4- Zona Sureste (Southeast Zone): Longitude 75 W, includes the state
+# of Quintana Roo.
+# 5- The islands, reefs and keys shall take their timezone from the
+# longitude they are located at.
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Mexico 1939 only - Feb 5 0:00 1:00 D
@@ -2531,14 +2547,9 @@
###############################################################################
# Anguilla
+# Antigua and Barbuda
# See America/Port_of_Spain.
-# Antigua and Barbuda
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone America/Antigua -4:07:12 - LMT 1912 Mar 2
- -5:00 - EST 1951
- -4:00 - AST
-
# Bahamas
#
# For 1899 Milne gives -5:09:29.5; round that.
@@ -2604,10 +2615,7 @@
-4:00 US A%sT
# Cayman Is
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone America/Cayman -5:25:32 - LMT 1890 # Georgetown
- -5:07:11 - KMT 1912 Feb # Kingston Mean Time
- -5:00 - EST
+# See America/Panama.
# Costa Rica
@@ -3130,6 +3138,7 @@
Zone America/Panama -5:18:08 - LMT 1890
-5:19:36 - CMT 1908 Apr 22 # Colón Mean Time
-5:00 - EST
+Link America/Panama America/Cayman
# Puerto Rico
# There are too many San Juans elsewhere, so we'll use 'Puerto_Rico'.
--- a/jdk/test/sun/util/calendar/zi/tzdata/southamerica Mon Apr 13 17:03:11 2015 -0700
+++ b/jdk/test/sun/util/calendar/zi/tzdata/southamerica Tue Apr 14 12:10:00 2015 -0700
@@ -1229,10 +1229,13 @@
# DST Start: first Saturday of September 2014 (Sun 07 Sep 2014 04:00 UTC)
# http://www.diariooficial.interior.gob.cl//media/2014/02/19/do-20140219.pdf
-# From Juan Correa (2015-01-28):
-# ... today the Ministry of Energy announced that Chile will drop DST, will keep
-# "summer time" (UTC -3 / UTC -5) all year round....
-# http://www.minenergia.cl/ministerio/noticias/generales/ministerio-de-energia-anuncia.html
+# From Eduardo Romero Urra (2015-03-03):
+# Today has been published officially that Chile will use the DST time
+# permanently until March 25 of 2017
+# http://www.diariooficial.interior.gob.cl/media/2015/03/03/1-large.jpg
+#
+# From Paul Eggert (2015-03-03):
+# For now, assume that the extension will persist indefinitely.
# NOTE: ChileAQ rules for Antarctic bases are stored separately in the
# 'antarctica' file.
@@ -1291,7 +1294,7 @@
-3:00 - CLT
Zone Pacific/Easter -7:17:44 - LMT 1890
-7:17:28 - EMT 1932 Sep # Easter Mean Time
- -7:00 Chile EAS%sT 1982 Mar 13 3:00u # Easter Time
+ -7:00 Chile EAS%sT 1982 Mar 14 3:00u # Easter Time
-6:00 Chile EAS%sT 2015 Apr 26 3:00u
-5:00 - EAST
#
@@ -1626,6 +1629,7 @@
# These all agree with Trinidad and Tobago since 1970.
Link America/Port_of_Spain America/Anguilla
+Link America/Port_of_Spain America/Antigua
Link America/Port_of_Spain America/Dominica
Link America/Port_of_Spain America/Grenada
Link America/Port_of_Spain America/Guadeloupe
--- a/langtools/.hgtags Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/.hgtags Tue Apr 14 12:10:00 2015 -0700
@@ -300,3 +300,5 @@
32a2e724988499e6f68611a65168c5f2fde0f6b9 jdk9-b55
5ee7bba6ef41447f921184e8522da36734aec089 jdk9-b56
ec977a00cecbf0007b0fa26c7af2852d57a79cad jdk9-b57
+07ce89fec30165a2f1212047bd23b30086ed1e74 jdk9-b58
+a598534d277e170a0bbf177bd54d9d179245532b jdk9-b59
--- a/langtools/make/CompileInterim.gmk Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/make/CompileInterim.gmk Tue Apr 14 12:10:00 2015 -0700
@@ -43,7 +43,6 @@
$(LANGTOOLS_TOPDIR)/src/jdk.compiler/share/classes \
$(LANGTOOLS_TOPDIR)/src/jdk.dev/share/classes \
$(LANGTOOLS_TOPDIR)/src/jdk.javadoc/share/classes \
- $(LANGTOOLS_TOPDIR)/src/java.base/share/classes \
$(SUPPORT_OUTPUTDIR)/gensrc/jdk.compiler \
$(SUPPORT_OUTPUTDIR)/gensrc/jdk.dev \
$(SUPPORT_OUTPUTDIR)/gensrc/jdk.javadoc, \
--- a/langtools/make/Makefile Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-#
-# Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation. Oracle designates this
-# particular file as subject to the "Classpath" exception as provided
-# by Oracle in the LICENSE file that accompanied this code.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# Locate this Makefile
-ifeq ($(filter /%, $(lastword $(MAKEFILE_LIST))), )
- makefile_path := $(CURDIR)/$(lastword $(MAKEFILE_LIST))
-else
- makefile_path := $(lastword $(MAKEFILE_LIST))
-endif
-repo_dir := $(patsubst %/make/Makefile, %, $(makefile_path))
-
-# What is the name of this subsystem (langtools, corba, etc)?
-subsystem_name := $(notdir $(repo_dir))
-
-# Try to locate top-level makefile
-top_level_makefile := $(repo_dir)/../Makefile
-ifneq ($(wildcard $(top_level_makefile)), )
- $(info Will run $(subsystem_name) target on top-level Makefile)
- $(info WARNING: This is a non-recommended way of building!)
- $(info ===================================================)
-else
- $(info Cannot locate top-level Makefile. Is this repo not checked out as part of a complete forest?)
- $(error Build from top-level Makefile instead)
-endif
-
-all:
- @$(MAKE) -f $(top_level_makefile) $(subsystem_name)
--- a/langtools/make/build.properties Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/make/build.properties Tue Apr 14 12:10:00 2015 -0700
@@ -47,12 +47,11 @@
boot.javac.target = 8
#configuration of submodules (share by both the bootstrap and normal compilation):
-langtools.modules=java.base:java.compiler:jdk.compiler:jdk.dev:jdk.javadoc
-java.base.dependencies=
-java.compiler.dependencies=java.base
-jdk.compiler.dependencies=java.base:java.compiler
-jdk.javadoc.dependencies=java.base:java.compiler:jdk.compiler
-jdk.dev.dependencies=java.base:java.compiler:jdk.compiler
+langtools.modules=java.compiler:jdk.compiler:jdk.dev:jdk.javadoc
+java.compiler.dependencies=
+jdk.compiler.dependencies=java.compiler
+jdk.javadoc.dependencies=java.compiler:jdk.compiler
+jdk.dev.dependencies=java.compiler:jdk.compiler
javac.resource.includes = \
com/sun/tools/javac/resources/compiler.properties
--- a/langtools/make/build.xml Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/make/build.xml Tue Apr 14 12:10:00 2015 -0700
@@ -254,7 +254,6 @@
warningsProperty="findbugs.all.warnings"
jvm="${target.java.home}/bin/java"
jvmargs="-Xmx512M">
- <class location="${build.dir}/java.base/classes"/>
<class location="${build.dir}/java.compiler/classes"/>
<class location="${build.dir}/jdk.compiler/classes"/>
<class location="${build.dir}/jdk.javadoc/classes"/>
@@ -461,7 +460,6 @@
<macrodef name="build-all-module-jars">
<attribute name="compilation.kind" default=""/>
<sequential>
- <build-module-jar module.name="java.base" compilation.kind="@{compilation.kind}" />
<build-module-jar module.name="java.compiler" compilation.kind="@{compilation.kind}" />
<build-module-jar module.name="jdk.compiler" compilation.kind="@{compilation.kind}" />
<build-module-jar module.name="jdk.javadoc" compilation.kind="@{compilation.kind}" />
@@ -522,8 +520,6 @@
<macrodef name="build-all-module-classes">
<attribute name="compilation.kind" default=""/>
<sequential>
- <build-module-classes module.name="java.base"
- compilation.kind="@{compilation.kind}" />
<build-module-classes module.name="java.compiler"
compilation.kind="@{compilation.kind}" />
<build-module-classes module.name="jdk.compiler"
--- a/langtools/make/intellij/langtools.iml Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/make/intellij/langtools.iml Tue Apr 14 12:10:00 2015 -0700
@@ -4,13 +4,11 @@
<output url="file://$MODULE_DIR$/build" />
<output-test url="file://$MODULE_DIR$/build" />
<content url="file://$MODULE_DIR$">
- <sourceFolder url="file://$MODULE_DIR$/src/java.base/share/classes" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/java.compiler/share/classes" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/jdk.compiler/share/classes" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/jdk.dev/share/classes" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/jdk.javadoc/share/classes" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
- <sourceFolder url="file://$MODULE_DIR$/build/bootstrap/java.base/gensrc" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/build/bootstrap/java.compiler/gensrc" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/build/bootstrap/jdk.compiler/gensrc" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/build/bootstrap/jdk.dev/gensrc" isTestSource="false" />
--- a/langtools/make/intellij/workspace.xml Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/make/intellij/workspace.xml Tue Apr 14 12:10:00 2015 -0700
@@ -10,7 +10,7 @@
<!-- standard tools -->
<configuration default="false" name="javac" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" value="com.sun.tools.javac.Main" />
- <option name="VM_PARAMETERS" value="-Xbootclasspath/p:build@FILE_SEP@java.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@java.base@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.javadoc@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.dev@FILE_SEP@classes" />
+ <option name="VM_PARAMETERS" value="-Xbootclasspath/p:build@FILE_SEP@java.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.javadoc@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.dev@FILE_SEP@classes" />
<option name="PROGRAM_PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
@@ -29,7 +29,7 @@
</configuration>
<configuration default="false" name="javadoc" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" value="com.sun.tools.javadoc.Main" />
- <option name="VM_PARAMETERS" value="-Xbootclasspath/p:build@FILE_SEP@java.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@java.base@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.javadoc@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.dev@FILE_SEP@classes" />
+ <option name="VM_PARAMETERS" value="-Xbootclasspath/p:build@FILE_SEP@java.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.javadoc@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.dev@FILE_SEP@classes" />
<option name="PROGRAM_PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
@@ -48,7 +48,7 @@
</configuration>
<configuration default="false" name="javap" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" value="com.sun.tools.javap.Main" />
- <option name="VM_PARAMETERS" value="-Xbootclasspath/p:build@FILE_SEP@java.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@java.base@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.javadoc@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.dev@FILE_SEP@classes" />
+ <option name="VM_PARAMETERS" value="-Xbootclasspath/p:build@FILE_SEP@java.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.javadoc@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.dev@FILE_SEP@classes" />
<option name="PROGRAM_PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
@@ -67,7 +67,7 @@
</configuration>
<configuration default="false" name="javah" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" value="com.sun.tools.javah.Main" />
- <option name="VM_PARAMETERS" value="-Xbootclasspath/p:build@FILE_SEP@java.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@java.base@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.javadoc@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.dev@FILE_SEP@classes" />
+ <option name="VM_PARAMETERS" value="-Xbootclasspath/p:build@FILE_SEP@java.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.javadoc@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.dev@FILE_SEP@classes" />
<option name="PROGRAM_PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
@@ -86,7 +86,7 @@
</configuration>
<configuration default="false" name="sjavac" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" value="com.sun.tools.sjavac.Main" />
- <option name="VM_PARAMETERS" value="-Xbootclasspath/p:build@FILE_SEP@java.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@java.base@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.javadoc@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.dev@FILE_SEP@classes" />
+ <option name="VM_PARAMETERS" value="-Xbootclasspath/p:build@FILE_SEP@java.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.javadoc@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@jdk.dev@FILE_SEP@classes" />
<option name="PROGRAM_PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
@@ -106,7 +106,7 @@
<!-- bootstrap javac -->
<configuration default="false" name="javac (bootstrap)" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" value="com.sun.tools.javac.Main" />
- <option name="VM_PARAMETERS" value="-Xbootclasspath/p:build@FILE_SEP@bootstrap@FILE_SEP@java.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@bootstrap@FILE_SEP@jdk.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@bootstrap@FILE_SEP@java.base@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@bootstrap@FILE_SEP@jdk.javadoc@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@bootstrap@FILE_SEP@jdk.dev@FILE_SEP@classes" />
+ <option name="VM_PARAMETERS" value="-Xbootclasspath/p:build@FILE_SEP@bootstrap@FILE_SEP@java.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@bootstrap@FILE_SEP@jdk.compiler@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@bootstrap@FILE_SEP@jdk.javadoc@FILE_SEP@classes@PATH_SEP@build@FILE_SEP@bootstrap@FILE_SEP@jdk.dev@FILE_SEP@classes" />
<option name="PROGRAM_PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
--- a/langtools/make/netbeans/langtools/nbproject/project.xml Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/make/netbeans/langtools/nbproject/project.xml Tue Apr 14 12:10:00 2015 -0700
@@ -57,11 +57,6 @@
<location>${root}/make</location>
</source-folder>
<source-folder>
- <label>Source files - java.base</label>
- <type>java</type>
- <location>${root}/src/java.base/share/classes</location>
- </source-folder>
- <source-folder>
<label>Source files - java.compiler</label>
<type>java</type>
<location>${root}/src/java.compiler/share/classes</location>
@@ -107,19 +102,6 @@
</action>
<action name="compile.single">
<target>compile-single</target>
- <property name="module.name">java.base</property>
- <context>
- <property>includes</property>
- <folder>${root}/src/java.base/share/classes</folder>
- <pattern>\.java$</pattern>
- <format>relative-path</format>
- <arity>
- <separated-files>,</separated-files>
- </arity>
- </context>
- </action>
- <action name="compile.single">
- <target>compile-single</target>
<property name="module.name">java.compiler</property>
<context>
<property>includes</property>
@@ -259,18 +241,6 @@
<target>debug-single</target>
<context>
<property>debug.classname</property>
- <folder>${root}/src/java.base/share/classes</folder>
- <pattern>\.java$</pattern>
- <format>java-name</format>
- <arity>
- <one-file-only/>
- </arity>
- </context>
- </action>
- <action name="debug.single">
- <target>debug-single</target>
- <context>
- <property>debug.classname</property>
<folder>${root}/src/java.compiler/share/classes</folder>
<pattern>\.java$</pattern>
<format>java-name</format>
@@ -333,19 +303,6 @@
</action>
<action name="debug.fix">
<target>debug-fix</target>
- <property name="module.name">java.base</property>
- <context>
- <property>class</property>
- <folder>${root}/src/java.base/share/classes</folder>
- <pattern>\.java$</pattern>
- <format>relative-path-noext</format>
- <arity>
- <one-file-only/>
- </arity>
- </context>
- </action>
- <action name="debug.fix">
- <target>debug-fix</target>
<property name="module.name">java.compiler</property>
<context>
<property>class</property>
@@ -417,10 +374,6 @@
<view>
<items>
<source-folder style="tree">
- <label>Source files - java.base</label>
- <location>${root}/src/java.base/share/classes</location>
- </source-folder>
- <source-folder style="tree">
<label>Source files - java.compiler</label>
<location>${root}/src/java.compiler/share/classes</location>
</source-folder>
@@ -477,36 +430,29 @@
</general-data>
<java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/4">
<compilation-unit>
- <package-root>${root}/src/java.base/share/classes</package-root>
- <package-root>${root}/build/bootstrap/java.base/gensrc</package-root>
- <built-to>${root}/build/java.base/classes</built-to>
- <source-level>1.8</source-level>
- </compilation-unit>
- <compilation-unit>
<package-root>${root}/src/java.compiler/share/classes</package-root>
<package-root>${root}/build/bootstrap/java.compiler/gensrc</package-root>
- <classpath mode="compile">${root}/build/java.base/classes</classpath>
<built-to>${root}/build/java.compiler/classes</built-to>
<source-level>1.8</source-level>
</compilation-unit>
<compilation-unit>
<package-root>${root}/src/jdk.compiler/share/classes</package-root>
<package-root>${root}/build/bootstrap/jdk.compiler/gensrc</package-root>
- <classpath mode="compile">${root}/build/java.base/classes:${root}/build/java.compiler/classes</classpath>
+ <classpath mode="compile">${root}/build/java.compiler/classes</classpath>
<built-to>${root}/build/jdk.compiler/classes</built-to>
<source-level>1.8</source-level>
</compilation-unit>
<compilation-unit>
<package-root>${root}/src/jdk.dev/share/classes</package-root>
<package-root>${root}/build/bootstrap/jdk.dev/gensrc</package-root>
- <classpath mode="compile">${root}/build/java.base/classes:${root}/build/java.compiler/classes:${root}/build/jdk.compiler/classes</classpath>
+ <classpath mode="compile">${root}/build/java.compiler/classes:${root}/build/jdk.compiler/classes</classpath>
<built-to>${root}/build/jdk.dev/classes</built-to>
<source-level>1.8</source-level>
</compilation-unit>
<compilation-unit>
<package-root>${root}/src/jdk.javadoc/share/classes</package-root>
<package-root>${root}/build/bootstrap/jdk.javadoc/gensrc</package-root>
- <classpath mode="compile">${root}/build/java.base/classes:${root}/build/java.compiler/classes:${root}/build/jdk.compiler/classes</classpath>
+ <classpath mode="compile">${root}/build/java.compiler/classes:${root}/build/jdk.compiler/classes</classpath>
<built-to>${root}/build/jdk.javadoc/classes</built-to>
<source-level>1.8</source-level>
</compilation-unit>
--- a/langtools/src/java.base/share/classes/jdk/Exported.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk;
-
-import java.lang.annotation.*;
-
-/**
- * Indicates whether or not a JDK specific type or package is an
- * exported part of the JDK suitable for use outside of the JDK
- * implementation itself.
- *
- * This annotation should only be applied to types and packages
- * <em>outside</em> of the Java SE namespaces of {@code java.*} and
- * {@code javax.*} packages. For example, certain portions of {@code
- * com.sun.*} are official parts of the JDK meant to be generally
- * usable while other portions of {@code com.sun.*} are not. This
- * annotation type allows those portions to be easily and
- * programmatically distinguished.
- *
- * <p>If in one release a type or package is
- * <code>@Exported(true)</code>, in a subsequent major release such a
- * type or package can transition to <code>@Exported(false)</code>.
- *
- * <p>If a type or package is <code>@Exported(false)</code> in a
- * release, it may be removed in a subsequent major release.
- *
- * <p>If a top-level type has an <code>@Exported</code> annotation,
- * any nested member types with the top-level type should have an
- * <code>@Exported</code> annotation with the same value.
- *
- * (In exceptional cases, if a nested type is going to be removed
- * before its enclosing type, the nested type's could be
- * <code>@Exported(false)</code> while its enclosing type was
- * <code>@Exported(true)</code>.)
- *
- * Likewise, if a package has an <code>@Exported</code> annotation,
- * top-level types within that package should also have an
- * <code>@Exported</code> annotation.
- *
- * Sometimes a top-level type may have a different
- * <code>@Exported</code> value than its package.
- *
- * @since 1.8
- */
-@Documented
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.TYPE, ElementType.PACKAGE})
-@Exported
-public @interface Exported {
- /**
- * Whether or not the annotated type or package is an exported
- * part of the JDK.
- * @return whether or not the annotated type or package is an exported
- * part of the JDK
- */
- boolean value() default true;
-}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java Tue Apr 14 12:10:00 2015 -0700
@@ -40,6 +40,7 @@
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.code.Symbol.ClassSymbol;
import com.sun.tools.javac.comp.*;
+import com.sun.tools.javac.file.BaseFileManager;
import com.sun.tools.javac.main.*;
import com.sun.tools.javac.main.JavaCompiler;
import com.sun.tools.javac.parser.Parser;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTool.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTool.java Tue Apr 14 12:10:00 2015 -0700
@@ -44,7 +44,7 @@
import com.sun.tools.javac.file.JavacFileManager;
import com.sun.tools.javac.main.Arguments;
import com.sun.tools.javac.main.Option;
-import com.sun.tools.javac.util.BaseFileManager;
+import com.sun.tools.javac.file.BaseFileManager;
import com.sun.tools.javac.util.ClientCodeException;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.DefinedBy;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java Tue Apr 14 12:10:00 2015 -0700
@@ -696,7 +696,8 @@
@DefinedBy(Api.COMPILER_TREE)
public TypeMirror getTypeMirror(TreePath path) {
Tree t = path.getLeaf();
- return ((JCTree)t).type;
+ Type ty = ((JCTree)t).type;
+ return ty == null ? null : ty.stripMetadataIfNeeded();
}
@DefinedBy(Api.COMPILER_TREE)
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,8 @@
package com.sun.tools.javac.code;
-import java.io.*;
+import java.io.IOException;
+import java.io.File;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
@@ -38,16 +39,15 @@
import javax.tools.StandardJavaFileManager;
import com.sun.tools.javac.code.Scope.WriteableScope;
-import com.sun.tools.javac.code.Symbol.*;
import com.sun.tools.javac.code.Symbol.ClassSymbol;
import com.sun.tools.javac.code.Symbol.Completer;
import com.sun.tools.javac.code.Symbol.CompletionFailure;
import com.sun.tools.javac.code.Symbol.PackageSymbol;
import com.sun.tools.javac.code.Symbol.TypeSymbol;
import com.sun.tools.javac.comp.Annotate;
+import com.sun.tools.javac.comp.Enter;
import com.sun.tools.javac.file.JRTIndex;
import com.sun.tools.javac.file.JavacFileManager;
-import com.sun.tools.javac.file.RelativePath.RelativeDirectory;
import com.sun.tools.javac.jvm.ClassReader;
import com.sun.tools.javac.jvm.Profile;
import com.sun.tools.javac.util.*;
@@ -75,7 +75,7 @@
ClassReader reader;
- Annotate annotate;
+ private final Annotate annotate;
/** Switch: verbose output.
*/
@@ -272,18 +272,13 @@
try {
ClassSymbol c = (ClassSymbol) sym;
dependencies.push(c, CompletionCause.CLASS_READER);
+ annotate.blockAnnotations();
c.members_field = new Scope.ErrorScope(c); // make sure it's always defined
- annotate.enterStart();
- try {
- completeOwners(c.owner);
- completeEnclosing(c);
- } finally {
- // The flush needs to happen only after annotations
- // are filled in.
- annotate.enterDoneWithoutFlush();
- }
+ completeOwners(c.owner);
+ completeEnclosing(c);
fillIn(c);
} finally {
+ annotate.unblockAnnotationsNoFlush();
dependencies.pop();
}
} else if (sym.kind == PCK) {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Kinds.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Kinds.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -66,22 +66,22 @@
MTH(Category.BASIC, KindName.METHOD, KindSelector.MTH),
POLY(Category.BASIC, KindSelector.POLY),
ERR(Category.ERROR, KindSelector.ERR),
- AMBIGUOUS(Category.OVERLOAD),
- HIDDEN(Category.OVERLOAD),
- STATICERR(Category.OVERLOAD),
- MISSING_ENCL(Category.OVERLOAD),
- ABSENT_VAR(Category.OVERLOAD, KindName.VAR),
- WRONG_MTHS(Category.OVERLOAD, KindName.METHOD),
- WRONG_MTH(Category.OVERLOAD, KindName.METHOD),
- ABSENT_MTH(Category.OVERLOAD, KindName.METHOD),
- ABSENT_TYP(Category.OVERLOAD, KindName.CLASS);
+ AMBIGUOUS(Category.RESOLUTION_TARGET), // overloaded target
+ HIDDEN(Category.RESOLUTION_TARGET), // not overloaded non-target
+ STATICERR(Category.RESOLUTION_TARGET), // overloaded? target
+ MISSING_ENCL(Category.RESOLUTION), // not overloaded non-target
+ ABSENT_VAR(Category.RESOLUTION_TARGET, KindName.VAR), // not overloaded non-target
+ WRONG_MTHS(Category.RESOLUTION_TARGET, KindName.METHOD), // overloaded target
+ WRONG_MTH(Category.RESOLUTION_TARGET, KindName.METHOD), // not overloaded target
+ ABSENT_MTH(Category.RESOLUTION_TARGET, KindName.METHOD), // not overloaded non-target
+ ABSENT_TYP(Category.RESOLUTION_TARGET, KindName.CLASS); // not overloaded non-target
// There are essentially two "levels" to the Kind datatype.
// The first is a totally-ordered set of categories of
// solutions. Within each category, we have more
// possibilities.
private enum Category {
- BASIC, ERROR, OVERLOAD;
+ BASIC, ERROR, RESOLUTION, RESOLUTION_TARGET;
}
private final KindName kindName;
@@ -127,8 +127,12 @@
return selector.contains(kindSelectors);
}
- public boolean isOverloadError() {
- return category == Category.OVERLOAD;
+ public boolean isResolutionError() {
+ return category == Category.RESOLUTION || category == Category.RESOLUTION_TARGET;
+ }
+
+ public boolean isResolutionTargetError() {
+ return category == Category.RESOLUTION_TARGET;
}
public boolean isValid() {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java Tue Apr 14 12:10:00 2015 -0700
@@ -209,6 +209,9 @@
public boolean allowPrivateSafeVarargs() {
return compareTo(JDK1_9) >= 0;
}
+ public boolean allowDiamondWithAnonymousClassCreation() {
+ return compareTo(JDK1_9) >= 0;
+ }
public boolean allowUnderscoreIdentifier() {
return compareTo(JDK1_8) <= 0;
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -33,6 +33,11 @@
import javax.lang.model.element.*;
import javax.tools.JavaFileObject;
+import com.sun.tools.javac.code.Attribute.Compound;
+import com.sun.tools.javac.code.TypeAnnotations.AnnotationType;
+import com.sun.tools.javac.code.TypeMetadata.Entry;
+import com.sun.tools.javac.comp.Annotate.AnnotationTypeCompleter;
+import com.sun.tools.javac.comp.Annotate.AnnotationTypeMetadata;
import com.sun.tools.javac.code.Scope.WriteableScope;
import com.sun.tools.javac.code.Type.*;
import com.sun.tools.javac.comp.Attr;
@@ -738,6 +743,13 @@
return list;
}
+ public AnnotationTypeMetadata getAnnotationTypeMetadata() {
+ Assert.error("Only on ClassSymbol");
+ return null; //unreachable
+ }
+
+ public boolean isAnnotationType() { return false; }
+
@Override
public <R, P> R accept(Symbol.Visitor<R, P> v, P p) {
return v.visitTypeSymbol(this, p);
@@ -958,6 +970,9 @@
*/
public Pool pool;
+ /** the annotation metadata attached to this class */
+ private AnnotationTypeMetadata annotationTypeMetadata;
+
public ClassSymbol(long flags, Name name, Type type, Symbol owner) {
super(TYP, flags, name, type, owner);
this.members_field = null;
@@ -966,6 +981,7 @@
this.sourcefile = null;
this.classfile = null;
this.pool = null;
+ this.annotationTypeMetadata = AnnotationTypeMetadata.notAnAnnotationType();
}
public ClassSymbol(long flags, Name name, Symbol owner) {
@@ -1202,8 +1218,24 @@
t.all_interfaces_field = null;
}
metadata = null;
+ annotationTypeMetadata = AnnotationTypeMetadata.notAnAnnotationType();
+ }
+
+ @Override
+ public AnnotationTypeMetadata getAnnotationTypeMetadata() {
+ return annotationTypeMetadata;
}
+ @Override
+ public boolean isAnnotationType() {
+ return (flags_field & Flags.ANNOTATION) != 0;
+ }
+
+ public void setAnnotationTypeMetadata(AnnotationTypeMetadata a) {
+ Assert.checkNonNull(a);
+ Assert.check(!annotationTypeMetadata.isMetadataForAnnotationType());
+ this.annotationTypeMetadata = a;
+ }
}
@@ -1360,7 +1392,7 @@
/** The names of the parameters */
public List<Name> savedParameterNames;
- /** For an attribute field accessor, its default value if any.
+ /** For an annotation type element, its default value if any.
* The value is null if none appeared in the method
* declaration.
*/
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,7 @@
import javax.lang.model.type.*;
import com.sun.tools.javac.code.Symbol.*;
-import com.sun.tools.javac.code.Types.MapVisitor;
+import com.sun.tools.javac.code.TypeMetadata.Entry;
import com.sun.tools.javac.util.*;
import com.sun.tools.javac.util.DefinedBy.Api;
import static com.sun.tools.javac.code.BoundKind.*;
@@ -87,11 +87,10 @@
return metadata;
}
- public TypeMetadata.Element getMetadataOfKind(final TypeMetadata.Element.Kind kind) {
+ public Entry getMetadataOfKind(final Entry.Kind kind) {
return metadata != null ? metadata.get(kind) : null;
}
-
/** Constant type: no type at all. */
public static final JCNoType noType = new JCNoType() {
@Override @DefinedBy(Api.LANGUAGE_MODEL)
@@ -238,7 +237,12 @@
List<Type> typarams = t.getTypeArguments();
List<Type> typarams1 = visit(typarams, s);
if (outer1 == outer && typarams1 == typarams) return t;
- else return new ClassType(outer1, typarams1, t.tsym, t.metadata);
+ else return new ClassType(outer1, typarams1, t.tsym, t.metadata) {
+ @Override
+ protected boolean needsStripping() {
+ return true;
+ }
+ };
}
@Override
@@ -249,7 +253,12 @@
if (t == wt.type)
return wt;
else
- return new WildcardType(t, wt.kind, wt.tsym, wt.bound, wt.metadata);
+ return new WildcardType(t, wt.kind, wt.tsym, wt.bound, wt.metadata) {
+ @Override
+ protected boolean needsStripping() {
+ return true;
+ }
+ };
}
@Override
@@ -257,7 +266,12 @@
Type elemtype = t.elemtype;
Type elemtype1 = visit(elemtype, s);
if (elemtype1 == elemtype) return t;
- else return new ArrayType(elemtype1, t.tsym, t.metadata);
+ else return new ArrayType(elemtype1, t.tsym, t.metadata) {
+ @Override
+ protected boolean needsStripping() {
+ return true;
+ }
+ };
}
@Override
@@ -271,7 +285,12 @@
if (argtypes1 == argtypes &&
restype1 == restype &&
thrown1 == thrown) return t;
- else return new MethodType(argtypes1, restype1, thrown1, t.tsym);
+ else return new MethodType(argtypes1, restype1, thrown1, t.tsym) {
+ @Override
+ protected boolean needsStripping() {
+ return true;
+ }
+ };
}
@Override
@@ -313,38 +332,78 @@
}
/**
- * Create a new type with exactly the given metadata. The
- * argument is guaranteed to always be non-empty, and should have
- * already been copied/combined with the current type's metadata.
- * This is used internally by other methods.
- *
+ * Returns the original version of this type, before metadata were added. This routine is meant
+ * for internal use only (i.e. {@link Type#equalsIgnoreMetadata(Type)}, {@link Type#stripMetadata});
+ * it should not be used outside this class.
*/
- public abstract Type clone(TypeMetadata md);
+ protected Type typeNoMetadata() {
+ return metadata == TypeMetadata.EMPTY ? this : baseType();
+ }
- public Type combineMetadata(final TypeMetadata.Element md) {
- return clone(metadata.combine(md));
+ /**
+ * Create a new copy of this type but with the specified TypeMetadata.
+ */
+ public abstract Type cloneWithMetadata(TypeMetadata metadata);
+
+ /**
+ * Does this type require annotation stripping for API clients?
+ */
+ protected boolean needsStripping() {
+ return false;
}
+ /**
+ * Strip all metadata associated with this type - this could return a new clone of the type.
+ * This routine is only used to present the correct annotated types back to the users when types
+ * are accessed through compiler APIs; it should not be used anywhere in the compiler internals
+ * as doing so might result in performance penalties.
+ */
+ public Type stripMetadataIfNeeded() {
+ return needsStripping() ?
+ accept(stripMetadata, null) :
+ this;
+ }
+ //where
+ private final static TypeMapping<Void> stripMetadata = new TypeMapping<Void>() {
+ @Override
+ public Type visitClassType(ClassType t, Void aVoid) {
+ return super.visitClassType((ClassType)t.typeNoMetadata(), aVoid);
+ }
+
+ @Override
+ public Type visitArrayType(ArrayType t, Void aVoid) {
+ return super.visitArrayType((ArrayType)t.typeNoMetadata(), aVoid);
+ }
+
+ @Override
+ public Type visitTypeVar(TypeVar t, Void aVoid) {
+ return super.visitTypeVar((TypeVar)t.typeNoMetadata(), aVoid);
+ }
+
+ @Override
+ public Type visitWildcardType(WildcardType wt, Void aVoid) {
+ return super.visitWildcardType((WildcardType)wt.typeNoMetadata(), aVoid);
+ }
+ };
+
public Type annotatedType(final List<Attribute.TypeCompound> annos) {
- final TypeMetadata.Element annoMetadata = new TypeMetadata.Annotations(annos);
- return combineMetadata(annoMetadata);
+ final Entry annoMetadata = new TypeMetadata.Annotations(annos);
+ return cloneWithMetadata(metadata.combine(annoMetadata));
}
public boolean isAnnotated() {
final TypeMetadata.Annotations metadata =
- (TypeMetadata.Annotations)getMetadataOfKind(TypeMetadata.Element.Kind.ANNOTATIONS);
+ (TypeMetadata.Annotations)getMetadataOfKind(Entry.Kind.ANNOTATIONS);
return null != metadata && !metadata.getAnnotations().isEmpty();
}
- private static final List<Attribute.TypeCompound> noAnnotations = List.nil();
-
@Override @DefinedBy(Api.LANGUAGE_MODEL)
public List<Attribute.TypeCompound> getAnnotationMirrors() {
final TypeMetadata.Annotations metadata =
- (TypeMetadata.Annotations)getMetadataOfKind(TypeMetadata.Element.Kind.ANNOTATIONS);
+ (TypeMetadata.Annotations)getMetadataOfKind(Entry.Kind.ANNOTATIONS);
- return metadata == null ? noAnnotations : metadata.getAnnotations();
+ return metadata == null ? List.nil() : metadata.getAnnotations();
}
@@ -431,13 +490,15 @@
}
/**
- * This method is analogous to isSameType, but weaker, since we
- * never complete classes. Where isSameType would complete a
- * class, equals assumes that the two types are different.
+ * Override this method with care. For most Type instances this should behave as ==.
*/
@Override @DefinedBy(Api.LANGUAGE_MODEL)
public boolean equals(Object t) {
- return super.equals(t);
+ return this == t;
+ }
+
+ public boolean equalsIgnoreMetadata(Type t) {
+ return typeNoMetadata().equals(t.typeNoMetadata());
}
@Override @DefinedBy(Api.LANGUAGE_MODEL)
@@ -547,7 +608,7 @@
* Does this type contain occurrences of type t?
*/
public boolean contains(Type t) {
- return t == this;
+ return t.equalsIgnoreMetadata(this);
}
public static boolean contains(List<Type> ts, Type t) {
@@ -615,19 +676,21 @@
TypeTag tag;
public JCPrimitiveType(TypeTag tag, TypeSymbol tsym) {
- this(tag, tsym, TypeMetadata.empty);
+ this(tag, tsym, TypeMetadata.EMPTY);
}
- private JCPrimitiveType(TypeTag tag, TypeSymbol tsym,
- TypeMetadata metadata) {
+ private JCPrimitiveType(TypeTag tag, TypeSymbol tsym, TypeMetadata metadata) {
super(tsym, metadata);
this.tag = tag;
Assert.check(tag.isPrimitive);
}
@Override
- public JCPrimitiveType clone(TypeMetadata md) {
- return new JCPrimitiveType(tag, tsym, md);
+ public JCPrimitiveType cloneWithMetadata(TypeMetadata md) {
+ return new JCPrimitiveType(tag, tsym, md) {
+ @Override
+ public Type baseType() { return JCPrimitiveType.this.baseType(); }
+ };
}
@Override
@@ -740,7 +803,7 @@
}
public WildcardType(Type type, BoundKind kind, TypeSymbol tsym) {
- this(type, kind, tsym, null, TypeMetadata.empty);
+ this(type, kind, tsym, null, TypeMetadata.EMPTY);
}
public WildcardType(Type type, BoundKind kind, TypeSymbol tsym,
@@ -750,7 +813,7 @@
public WildcardType(Type type, BoundKind kind, TypeSymbol tsym,
TypeVar bound) {
- this(type, kind, tsym, bound, TypeMetadata.empty);
+ this(type, kind, tsym, bound, TypeMetadata.EMPTY);
}
public WildcardType(Type type, BoundKind kind, TypeSymbol tsym,
@@ -762,8 +825,11 @@
}
@Override
- public WildcardType clone(TypeMetadata md) {
- return new WildcardType(type, kind, tsym, bound, md);
+ public WildcardType cloneWithMetadata(TypeMetadata md) {
+ return new WildcardType(type, kind, tsym, bound, md) {
+ @Override
+ public Type baseType() { return WildcardType.this.baseType(); }
+ };
}
@Override
@@ -883,7 +949,7 @@
public List<Type> all_interfaces_field;
public ClassType(Type outer, List<Type> typarams, TypeSymbol tsym) {
- this(outer, typarams, tsym, TypeMetadata.empty);
+ this(outer, typarams, tsym, TypeMetadata.EMPTY);
}
public ClassType(Type outer, List<Type> typarams, TypeSymbol tsym,
@@ -897,13 +963,11 @@
}
@Override
- public ClassType clone(TypeMetadata md) {
- final ClassType out =
- new ClassType(outer_field, typarams_field, tsym, md);
- out.allparams_field = allparams_field;
- out.supertype_field = supertype_field;
- out.interfaces_field = interfaces_field;
- return out;
+ public ClassType cloneWithMetadata(TypeMetadata md) {
+ return new ClassType(outer_field, typarams_field, tsym, md) {
+ @Override
+ public Type baseType() { return ClassType.this.baseType(); }
+ };
}
@Override
@@ -935,14 +999,16 @@
@DefinedBy(Api.LANGUAGE_MODEL)
public String toString() {
StringBuilder buf = new StringBuilder();
- appendAnnotationsString(buf);
if (getEnclosingType().hasTag(CLASS) && tsym.owner.kind == TYP) {
buf.append(getEnclosingType().toString());
buf.append(".");
+ appendAnnotationsString(buf);
buf.append(className(tsym, false));
} else {
+ appendAnnotationsString(buf);
buf.append(className(tsym, true));
}
+
if (getTypeArguments().nonEmpty()) {
buf.append('<');
buf.append(getTypeArguments().toString());
@@ -1050,7 +1116,7 @@
public boolean contains(Type elem) {
return
- elem == this
+ elem.equalsIgnoreMetadata(this)
|| (isParameterized()
&& (getEnclosingType().contains(elem) || contains(getTypeArguments(), elem)))
|| (isCompound()
@@ -1073,10 +1139,6 @@
}
public static class ErasedClassType extends ClassType {
- public ErasedClassType(Type outer, TypeSymbol tsym) {
- super(outer, List.<Type>nil(), tsym);
- }
-
public ErasedClassType(Type outer, TypeSymbol tsym,
TypeMetadata metadata) {
super(outer, List.<Type>nil(), tsym, metadata);
@@ -1104,7 +1166,7 @@
}
@Override
- public UnionClassType clone(TypeMetadata md) {
+ public UnionClassType cloneWithMetadata(TypeMetadata md) {
throw new AssertionError("Cannot add metadata to a union type");
}
@@ -1155,7 +1217,7 @@
}
@Override
- public IntersectionClassType clone(TypeMetadata md) {
+ public IntersectionClassType cloneWithMetadata(TypeMetadata md) {
throw new AssertionError("Cannot add metadata to an intersection type");
}
@@ -1196,7 +1258,7 @@
public Type elemtype;
public ArrayType(Type elemtype, TypeSymbol arrayClass) {
- this(elemtype, arrayClass, TypeMetadata.empty);
+ this(elemtype, arrayClass, TypeMetadata.EMPTY);
}
public ArrayType(Type elemtype, TypeSymbol arrayClass,
@@ -1205,9 +1267,18 @@
this.elemtype = elemtype;
}
+ public ArrayType(ArrayType that) {
+ //note: type metadata is deliberately shared here, as we want side-effects from annotation
+ //processing to flow from original array to the cloned array.
+ this(that.elemtype, that.tsym, that.getMetadata());
+ }
+
@Override
- public ArrayType clone(TypeMetadata md) {
- return new ArrayType(elemtype, tsym, md);
+ public ArrayType cloneWithMetadata(TypeMetadata md) {
+ return new ArrayType(elemtype, tsym, md) {
+ @Override
+ public Type baseType() { return ArrayType.this.baseType(); }
+ };
}
@Override
@@ -1228,12 +1299,15 @@
return sb.toString();
}
- @DefinedBy(Api.LANGUAGE_MODEL)
+ @Override @DefinedBy(Api.LANGUAGE_MODEL)
public boolean equals(Object obj) {
- return
- this == obj ||
- (obj instanceof ArrayType &&
- this.elemtype.equals(((ArrayType)obj).elemtype));
+ if (obj instanceof ArrayType) {
+ ArrayType that = (ArrayType)obj;
+ return this == that ||
+ elemtype.equals(that.elemtype);
+ }
+
+ return false;
}
@DefinedBy(Api.LANGUAGE_MODEL)
@@ -1279,7 +1353,7 @@
}
public boolean contains(Type elem) {
- return elem == this || elemtype.contains(elem);
+ return elem.equalsIgnoreMetadata(this) || elemtype.contains(elem);
}
public void complete() {
@@ -1318,14 +1392,14 @@
TypeSymbol methodClass) {
// Presently no way to refer to a method type directly, so
// we cannot put type annotations on it.
- super(methodClass, TypeMetadata.empty);
+ super(methodClass, TypeMetadata.EMPTY);
this.argtypes = argtypes;
this.restype = restype;
this.thrown = thrown;
}
@Override
- public MethodType clone(TypeMetadata md) {
+ public MethodType cloneWithMetadata(TypeMetadata md) {
throw new AssertionError("Cannot add metadata to a method type");
}
@@ -1370,7 +1444,7 @@
}
public boolean contains(Type elem) {
- return elem == this || contains(argtypes, elem) || restype.contains(elem) || contains(thrown, elem);
+ return elem.equalsIgnoreMetadata(this) || contains(argtypes, elem) || restype.contains(elem) || contains(thrown, elem);
}
public MethodType asMethodType() { return this; }
@@ -1408,11 +1482,11 @@
PackageType(TypeSymbol tsym) {
// Package types cannot be annotated
- super(tsym, TypeMetadata.empty);
+ super(tsym, TypeMetadata.EMPTY);
}
@Override
- public PackageType clone(TypeMetadata md) {
+ public PackageType cloneWithMetadata(TypeMetadata md) {
throw new AssertionError("Cannot add metadata to a package type");
}
@@ -1464,14 +1538,14 @@
public Type lower;
public TypeVar(Name name, Symbol owner, Type lower) {
- super(null, TypeMetadata.empty);
+ super(null, TypeMetadata.EMPTY);
tsym = new TypeVariableSymbol(0, name, this, owner);
- this.bound = bound;
+ this.bound = null;
this.lower = lower;
}
public TypeVar(TypeSymbol tsym, Type bound, Type lower) {
- this(tsym, bound, lower, TypeMetadata.empty);
+ this(tsym, bound, lower, TypeMetadata.EMPTY);
}
public TypeVar(TypeSymbol tsym, Type bound, Type lower,
@@ -1482,8 +1556,11 @@
}
@Override
- public TypeVar clone(TypeMetadata md) {
- return new TypeVar(tsym, bound, lower, md);
+ public TypeVar cloneWithMetadata(TypeMetadata md) {
+ return new TypeVar(tsym, bound, lower, md) {
+ @Override
+ public Type baseType() { return TypeVar.this.baseType(); }
+ };
}
@Override
@@ -1566,8 +1643,11 @@
}
@Override
- public CapturedType clone(TypeMetadata md) {
- return new CapturedType(tsym, bound, bound, lower, wildcard, md);
+ public CapturedType cloneWithMetadata(TypeMetadata md) {
+ return new CapturedType(tsym, bound, bound, lower, wildcard, md) {
+ @Override
+ public Type baseType() { return CapturedType.this.baseType(); }
+ };
}
@Override
@@ -1597,7 +1677,7 @@
public TypeTag tag;
public DelegatedType(TypeTag tag, Type qtype) {
- this(tag, qtype, TypeMetadata.empty);
+ this(tag, qtype, TypeMetadata.EMPTY);
}
public DelegatedType(TypeTag tag, Type qtype,
@@ -1635,7 +1715,7 @@
}
@Override
- public ForAll clone(TypeMetadata md) {
+ public ForAll cloneWithMetadata(TypeMetadata md) {
throw new AssertionError("Cannot add metadata to a forall type");
}
@@ -1785,7 +1865,7 @@
}
@Override
- public UndetVar clone(TypeMetadata md) {
+ public UndetVar cloneWithMetadata(TypeMetadata md) {
throw new AssertionError("Cannot add metadata to an UndetVar type");
}
@@ -1940,11 +2020,11 @@
// Need to use List.nil(), because JCNoType constructor
// gets called in static initializers in Type, where
// noAnnotations is also defined.
- super(null, TypeMetadata.empty);
+ super(null, TypeMetadata.EMPTY);
}
@Override
- public JCNoType clone(TypeMetadata md) {
+ public JCNoType cloneWithMetadata(TypeMetadata md) {
throw new AssertionError("Cannot add metadata to a JCNoType");
}
@@ -1973,11 +2053,11 @@
public JCVoidType() {
// Void cannot be annotated
- super(null, TypeMetadata.empty);
+ super(null, TypeMetadata.EMPTY);
}
@Override
- public JCVoidType clone(TypeMetadata md) {
+ public JCVoidType cloneWithMetadata(TypeMetadata md) {
throw new AssertionError("Cannot add metadata to a void type");
}
@@ -2008,11 +2088,11 @@
static class BottomType extends Type implements NullType {
public BottomType() {
// Bottom is a synthesized internal type, so it cannot be annotated
- super(null, TypeMetadata.empty);
+ super(null, TypeMetadata.EMPTY);
}
@Override
- public BottomType clone(TypeMetadata md) {
+ public BottomType cloneWithMetadata(TypeMetadata md) {
throw new AssertionError("Cannot add metadata to a bottom type");
}
@@ -2077,8 +2157,11 @@
}
@Override
- public ErrorType clone(TypeMetadata md) {
- return new ErrorType(originalType, tsym, md);
+ public ErrorType cloneWithMetadata(TypeMetadata md) {
+ return new ErrorType(originalType, tsym, md) {
+ @Override
+ public Type baseType() { return ErrorType.this.baseType(); }
+ };
}
@Override
@@ -2145,11 +2228,11 @@
public UnknownType() {
// Unknown is a synthesized internal type, so it cannot be
// annotated.
- super(null, TypeMetadata.empty);
+ super(null, TypeMetadata.EMPTY);
}
@Override
- public UnknownType clone(TypeMetadata md) {
+ public UnknownType cloneWithMetadata(TypeMetadata md) {
throw new AssertionError("Cannot add metadata to an unknown type");
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -118,14 +118,10 @@
public static final List<TypePathEntry> emptyPath = List.nil();
- // NOTE: All of these will be converted to final fields eventually.
-
public final TargetType type;
// For generic/array types.
- // This field is in the process of being made final. Do not
- // introduce new mutations.
public List<TypePathEntry> location;
// Tree position.
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@
import javax.tools.JavaFileObject;
+import com.sun.tools.javac.code.Attribute.Array;
import com.sun.tools.javac.code.Attribute.TypeCompound;
import com.sun.tools.javac.code.Type.ArrayType;
import com.sun.tools.javac.code.Type.CapturedType;
@@ -47,8 +48,8 @@
import com.sun.tools.javac.code.TypeAnnotationPosition.TypePathEntryKind;
import com.sun.tools.javac.code.Symbol.VarSymbol;
import com.sun.tools.javac.code.Symbol.MethodSymbol;
+import com.sun.tools.javac.code.TypeMetadata.Entry.Kind;
import com.sun.tools.javac.comp.Annotate;
-import com.sun.tools.javac.comp.Annotate.Worker;
import com.sun.tools.javac.comp.Attr;
import com.sun.tools.javac.comp.AttrContext;
import com.sun.tools.javac.comp.Env;
@@ -71,7 +72,6 @@
import com.sun.tools.javac.util.ListBuffer;
import com.sun.tools.javac.util.Log;
import com.sun.tools.javac.util.Names;
-import com.sun.tools.javac.util.Options;
import static com.sun.tools.javac.code.Kinds.Kind.*;
@@ -105,7 +105,6 @@
syms = Symtab.instance(context);
annotate = Annotate.instance(context);
attr = Attr.instance(context);
- Options options = Options.instance(context);
}
/**
@@ -113,12 +112,9 @@
* determine the correct positions for type annotations.
* This version only visits types in signatures and should be
* called from MemberEnter.
- * The method takes the Annotate object as parameter and
- * adds an Annotate.Worker to the correct Annotate queue for
- * later processing.
*/
public void organizeTypeAnnotationsSignatures(final Env<AttrContext> env, final JCClassDecl tree) {
- annotate.afterRepeated( new Worker() {
+ annotate.afterTypes(new Runnable() {
@Override
public void run() {
JavaFileObject oldSource = log.useSource(env.toplevel.sourcefile);
@@ -129,11 +125,11 @@
log.useSource(oldSource);
}
}
- } );
+ });
}
public void validateTypeAnnotationsSignatures(final Env<AttrContext> env, final JCClassDecl tree) {
- annotate.validate(new Worker() { //validate annotations
+ annotate.validate(new Runnable() { //validate annotations
@Override
public void run() {
JavaFileObject oldSource = log.useSource(env.toplevel.sourcefile);
@@ -144,7 +140,7 @@
log.useSource(oldSource);
}
}
- } );
+ });
}
/**
@@ -155,101 +151,106 @@
new TypeAnnotationPositions(false).scan(tree);
}
- public enum AnnotationType { DECLARATION, TYPE, BOTH }
+ public enum AnnotationType { DECLARATION, TYPE, NONE, BOTH }
+
+ public List<Attribute> annotationTargets(Attribute.Compound anno) {
+ Attribute.Compound atTarget = anno.type.tsym.getAnnotationTypeMetadata().getTarget();
+ if (atTarget == null) {
+ return null;
+ }
+
+ Attribute atValue = atTarget.member(names.value);
+ if (!(atValue instanceof Attribute.Array)) {
+ return null;
+ }
+
+ List<Attribute> targets = ((Array)atValue).getValue();
+ if (targets.stream().anyMatch(a -> !(a instanceof Attribute.Enum))) {
+ return null;
+ }
+
+ return targets;
+ }
/**
* Determine whether an annotation is a declaration annotation,
* a type annotation, or both.
*/
- public AnnotationType annotationType(Attribute.Compound a, Symbol s) {
- Attribute.Compound atTarget =
- a.type.tsym.attribute(syms.annotationTargetType.tsym);
- if (atTarget == null) {
- return inferTargetMetaInfo(a, s);
- }
- Attribute atValue = atTarget.member(names.value);
- if (!(atValue instanceof Attribute.Array)) {
- Assert.error("annotationType(): bad @Target argument " + atValue +
- " (" + atValue.getClass() + ")");
- return AnnotationType.DECLARATION; // error recovery
- }
- Attribute.Array arr = (Attribute.Array) atValue;
- boolean isDecl = false, isType = false;
- for (Attribute app : arr.values) {
- if (!(app instanceof Attribute.Enum)) {
- Assert.error("annotationType(): unrecognized Attribute kind " + app +
- " (" + app.getClass() + ")");
- isDecl = true;
- continue;
- }
- Attribute.Enum e = (Attribute.Enum) app;
- if (e.value.name == names.TYPE) {
- if (s.kind == TYP)
- isDecl = true;
- } else if (e.value.name == names.FIELD) {
- if (s.kind == VAR &&
- s.owner.kind != MTH)
- isDecl = true;
- } else if (e.value.name == names.METHOD) {
- if (s.kind == MTH &&
- !s.isConstructor())
- isDecl = true;
- } else if (e.value.name == names.PARAMETER) {
- if (s.kind == VAR &&
- s.owner.kind == MTH &&
- (s.flags() & Flags.PARAMETER) != 0)
- isDecl = true;
- } else if (e.value.name == names.CONSTRUCTOR) {
- if (s.kind == MTH &&
- s.isConstructor())
- isDecl = true;
- } else if (e.value.name == names.LOCAL_VARIABLE) {
- if (s.kind == VAR &&
- s.owner.kind == MTH &&
- (s.flags() & Flags.PARAMETER) == 0)
- isDecl = true;
- } else if (e.value.name == names.ANNOTATION_TYPE) {
- if (s.kind == TYP &&
- (s.flags() & Flags.ANNOTATION) != 0)
- isDecl = true;
- } else if (e.value.name == names.PACKAGE) {
- if (s.kind == PCK)
- isDecl = true;
- } else if (e.value.name == names.TYPE_USE) {
- if (s.kind == TYP ||
- s.kind == VAR ||
- (s.kind == MTH && !s.isConstructor() &&
- !s.type.getReturnType().hasTag(TypeTag.VOID)) ||
- (s.kind == MTH && s.isConstructor()))
- isType = true;
- } else if (e.value.name == names.TYPE_PARAMETER) {
- /* Irrelevant in this case */
- // TYPE_PARAMETER doesn't aid in distinguishing between
- // Type annotations and declaration annotations on an
- // Element
- } else {
- Assert.error("annotationType(): unrecognized Attribute name " + e.value.name +
- " (" + e.value.name.getClass() + ")");
- isDecl = true;
- }
- }
- if (isDecl && isType) {
+ public AnnotationType annotationTargetType(Attribute.Compound a, Symbol s) {
+ List<Attribute> targets = annotationTargets(a);
+ return (targets == null) ?
+ AnnotationType.DECLARATION :
+ targets.stream()
+ .map(attr -> targetToAnnotationType(attr, s))
+ .reduce(AnnotationType.NONE, this::combineAnnotationType);
+ }
+
+ private AnnotationType combineAnnotationType(AnnotationType at1, AnnotationType at2) {
+ if (at1 == AnnotationType.NONE) {
+ return at2;
+ } else if (at2 == AnnotationType.NONE) {
+ return at1;
+ } else if (at1 != at2) {
return AnnotationType.BOTH;
- } else if (isType) {
- return AnnotationType.TYPE;
} else {
- return AnnotationType.DECLARATION;
+ return at1;
}
}
- /** Infer the target annotation kind, if none is give.
- * We only infer declaration annotations.
- */
- private static AnnotationType inferTargetMetaInfo(Attribute.Compound a, Symbol s) {
- return AnnotationType.DECLARATION;
+ private AnnotationType targetToAnnotationType(Attribute a, Symbol s) {
+ Attribute.Enum e = (Attribute.Enum)a;
+ if (e.value.name == names.TYPE) {
+ if (s.kind == TYP)
+ return AnnotationType.DECLARATION;
+ } else if (e.value.name == names.FIELD) {
+ if (s.kind == VAR &&
+ s.owner.kind != MTH)
+ return AnnotationType.DECLARATION;
+ } else if (e.value.name == names.METHOD) {
+ if (s.kind == MTH &&
+ !s.isConstructor())
+ return AnnotationType.DECLARATION;
+ } else if (e.value.name == names.PARAMETER) {
+ if (s.kind == VAR &&
+ s.owner.kind == MTH &&
+ (s.flags() & Flags.PARAMETER) != 0)
+ return AnnotationType.DECLARATION;
+ } else if (e.value.name == names.CONSTRUCTOR) {
+ if (s.kind == MTH &&
+ s.isConstructor())
+ return AnnotationType.DECLARATION;
+ } else if (e.value.name == names.LOCAL_VARIABLE) {
+ if (s.kind == VAR &&
+ s.owner.kind == MTH &&
+ (s.flags() & Flags.PARAMETER) == 0)
+ return AnnotationType.DECLARATION;
+ } else if (e.value.name == names.ANNOTATION_TYPE) {
+ if (s.kind == TYP &&
+ (s.flags() & Flags.ANNOTATION) != 0)
+ return AnnotationType.DECLARATION;
+ } else if (e.value.name == names.PACKAGE) {
+ if (s.kind == PCK)
+ return AnnotationType.DECLARATION;
+ } else if (e.value.name == names.TYPE_USE) {
+ if (s.kind == TYP ||
+ s.kind == VAR ||
+ (s.kind == MTH && !s.isConstructor() &&
+ !s.type.getReturnType().hasTag(TypeTag.VOID)) ||
+ (s.kind == MTH && s.isConstructor()))
+ return AnnotationType.TYPE;
+ } else if (e.value.name == names.TYPE_PARAMETER) {
+ /* Irrelevant in this case */
+ // TYPE_PARAMETER doesn't aid in distinguishing between
+ // Type annotations and declaration annotations on an
+ // Element
+ } else {
+ Assert.error("annotationTargetType(): unrecognized Attribute name " + e.value.name +
+ " (" + e.value.name.getClass() + ")");
+ return AnnotationType.DECLARATION;
+ }
+ return AnnotationType.NONE;
}
-
private class TypeAnnotationPositions extends TreeScanner {
private final boolean sigOnly;
@@ -262,18 +263,29 @@
* When traversing the AST we keep the "frames" of visited
* trees in order to determine the position of annotations.
*/
- private ListBuffer<JCTree> frames = new ListBuffer<>();
+ private List<JCTree> frames = List.nil();
- protected void push(JCTree t) { frames = frames.prepend(t); }
- protected JCTree pop() { return frames.next(); }
+ protected void push(JCTree t) {
+ frames = frames.prepend(t);
+ }
+ protected JCTree pop() {
+ JCTree t = frames.head;
+ frames = frames.tail;
+ return t;
+ }
// could this be frames.elems.tail.head?
- private JCTree peek2() { return frames.toList().tail.head; }
+ private JCTree peek2() {
+ return frames.tail.head;
+ }
@Override
public void scan(JCTree tree) {
push(tree);
- super.scan(tree);
- pop();
+ try {
+ super.scan(tree);
+ } finally {
+ pop();
+ }
}
/**
@@ -283,41 +295,44 @@
* we never build an JCAnnotatedType. This step finds these
* annotations and marks them as if they were part of the type.
*/
- private void separateAnnotationsKinds(JCTree typetree, Type type, Symbol sym,
- TypeAnnotationPosition pos) {
- List<Attribute.Compound> annotations = sym.getRawAttributes();
+ private void separateAnnotationsKinds(JCTree typetree, Type type,
+ Symbol sym, TypeAnnotationPosition pos)
+ {
+ List<Attribute.Compound> allAnnotations = sym.getRawAttributes();
ListBuffer<Attribute.Compound> declAnnos = new ListBuffer<>();
ListBuffer<Attribute.TypeCompound> typeAnnos = new ListBuffer<>();
ListBuffer<Attribute.TypeCompound> onlyTypeAnnos = new ListBuffer<>();
- for (Attribute.Compound a : annotations) {
- switch (annotationType(a, sym)) {
- case DECLARATION:
- declAnnos.append(a);
- break;
- case BOTH: {
- declAnnos.append(a);
- Attribute.TypeCompound ta = toTypeCompound(a, pos);
- typeAnnos.append(ta);
- break;
- }
- case TYPE: {
- Attribute.TypeCompound ta = toTypeCompound(a, pos);
- typeAnnos.append(ta);
- // Also keep track which annotations are only type annotations
- onlyTypeAnnos.append(ta);
- break;
- }
+ for (Attribute.Compound a : allAnnotations) {
+ switch (annotationTargetType(a, sym)) {
+ case DECLARATION:
+ declAnnos.append(a);
+ break;
+ case BOTH: {
+ declAnnos.append(a);
+ Attribute.TypeCompound ta = toTypeCompound(a, pos);
+ typeAnnos.append(ta);
+ break;
+ }
+ case TYPE: {
+ Attribute.TypeCompound ta = toTypeCompound(a, pos);
+ typeAnnos.append(ta);
+ // Also keep track which annotations are only type annotations
+ onlyTypeAnnos.append(ta);
+ break;
+ }
}
}
- sym.resetAnnotations();
- sym.setDeclarationAttributes(declAnnos.toList());
-
+ // If we have no type annotations we are done for this Symbol
if (typeAnnos.isEmpty()) {
return;
}
+ // Reset decl annotations to the set {all - type only}
+ sym.resetAnnotations();
+ sym.setDeclarationAttributes(declAnnos.toList());
+
List<Attribute.TypeCompound> typeAnnotations = typeAnnos.toList();
if (type == null) {
@@ -328,7 +343,7 @@
// Declaration annotations are always allowed on constructor returns.
// Therefore, use typeAnnotations instead of onlyTypeAnnos.
- type = typeWithAnnotations(typetree, type, typeAnnotations, typeAnnotations);
+ typeWithAnnotations(typetree, type, typeAnnotations, typeAnnotations, pos);
// Note that we don't use the result, the call to
// typeWithAnnotations side-effects the type annotation positions.
// This is important for constructors of nested classes.
@@ -336,8 +351,8 @@
return;
}
- // type is non-null and annotations are added to that type
- type = typeWithAnnotations(typetree, type, typeAnnotations, onlyTypeAnnos.toList());
+ // type is non-null, add type annotations from declaration context to the type
+ type = typeWithAnnotations(typetree, type, typeAnnotations, onlyTypeAnnos.toList(), pos);
if (sym.getKind() == ElementKind.METHOD) {
sym.type.asMethodType().restype = type;
@@ -390,59 +405,23 @@
// Note that it is assumed that all annotations share the same position.
private Type typeWithAnnotations(final JCTree typetree, final Type type,
final List<Attribute.TypeCompound> annotations,
- final List<Attribute.TypeCompound> onlyTypeAnnotations) {
- //System.err.printf("typeWithAnnotations(typetree: %s, type: %s, annotations: %s, onlyTypeAnnotations: %s)%n",
- // typetree, type, annotations, onlyTypeAnnotations);
+ final List<Attribute.TypeCompound> onlyTypeAnnotations,
+ final TypeAnnotationPosition pos)
+ {
if (annotations.isEmpty()) {
return type;
}
- if (type.hasTag(TypeTag.ARRAY)) {
- Type.ArrayType arType = (Type.ArrayType) type;
- Type.ArrayType tomodify = new Type.ArrayType(null, arType.tsym);
- Type toreturn;
- if (type.isAnnotated()) {
- toreturn = tomodify.annotatedType(type.getAnnotationMirrors());
- } else {
- toreturn = tomodify;
- }
-
- JCArrayTypeTree arTree = arrayTypeTree(typetree);
- ListBuffer<TypePathEntry> depth = new ListBuffer<>();
- depth = depth.append(TypePathEntry.ARRAY);
- while (arType.elemtype.hasTag(TypeTag.ARRAY)) {
- if (arType.elemtype.isAnnotated()) {
- Type aelemtype = arType.elemtype;
- arType = (Type.ArrayType) aelemtype;
- ArrayType prevToMod = tomodify;
- tomodify = new Type.ArrayType(null, arType.tsym);
- prevToMod.elemtype = tomodify.annotatedType(arType.elemtype.getAnnotationMirrors());
- } else {
- arType = (Type.ArrayType) arType.elemtype;
- tomodify.elemtype = new Type.ArrayType(null, arType.tsym);
- tomodify = (Type.ArrayType) tomodify.elemtype;
- }
- arTree = arrayTypeTree(arTree.elemtype);
- depth = depth.append(TypePathEntry.ARRAY);
- }
- Type arelemType = typeWithAnnotations(arTree.elemtype, arType.elemtype, annotations, onlyTypeAnnotations);
- tomodify.elemtype = arelemType;
- {
- // All annotations share the same position; modify the first one.
- Attribute.TypeCompound a = annotations.get(0);
- TypeAnnotationPosition p = a.position;
- p.location = p.location.prependList(depth.toList());
- }
- typetree.type = toreturn;
- return toreturn;
- } else if (type.hasTag(TypeTag.TYPEVAR)) {
- // Nothing to do for type variables.
- return type;
+ if (type.hasTag(TypeTag.ARRAY))
+ return rewriteArrayType((ArrayType)type, annotations, pos);
+
+ if (type.hasTag(TypeTag.TYPEVAR)) {
+ return type.annotatedType(onlyTypeAnnotations);
} else if (type.getKind() == TypeKind.UNION) {
// There is a TypeKind, but no TypeTag.
- JCTypeUnion tutree = (JCTypeUnion) typetree;
+ JCTypeUnion tutree = (JCTypeUnion)typetree;
JCExpression fst = tutree.alternatives.get(0);
- Type res = typeWithAnnotations(fst, fst.type, annotations, onlyTypeAnnotations);
+ Type res = typeWithAnnotations(fst, fst.type, annotations, onlyTypeAnnotations, pos);
fst.type = res;
// TODO: do we want to set res as first element in uct.alternatives?
// UnionClassType uct = (com.sun.tools.javac.code.Type.UnionClassType)type;
@@ -459,8 +438,8 @@
enclTy.getKind() != TypeKind.NONE &&
enclTy.getKind() != TypeKind.ERROR &&
(enclTr.getKind() == JCTree.Kind.MEMBER_SELECT ||
- enclTr.getKind() == JCTree.Kind.PARAMETERIZED_TYPE ||
- enclTr.getKind() == JCTree.Kind.ANNOTATED_TYPE)) {
+ enclTr.getKind() == JCTree.Kind.PARAMETERIZED_TYPE ||
+ enclTr.getKind() == JCTree.Kind.ANNOTATED_TYPE)) {
// Iterate also over the type tree, not just the type: the type is already
// completely resolved and we cannot distinguish where the annotation
// belongs for a nested type.
@@ -483,20 +462,20 @@
if (enclTy != null &&
enclTy.hasTag(TypeTag.NONE)) {
switch (onlyTypeAnnotations.size()) {
- case 0:
- // Don't issue an error if all type annotations are
- // also declaration annotations.
- // If the annotations are also declaration annotations, they are
- // illegal as type annotations but might be legal as declaration annotations.
- // The normal declaration annotation checks make sure that the use is valid.
- break;
- case 1:
- log.error(typetree.pos(), "cant.type.annotate.scoping.1",
- onlyTypeAnnotations);
- break;
- default:
- log.error(typetree.pos(), "cant.type.annotate.scoping",
- onlyTypeAnnotations);
+ case 0:
+ // Don't issue an error if all type annotations are
+ // also declaration annotations.
+ // If the annotations are also declaration annotations, they are
+ // illegal as type annotations but might be legal as declaration annotations.
+ // The normal declaration annotation checks make sure that the use is valid.
+ break;
+ case 1:
+ log.error(typetree.pos(), "cant.type.annotate.scoping.1",
+ onlyTypeAnnotations);
+ break;
+ default:
+ log.error(typetree.pos(), "cant.type.annotate.scoping",
+ onlyTypeAnnotations);
}
return type;
}
@@ -539,15 +518,62 @@
}
}
- private JCArrayTypeTree arrayTypeTree(JCTree typetree) {
- if (typetree.getKind() == JCTree.Kind.ARRAY_TYPE) {
- return (JCArrayTypeTree) typetree;
- } else if (typetree.getKind() == JCTree.Kind.ANNOTATED_TYPE) {
- return (JCArrayTypeTree) ((JCAnnotatedType)typetree).underlyingType;
+ /**
+ * Create a copy of the {@code Type type} with the help of the Tree for a type
+ * {@code JCTree typetree} inserting all type annotations in {@code annotations} to the
+ * innermost array component type.
+ *
+ * SIDE EFFECT: Update position for the annotations to be {@code pos}.
+ */
+ private Type rewriteArrayType(ArrayType type, List<TypeCompound> annotations, TypeAnnotationPosition pos) {
+ ArrayType tomodify = new ArrayType(type);
+ ArrayType res = tomodify;
+
+ List<TypePathEntry> loc = List.nil();
+
+ // peel one and update loc
+ Type tmpType = type.elemtype;
+ loc = loc.prepend(TypePathEntry.ARRAY);
+
+ while (tmpType.hasTag(TypeTag.ARRAY)) {
+ ArrayType arr = (ArrayType)tmpType;
+
+ // Update last type with new element type
+ ArrayType tmp = new ArrayType(arr);
+ tomodify.elemtype = tmp;
+ tomodify = tmp;
+
+ tmpType = arr.elemtype;
+ loc = loc.prepend(TypePathEntry.ARRAY);
+ }
+
+ // Fix innermost element type
+ Type elemType;
+ if (tmpType.getMetadata() != null) {
+ List<TypeCompound> tcs;
+ if (tmpType.getAnnotationMirrors().isEmpty()) {
+ tcs = annotations;
+ } else {
+ // Special case, lets prepend
+ tcs = annotations.appendList(tmpType.getAnnotationMirrors());
+ }
+ elemType = tmpType.cloneWithMetadata(tmpType
+ .getMetadata()
+ .without(Kind.ANNOTATIONS)
+ .combine(new TypeMetadata.Annotations(tcs)));
} else {
- Assert.error("Could not determine array type from type tree: " + typetree);
- return null;
+ elemType = tmpType.cloneWithMetadata(new TypeMetadata(new TypeMetadata.Annotations(annotations)));
}
+ tomodify.elemtype = elemType;
+
+ // Update positions
+ for (TypeCompound tc : annotations) {
+ if (tc.position == null)
+ tc.position = pos;
+ tc.position.location = loc;
+ }
+
+ return res;
}
/** Return a copy of the first type that only differs by
@@ -569,7 +595,6 @@
private Type typeWithAnnotations(final Type type,
final Type stopAt,
final List<Attribute.TypeCompound> annotations) {
- //System.err.println("typeWithAnnotations " + type + " " + annotations + " stopAt " + stopAt);
Visitor<Type, List<TypeCompound>> visitor =
new Type.Visitor<Type, List<Attribute.TypeCompound>>() {
@Override
@@ -660,20 +685,14 @@
/* This is the beginning of the second part of organizing
* type annotations: determine the type annotation positions.
*/
-
- // This method is considered deprecated, and will be removed
- // in the near future. Don't use it for anything new.
private TypeAnnotationPosition
resolveFrame(JCTree tree,
JCTree frame,
List<JCTree> path,
JCLambda currentLambda,
int outer_type_index,
- ListBuffer<TypePathEntry> location) {
- /*
- System.out.println("Resolving tree: " + tree + " kind: " + tree.getKind());
- System.out.println(" Framing tree: " + frame + " kind: " + frame.getKind());
- */
+ ListBuffer<TypePathEntry> location)
+ {
// Note that p.offset is set in
// com.sun.tools.javac.jvm.Gen.setTypeAnnotationPositions(int)
@@ -695,20 +714,17 @@
if (frameNewClass.def != null) {
// Special handling for anonymous class instantiations
final JCClassDecl frameClassDecl = frameNewClass.def;
- if (frameClassDecl.extending == tree) {
- return TypeAnnotationPosition
- .classExtends(location.toList(), currentLambda,
- frame.pos);
- } else if (frameClassDecl.implementing.contains(tree)) {
+ if (frameClassDecl.implementing.contains(tree)) {
final int type_index =
frameClassDecl.implementing.indexOf(tree);
return TypeAnnotationPosition
.classExtends(location.toList(), currentLambda,
type_index, frame.pos);
} else {
- // In contrast to CLASS below, typarams cannot occur here.
- throw new AssertionError("Could not determine position of tree " + tree +
- " within frame " + frame);
+ //for encl.new @TA Clazz(), tree may be different from frameClassDecl.extending
+ return TypeAnnotationPosition
+ .classExtends(location.toList(), currentLambda,
+ frame.pos);
}
} else if (frameNewClass.typeargs.contains(tree)) {
final int type_index =
@@ -1120,29 +1136,31 @@
// Nothing to do for separateAnnotationsKinds if
// there are no annotations of either kind.
// TODO: make sure there are no declaration annotations.
- final TypeAnnotationPosition pos =
- TypeAnnotationPosition.methodReceiver(tree.recvparam.vartype.pos);
- separateAnnotationsKinds(tree.recvparam.vartype,
- tree.recvparam.sym.type,
- tree.recvparam.sym, pos);
+ final TypeAnnotationPosition pos = TypeAnnotationPosition.methodReceiver(tree.recvparam.vartype.pos);
+ push(tree.recvparam);
+ try {
+ separateAnnotationsKinds(tree.recvparam.vartype, tree.recvparam.sym.type, tree.recvparam.sym, pos);
+ } finally {
+ pop();
+ }
}
int i = 0;
for (JCVariableDecl param : tree.params) {
if (!param.mods.annotations.isEmpty()) {
// Nothing to do for separateAnnotationsKinds if
// there are no annotations of either kind.
- final TypeAnnotationPosition pos =
- TypeAnnotationPosition.methodParameter(i, param.vartype.pos);
- separateAnnotationsKinds(param.vartype,
- param.sym.type,
- param.sym, pos);
+ final TypeAnnotationPosition pos = TypeAnnotationPosition.methodParameter(i, param.vartype.pos);
+ push(param);
+ try {
+ separateAnnotationsKinds(param.vartype, param.sym.type, param.sym, pos);
+ } finally {
+ pop();
+ }
}
++i;
}
}
- push(tree);
- // super.visitMethodDef(tree);
if (sigOnly) {
scan(tree.mods);
scan(tree.restype);
@@ -1154,7 +1172,6 @@
scan(tree.defaultValue);
scan(tree.body);
}
- pop();
}
/* Store a reference to the current lambda expression, to
@@ -1172,18 +1189,20 @@
if (!param.mods.annotations.isEmpty()) {
// Nothing to do for separateAnnotationsKinds if
// there are no annotations of either kind.
- final TypeAnnotationPosition pos =
- TypeAnnotationPosition.methodParameter(tree, i,
- param.vartype.pos);
- separateAnnotationsKinds(param.vartype, param.sym.type, param.sym, pos);
+ final TypeAnnotationPosition pos = TypeAnnotationPosition
+ .methodParameter(tree, i, param.vartype.pos);
+ push(param);
+ try {
+ separateAnnotationsKinds(param.vartype, param.sym.type, param.sym, pos);
+ } finally {
+ pop();
+ }
}
++i;
}
- push(tree);
scan(tree.body);
scan(tree.params);
- pop();
} finally {
currentLambda = prevLambda;
}
@@ -1227,17 +1246,14 @@
// No type annotations can occur here.
} else {
// There is nothing else in a variable declaration that needs separation.
- Assert.error("Unhandled variable kind: " + tree + " of kind: " + tree.sym.getKind());
+ Assert.error("Unhandled variable kind");
}
- push(tree);
- // super.visitVarDef(tree);
scan(tree.mods);
scan(tree.vartype);
if (!sigOnly) {
scan(tree.init);
}
- pop();
}
@Override
@@ -1363,31 +1379,37 @@
scan(tree.elems);
}
- private void findPosition(JCTree tree, JCTree frame, List<JCAnnotation> annotations) {
+
+ private void findTypeCompoundPosition(JCTree tree, JCTree frame, List<Attribute.TypeCompound> annotations) {
if (!annotations.isEmpty()) {
- /*
- System.err.println("Finding pos for: " + annotations);
- System.err.println(" tree: " + tree + " kind: " + tree.getKind());
- System.err.println(" frame: " + frame + " kind: " + frame.getKind());
- */
final TypeAnnotationPosition p =
- resolveFrame(tree, frame, frames.toList(), currentLambda, 0,
- new ListBuffer<TypePathEntry>());
+ resolveFrame(tree, frame, frames, currentLambda, 0, new ListBuffer<>());
+ for (TypeCompound tc : annotations)
+ tc.position = p;
+ }
+ }
+
+ private void findPosition(JCTree tree, JCTree frame, List<JCAnnotation> annotations) {
+ if (!annotations.isEmpty())
+ {
+ final TypeAnnotationPosition p =
+ resolveFrame(tree, frame, frames, currentLambda, 0, new ListBuffer<>());
+
setTypeAnnotationPos(annotations, p);
}
}
- private void setTypeAnnotationPos(List<JCAnnotation> annotations,
- TypeAnnotationPosition position) {
+ private void setTypeAnnotationPos(List<JCAnnotation> annotations, TypeAnnotationPosition position)
+ {
+ // attribute might be null during DeferredAttr;
+ // we will be back later.
for (JCAnnotation anno : annotations) {
- // attribute might be null during DeferredAttr;
- // we will be back later.
- if (anno.attribute != null) {
+ if (anno.attribute != null)
((Attribute.TypeCompound) anno.attribute).position = position;
- }
}
}
+
@Override
public String toString() {
return super.toString() + ": sigOnly: " + sigOnly;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeMetadata.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeMetadata.java Tue Apr 14 12:10:00 2015 -0700
@@ -30,46 +30,63 @@
import com.sun.tools.javac.util.List;
import java.util.EnumMap;
import java.util.HashSet;
-import java.util.Map;
import java.util.Set;
/**
- * A super-interface for all type metadata elements. Metadata classes
- * can be created for any metadata on types with the following
- * properties:
+ * TypeMetadata is essentially an immutable {@code EnumMap<Entry.Kind, <? extends Entry>>}
*
- * <ul>
- * <li>They have a default value (preferably empty)</li>
- * <li>The field is usually the default value</li>
- * <li>Different values of the field are visible, and denote distinct
- * types</li>
- * </ul>
+ * A metadata class represented by a subtype of Entry can express a property on a Type instance.
+ * Thers should be at most one instance of an Entry per Entry.Kind on any given Type instance.
+ *
+ * Metadata classes of a specific kind are responsible for how they combine themselvs.
+ *
+ * @implNote {@code Entry:combine} need not be commutative.
*/
public class TypeMetadata {
+ public static final TypeMetadata EMPTY = new TypeMetadata();
- public static final TypeMetadata empty = new TypeMetadata();
- private final EnumMap<TypeMetadata.Element.Kind, TypeMetadata.Element> contents;
+ private final EnumMap<Entry.Kind, Entry> contents;
+ /**
+ * Create a new empty TypeMetadata map.
+ */
private TypeMetadata() {
- contents = new EnumMap<Element.Kind, Element>(Element.Kind.class);
+ contents = new EnumMap<>(Entry.Kind.class);
}
- public TypeMetadata(final Element elem) {
+ /**
+ * Create a new TypeMetadata map containing the Entry {@code elem}.
+ *
+ * @param elem the sole contents of this map
+ */
+ public TypeMetadata(Entry elem) {
this();
+ Assert.checkNonNull(elem);
contents.put(elem.kind(), elem);
}
- public TypeMetadata(final TypeMetadata other) {
+ /**
+ * Creates a copy of TypeMetadata {@code other} with a shallow copy the other's metadata contents.
+ *
+ * @param other the TypeMetadata to copy contents from.
+ */
+ public TypeMetadata(TypeMetadata other) {
+ Assert.checkNonNull(other);
contents = other.contents.clone();
}
- public TypeMetadata copy() {
- return new TypeMetadata(this);
- }
+ /**
+ * Return a copy of this TypeMetadata with the metadata entry for {@code elem.kind()} combined
+ * with {@code elem}.
+ *
+ * @param elem the new value
+ * @return a new TypeMetadata updated with {@code Entry elem}
+ */
+ public TypeMetadata combine(Entry elem) {
+ Assert.checkNonNull(elem);
- public TypeMetadata combine(final Element elem) {
- final TypeMetadata out = new TypeMetadata(this);
- final Element.Kind key = elem.kind();
+ TypeMetadata out = new TypeMetadata(this);
+ Entry.Kind key = elem.kind();
if (contents.containsKey(key)) {
out.add(key, this.contents.get(key).combine(elem));
} else {
@@ -78,17 +95,26 @@
return out;
}
- public TypeMetadata combine(final TypeMetadata other) {
- final TypeMetadata out = new TypeMetadata();
- final Set<Element.Kind> keys = new HashSet<>(this.contents.keySet());
+ /**
+ * Return a copy of this TypeMetadata with the metadata entry for all kinds from {@code other}
+ * combined with the same kind from this.
+ *
+ * @param other the TypeMetadata to combine with this
+ * @return a new TypeMetadata updated with all entries from {@code other}
+ */
+ public TypeMetadata combineAll(TypeMetadata other) {
+ Assert.checkNonNull(other);
+
+ TypeMetadata out = new TypeMetadata();
+ Set<Entry.Kind> keys = new HashSet<>(contents.keySet());
keys.addAll(other.contents.keySet());
- for(final Element.Kind key : keys) {
- if (this.contents.containsKey(key)) {
+ for(Entry.Kind key : keys) {
+ if (contents.containsKey(key)) {
if (other.contents.containsKey(key)) {
- out.add(key, this.contents.get(key).combine(other.contents.get(key)));
+ out.add(key, contents.get(key).combine(other.contents.get(key)));
} else {
- out.add(key, this.contents.get(key));
+ out.add(key, contents.get(key));
}
} else if (other.contents.containsKey(key)) {
out.add(key, other.contents.get(key));
@@ -97,26 +123,35 @@
return out;
}
- public Element get(final Element.Kind kind) {
+ /**
+ * Return a TypeMetadata with the metadata entry for {@code kind} removed.
+ *
+ * This may be the same instance or a new TypeMetadata.
+ *
+ * @param kind the {@code Kind} to remove metadata for
+ * @return a new TypeMetadata without {@code Kind kind}
+ */
+ public TypeMetadata without(Entry.Kind kind) {
+ if (this == EMPTY || contents.get(kind) == null)
+ return this;
+
+ TypeMetadata out = new TypeMetadata(this);
+ out.contents.remove(kind);
+ return out.contents.isEmpty() ? EMPTY : out;
+ }
+
+ public Entry get(Entry.Kind kind) {
return contents.get(kind);
}
- public boolean isEmpty() {
- return contents.isEmpty();
- }
-
- private void add(final Element.Kind kind, final Element elem) {
+ private void add(Entry.Kind kind, Entry elem) {
contents.put(kind, elem);
}
- private void addAll(final Map<? extends Element.Kind,? extends Element> m) {
- contents.putAll(m);
- }
-
- public interface Element {
+ public interface Entry {
public enum Kind {
- ANNOTATIONS;
+ ANNOTATIONS
}
/**
@@ -131,16 +166,18 @@
* @param other The metadata with which to combine this one.
* @return The combined metadata.
*/
- public Element combine(Element other);
+ public Entry combine(Entry other);
}
/**
* A type metadata object holding type annotations.
*/
- public static class Annotations implements Element {
- private final List<Attribute.TypeCompound> annos;
+ public static class Annotations implements Entry {
+ private List<Attribute.TypeCompound> annos;
- public Annotations(final List<Attribute.TypeCompound> annos) {
+ public static final List<Attribute.TypeCompound> TO_BE_SET = List.nil();
+
+ public Annotations(List<Attribute.TypeCompound> annos) {
this.annos = annos;
}
@@ -154,18 +191,16 @@
}
@Override
- public Annotations combine(final Element other) {
- // Temporary: we should append the lists, but that won't
- // work with type annotations today. Instead, we replace
- // the list.
- return new Annotations(((Annotations) other).annos);
+ public Annotations combine(Entry other) {
+ Assert.check(annos == TO_BE_SET);
+ annos = ((Annotations)other).annos;
+ return this;
}
@Override
public Kind kind() { return Kind.ANNOTATIONS; }
@Override
- public String toString() { return "ANNOTATIONS { " + annos + " }"; }
+ public String toString() { return "ANNOTATIONS [ " + annos + " ]"; }
}
-
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java Tue Apr 14 12:10:00 2015 -0700
@@ -40,6 +40,7 @@
import com.sun.tools.javac.code.Attribute.RetentionPolicy;
import com.sun.tools.javac.code.Lint.LintCategory;
import com.sun.tools.javac.code.Type.UndetVar.InferenceBound;
+import com.sun.tools.javac.code.TypeMetadata.Entry.Kind;
import com.sun.tools.javac.comp.AttrContext;
import com.sun.tools.javac.comp.Check;
import com.sun.tools.javac.comp.Enter;
@@ -809,7 +810,7 @@
return isSubtype(t, s, false);
}
public boolean isSubtype(Type t, Type s, boolean capture) {
- if (t == s)
+ if (t.equalsIgnoreMetadata(s))
return true;
if (s.isPartial())
return isSuperType(s, t);
@@ -1081,14 +1082,11 @@
isSameTypeStrict.visit(t, s) :
isSameTypeLoose.visit(t, s);
}
- public boolean isSameAnnotatedType(Type t, Type s) {
- return isSameAnnotatedType.visit(t, s);
- }
// where
abstract class SameTypeVisitor extends TypeRelation {
public Boolean visitType(Type t, Type s) {
- if (t == s)
+ if (t.equalsIgnoreMetadata(s))
return true;
if (s.isPartial())
@@ -1281,39 +1279,6 @@
// </editor-fold>
- TypeRelation isSameAnnotatedType = new LooseSameTypeVisitor() {
- private Boolean compareAnnotations(Type t1, Type t2) {
- List<Attribute.TypeCompound> annos1 = t1.getAnnotationMirrors();
- List<Attribute.TypeCompound> annos2 = t2.getAnnotationMirrors();
- return annos1.containsAll(annos2) && annos2.containsAll(annos1);
- }
-
- @Override
- public Boolean visitType(Type t, Type s) {
- return compareAnnotations(t, s) && super.visitType(t, s);
- }
-
- @Override
- public Boolean visitWildcardType(WildcardType t, Type s) {
- return compareAnnotations(t, s) && super.visitWildcardType(t, s);
- }
-
- @Override
- public Boolean visitClassType(ClassType t, Type s) {
- return compareAnnotations(t, s) && super.visitClassType(t, s);
- }
-
- @Override
- public Boolean visitArrayType(ArrayType t, Type s) {
- return compareAnnotations(t, s) && super.visitArrayType(t, s);
- }
-
- @Override
- public Boolean visitForAll(ForAll t, Type s) {
- return compareAnnotations(t, s) && super.visitForAll(t, s);
- }
- };
-
// <editor-fold defaultstate="collapsed" desc="Contains Type">
public boolean containedBy(Type t, Type s) {
switch (t.getTag()) {
@@ -2167,7 +2132,7 @@
* type parameters in t are deleted.
*/
public Type erasure(Type t) {
- return eraseNotNeeded(t)? t : erasure(t, false);
+ return eraseNotNeeded(t) ? t : erasure(t, false);
}
//where
private boolean eraseNotNeeded(Type t) {
@@ -2187,23 +2152,23 @@
}
// where
private TypeMapping<Boolean> erasure = new TypeMapping<Boolean>() {
- private Type combineMetadata(final Type ty,
- final TypeMetadata md) {
- if (!md.isEmpty()) {
- switch (ty.getKind()) {
- default: return ty.clone(ty.metadata.combine(md));
- case OTHER:
- case UNION:
- case INTERSECTION:
- case PACKAGE:
- case EXECUTABLE:
- case NONE:
- case VOID:
- case ERROR:
- return ty;
+ private Type combineMetadata(final Type s,
+ final Type t) {
+ if (t.getMetadata() != TypeMetadata.EMPTY) {
+ switch (s.getKind()) {
+ case OTHER:
+ case UNION:
+ case INTERSECTION:
+ case PACKAGE:
+ case EXECUTABLE:
+ case NONE:
+ case VOID:
+ case ERROR:
+ return s;
+ default: return s.cloneWithMetadata(s.getMetadata().without(Kind.ANNOTATIONS));
}
} else {
- return ty;
+ return s;
}
}
@@ -2212,7 +2177,7 @@
return t; /*fast special case*/
else {
//other cases already handled
- return combineMetadata(t, t.getMetadata());
+ return combineMetadata(t, t);
}
}
@@ -2220,17 +2185,18 @@
public Type visitClassType(ClassType t, Boolean recurse) {
Type erased = t.tsym.erasure(Types.this);
if (recurse) {
- erased = new ErasedClassType(erased.getEnclosingType(),erased.tsym, t.getMetadata());
+ erased = new ErasedClassType(erased.getEnclosingType(),erased.tsym,
+ t.getMetadata().without(Kind.ANNOTATIONS));
return erased;
} else {
- return combineMetadata(erased, t.getMetadata());
+ return combineMetadata(erased, t);
}
}
@Override
public Type visitTypeVar(TypeVar t, Boolean recurse) {
Type erased = erasure(t.bound, recurse);
- return combineMetadata(erased, t.getMetadata());
+ return combineMetadata(erased, t);
}
};
@@ -2932,7 +2898,7 @@
public List<Type> subst(List<Type> ts,
List<Type> from,
List<Type> to) {
- return new Subst(from, to).subst(ts);
+ return ts.map(new Subst(from, to));
}
/**
@@ -2942,10 +2908,10 @@
* elements of the longer list.
*/
public Type subst(Type t, List<Type> from, List<Type> to) {
- return new Subst(from, to).subst(t);
+ return t.map(new Subst(from, to));
}
- private class Subst extends UnaryVisitor<Type> {
+ private class Subst extends TypeMapping<Void> {
List<Type> from;
List<Type> to;
@@ -2964,49 +2930,12 @@
this.to = to;
}
- Type subst(Type t) {
- if (from.tail == null)
- return t;
- else
- return visit(t);
- }
-
- List<Type> subst(List<Type> ts) {
- if (from.tail == null)
- return ts;
- boolean wild = false;
- if (ts.nonEmpty() && from.nonEmpty()) {
- Type head1 = subst(ts.head);
- List<Type> tail1 = subst(ts.tail);
- if (head1 != ts.head || tail1 != ts.tail)
- return tail1.prepend(head1);
- }
- return ts;
- }
-
- public Type visitType(Type t, Void ignored) {
- return t;
- }
-
- @Override
- public Type visitMethodType(MethodType t, Void ignored) {
- List<Type> argtypes = subst(t.argtypes);
- Type restype = subst(t.restype);
- List<Type> thrown = subst(t.thrown);
- if (argtypes == t.argtypes &&
- restype == t.restype &&
- thrown == t.thrown)
- return t;
- else
- return new MethodType(argtypes, restype, thrown, t.tsym);
- }
-
@Override
public Type visitTypeVar(TypeVar t, Void ignored) {
for (List<Type> from = this.from, to = this.to;
from.nonEmpty();
from = from.tail, to = to.tail) {
- if (t == from.head) {
+ if (t.equalsIgnoreMetadata(from.head)) {
return to.head.withTypeVar(t);
}
}
@@ -3014,26 +2943,12 @@
}
@Override
- public Type visitUndetVar(UndetVar t, Void ignored) {
- //do nothing - we should not replace inside undet variables
- return t;
- }
-
- @Override
public Type visitClassType(ClassType t, Void ignored) {
if (!t.isCompound()) {
- List<Type> typarams = t.getTypeArguments();
- List<Type> typarams1 = subst(typarams);
- Type outer = t.getEnclosingType();
- Type outer1 = subst(outer);
- if (typarams1 == typarams && outer1 == outer)
- return t;
- else
- return new ClassType(outer1, typarams1, t.tsym,
- t.getMetadata());
+ return super.visitClassType(t, ignored);
} else {
- Type st = subst(supertype(t));
- List<Type> is = subst(interfaces(t));
+ Type st = visit(supertype(t));
+ List<Type> is = visit(interfaces(t), ignored);
if (st == supertype(t) && is == interfaces(t))
return t;
else
@@ -3043,26 +2958,11 @@
@Override
public Type visitWildcardType(WildcardType t, Void ignored) {
- Type bound = t.type;
- if (t.kind != BoundKind.UNBOUND)
- bound = subst(bound);
- if (bound == t.type) {
- return t;
- } else {
- if (t.isExtendsBound() && bound.isExtendsBound())
- bound = wildUpperBound(bound);
- return new WildcardType(bound, t.kind, syms.boundClass,
- t.bound, t.getMetadata());
+ WildcardType t2 = (WildcardType)super.visitWildcardType(t, ignored);
+ if (t2 != t && t.isExtendsBound() && t2.type.isExtendsBound()) {
+ t2.type = wildUpperBound(t2.type);
}
- }
-
- @Override
- public Type visitArrayType(ArrayType t, Void ignored) {
- Type elemtype = subst(t.elemtype);
- if (elemtype == t.elemtype)
- return t;
- else
- return new ArrayType(elemtype, t.tsym, t.getMetadata());
+ return t2;
}
@Override
@@ -3075,21 +2975,25 @@
Types.this.subst(t.qtype, t.tvars, freevars));
}
List<Type> tvars1 = substBounds(t.tvars, from, to);
- Type qtype1 = subst(t.qtype);
+ Type qtype1 = visit(t.qtype);
if (tvars1 == t.tvars && qtype1 == t.qtype) {
return t;
} else if (tvars1 == t.tvars) {
- return new ForAll(tvars1, qtype1);
+ return new ForAll(tvars1, qtype1) {
+ @Override
+ public boolean needsStripping() {
+ return true;
+ }
+ };
} else {
- return new ForAll(tvars1,
- Types.this.subst(qtype1, t.tvars, tvars1));
+ return new ForAll(tvars1, Types.this.subst(qtype1, t.tvars, tvars1)) {
+ @Override
+ public boolean needsStripping() {
+ return true;
+ }
+ };
}
}
-
- @Override
- public Type visitErrorType(ErrorType t, Void ignored) {
- return t;
- }
}
public List<Type> substBounds(List<Type> tvars,
@@ -4232,8 +4136,7 @@
}
private boolean containsTypeEquivalent(Type t, Type s) {
- return
- isSameType(t, s) || // shortcut
+ return isSameType(t, s) || // shortcut
containsType(t, s) && containsType(s, t);
}
@@ -4675,7 +4578,7 @@
return getRetention(a.type.tsym);
}
- public RetentionPolicy getRetention(Symbol sym) {
+ public RetentionPolicy getRetention(TypeSymbol sym) {
RetentionPolicy vis = RetentionPolicy.CLASS; // the default
Attribute.Compound c = sym.attribute(syms.retentionType.tsym);
if (c != null) {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Analyzer.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Analyzer.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -90,6 +90,7 @@
final DeferredAttr deferredAttr;
final TreeMaker make;
final Names names;
+ private final boolean allowDiamondWithAnonymousClassCreation;
final EnumSet<AnalyzerMode> analyzerModes;
@@ -112,6 +113,7 @@
String findOpt = options.get("find");
//parse modes
Source source = Source.instance(context);
+ allowDiamondWithAnonymousClassCreation = source.allowDiamondWithAnonymousClassCreation();
analyzerModes = AnalyzerMode.getAnalyzerModes(findOpt, source);
}
@@ -210,7 +212,7 @@
boolean match(JCNewClass tree) {
return tree.clazz.hasTag(TYPEAPPLY) &&
!TreeInfo.isDiamond(tree) &&
- tree.def == null;
+ (tree.def == null || allowDiamondWithAnonymousClassCreation);
}
@Override
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,28 +25,39 @@
package com.sun.tools.javac.comp;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
+import com.sun.tools.javac.code.*;
+import com.sun.tools.javac.code.Attribute.Compound;
+import com.sun.tools.javac.code.Attribute.TypeCompound;
+import com.sun.tools.javac.code.Scope.WriteableScope;
+import com.sun.tools.javac.code.Symbol.*;
+import com.sun.tools.javac.code.TypeMetadata.Entry.Kind;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.JCTree.*;
+import com.sun.tools.javac.tree.TreeInfo;
+import com.sun.tools.javac.tree.TreeMaker;
+import com.sun.tools.javac.tree.TreeScanner;
+import com.sun.tools.javac.util.*;
+import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
+import com.sun.tools.javac.util.List;
import javax.tools.JavaFileObject;
+import java.util.*;
-import com.sun.tools.javac.util.*;
-import com.sun.tools.javac.util.DefinedBy.Api;
-import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
-import com.sun.tools.javac.code.*;
-import com.sun.tools.javac.code.Symbol.*;
-import com.sun.tools.javac.tree.*;
-import com.sun.tools.javac.tree.JCTree.*;
-
-import static com.sun.tools.javac.code.Kinds.Kind.*;
+import static com.sun.tools.javac.code.Flags.SYNTHETIC;
+import static com.sun.tools.javac.code.Kinds.Kind.MTH;
+import static com.sun.tools.javac.code.Kinds.Kind.VAR;
+import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE;
import static com.sun.tools.javac.code.TypeTag.ARRAY;
import static com.sun.tools.javac.code.TypeTag.CLASS;
-import static com.sun.tools.javac.tree.JCTree.Tag.*;
+import static com.sun.tools.javac.tree.JCTree.Tag.ANNOTATION;
+import static com.sun.tools.javac.tree.JCTree.Tag.ASSIGN;
+import static com.sun.tools.javac.tree.JCTree.Tag.IDENT;
+import static com.sun.tools.javac.tree.JCTree.Tag.NEWARRAY;
-/** Enter annotations on symbols. Annotations accumulate in a queue,
- * which is processed at the top level of any set of recursive calls
- * requesting it be processed.
+/** Enter annotations onto symbols and types (and trees).
+ *
+ * This is also a pseudo stage in the compiler taking care of scheduling when annotations are
+ * entered.
*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own risk.
@@ -64,95 +75,98 @@
}
private final Attr attr;
- private final TreeMaker make;
- private final Log log;
- private final Symtab syms;
- private final Names names;
- private final Resolve rs;
- private final Types types;
+ private final Check chk;
private final ConstFold cfolder;
- private final Check chk;
+ private final DeferredLintHandler deferredLintHandler;
+ private final Enter enter;
private final Lint lint;
- private final DeferredLintHandler deferredLintHandler;
- private final Source source;
+ private final Log log;
+ private final Names names;
+ private final Resolve resolve;
+ private final TreeMaker make;
+ private final Symtab syms;
+ private final TypeEnvs typeEnvs;
+ private final Types types;
- private boolean allowTypeAnnos;
- private boolean allowRepeatedAnnos;
+ private final Attribute theUnfinishedDefaultValue;
+ private final boolean allowRepeatedAnnos;
protected Annotate(Context context) {
context.put(annotateKey, this);
+
attr = Attr.instance(context);
- make = TreeMaker.instance(context);
+ chk = Check.instance(context);
+ cfolder = ConstFold.instance(context);
+ deferredLintHandler = DeferredLintHandler.instance(context);
+ enter = Enter.instance(context);
log = Log.instance(context);
- syms = Symtab.instance(context);
+ lint = Lint.instance(context);
+ make = TreeMaker.instance(context);
names = Names.instance(context);
- rs = Resolve.instance(context);
+ resolve = Resolve.instance(context);
+ syms = Symtab.instance(context);
+ typeEnvs = TypeEnvs.instance(context);
types = Types.instance(context);
- cfolder = ConstFold.instance(context);
- chk = Check.instance(context);
- source = Source.instance(context);
- lint = Lint.instance(context);
- deferredLintHandler = DeferredLintHandler.instance(context);
+
+ theUnfinishedDefaultValue = new Attribute.Error(syms.errType);
+
+ Source source = Source.instance(context);
allowRepeatedAnnos = source.allowRepeatedAnnotations();
- allowTypeAnnos = source.allowTypeAnnotations();
}
-/* ********************************************************************
- * Queue maintenance
- *********************************************************************/
-
- private int enterCount = 0;
+ /** Semaphore to delay annotation processing */
+ private int blockCount = 0;
- ListBuffer<Worker> q = new ListBuffer<>();
- ListBuffer<Worker> typesQ = new ListBuffer<>();
- ListBuffer<Worker> repeatedQ = new ListBuffer<>();
- ListBuffer<Worker> afterRepeatedQ = new ListBuffer<>();
- ListBuffer<Worker> validateQ = new ListBuffer<>();
-
- public void earlier(Worker a) {
- q.prepend(a);
- }
-
- public void normal(Worker a) {
- q.append(a);
+ /** Called when annotations processing needs to be postponed. */
+ public void blockAnnotations() {
+ blockCount++;
}
- public void typeAnnotation(Worker a) {
- typesQ.append(a);
- }
-
- public void repeated(Worker a) {
- repeatedQ.append(a);
- }
-
- public void afterRepeated(Worker a) {
- afterRepeatedQ.append(a);
- }
-
- public void validate(Worker a) {
- validateQ.append(a);
- }
-
- /** Called when the Enter phase starts. */
- public void enterStart() {
- enterCount++;
- }
-
- /** Called after the Enter phase completes. */
- public void enterDone() {
- enterCount--;
- flush();
+ /** Called when annotation processing can be resumed. */
+ public void unblockAnnotations() {
+ blockCount--;
+ if (blockCount == 0)
+ flush();
}
/** Variant which allows for a delayed flush of annotations.
* Needed by ClassReader */
- public void enterDoneWithoutFlush() {
- enterCount--;
+ public void unblockAnnotationsNoFlush() {
+ blockCount--;
}
+ /** are we blocking annotation processing? */
+ public boolean annotationsBlocked() {return blockCount > 0; }
+
+ public List<TypeCompound> fromAnnotations(List<JCAnnotation> annotations) {
+ if (annotations.isEmpty()) {
+ return List.nil();
+ }
+
+ ListBuffer<TypeCompound> buf = new ListBuffer<>();
+ for (JCAnnotation anno : annotations) {
+ Assert.checkNonNull(anno.attribute);
+ buf.append((TypeCompound) anno.attribute);
+ }
+ return buf.toList();
+ }
+
+ /** Annotate (used for everything else) */
+ public void normal(Runnable r) {
+ q.append(r);
+ }
+
+ /** Validate, triggers after 'normal' */
+ public void validate(Runnable a) {
+ validateQ.append(a);
+ }
+
+ /** Flush all annotation queues */
public void flush() {
- if (enterCount != 0) return;
- enterCount++;
+ if (annotationsBlocked()) return;
+ if (isFlushing()) return;
+
+ startFlushing();
try {
while (q.nonEmpty()) {
q.next().run();
@@ -160,35 +174,502 @@
while (typesQ.nonEmpty()) {
typesQ.next().run();
}
- while (repeatedQ.nonEmpty()) {
- repeatedQ.next().run();
- }
- while (afterRepeatedQ.nonEmpty()) {
- afterRepeatedQ.next().run();
+ while (afterTypesQ.nonEmpty()) {
+ afterTypesQ.next().run();
}
while (validateQ.nonEmpty()) {
validateQ.next().run();
}
} finally {
- enterCount--;
+ doneFlushing();
+ }
+ }
+
+ private ListBuffer<Runnable> q = new ListBuffer<>();
+ private ListBuffer<Runnable> validateQ = new ListBuffer<>();
+
+ private int flushCount = 0;
+ private boolean isFlushing() { return flushCount > 0; }
+ private void startFlushing() { flushCount++; }
+ private void doneFlushing() { flushCount--; }
+
+ ListBuffer<Runnable> typesQ = new ListBuffer<>();
+ ListBuffer<Runnable> afterTypesQ = new ListBuffer<>();
+
+
+ public void typeAnnotation(Runnable a) {
+ typesQ.append(a);
+ }
+
+ public void afterTypes(Runnable a) {
+ afterTypesQ.append(a);
+ }
+
+ /**
+ * Queue annotations for later attribution and entering. This is probably the method you are looking for.
+ *
+ * @param annotations the list of JCAnnotations to attribute and enter
+ * @param localEnv the enclosing env
+ * @param s ths Symbol on which to enter the annotations
+ * @param deferPos report errors here
+ */
+ public void annotateLater(List<JCAnnotation> annotations, Env<AttrContext> localEnv,
+ Symbol s, DiagnosticPosition deferPos)
+ {
+ if (annotations.isEmpty()) {
+ return;
+ }
+
+ s.resetAnnotations(); // mark Annotations as incomplete for now
+
+ normal(new Runnable() {
+ @Override
+ public String toString() {
+ return "Annotate " + annotations + " onto " + s + " in " + s.owner;
+ }
+
+ @Override
+ public void run() {
+ Assert.check(s.annotationsPendingCompletion());
+ JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile);
+ DiagnosticPosition prevLintPos =
+ deferPos != null
+ ? deferredLintHandler.setPos(deferPos)
+ : deferredLintHandler.immediate();
+ Lint prevLint = deferPos != null ? null : chk.setLint(lint);
+ try {
+ if (s.hasAnnotations() && annotations.nonEmpty())
+ log.error(annotations.head.pos, "already.annotated", Kinds.kindName(s), s);
+
+ Assert.checkNonNull(s, "Symbol argument to actualEnterAnnotations is null");
+ annotateNow(s, annotations, localEnv, false);
+ } finally {
+ if (prevLint != null)
+ chk.setLint(prevLint);
+ deferredLintHandler.setPos(prevLintPos);
+ log.useSource(prev);
+ }
+ }
+ });
+
+ validate(new Runnable() { //validate annotations
+ @Override
+ public void run() {
+ JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile);
+ try {
+ chk.validateAnnotations(annotations, s);
+ } finally {
+ log.useSource(prev);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "validate annotations: " + annotations + " on " + s;
+ }
+ });
+ }
+
+
+ /** Queue processing of an attribute default value. */
+ public void annotateDefaultValueLater(JCExpression defaultValue, Env<AttrContext> localEnv,
+ MethodSymbol m, DiagnosticPosition deferPos)
+ {
+ normal(new Runnable() {
+ @Override
+ public void run() {
+ JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile);
+ DiagnosticPosition prevLintPos = deferredLintHandler.setPos(deferPos);
+ try {
+ enterDefaultValue(defaultValue, localEnv, m);
+ } finally {
+ deferredLintHandler.setPos(prevLintPos);
+ log.useSource(prev);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "Annotate " + m.owner + "." +
+ m + " default " + defaultValue;
+ }
+ });
+
+ validate(new Runnable() { //validate annotations
+ @Override
+ public void run() {
+ JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile);
+ try {
+ // if default value is an annotation, check it is a well-formed
+ // annotation value (e.g. no duplicate values, no missing values, etc.)
+ chk.validateAnnotationTree(defaultValue);
+ } finally {
+ log.useSource(prev);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "Validate default value " + m.owner + "." + m + " default " + defaultValue;
+ }
+ });
+ }
+
+ /** Enter a default value for an annotation element. */
+ private void enterDefaultValue(JCExpression defaultValue,
+ Env<AttrContext> localEnv, MethodSymbol m) {
+ m.defaultValue = attributeAnnotationValue(m.type.getReturnType(), defaultValue, localEnv);
+ }
+
+ /**
+ * Gather up annotations into a map from type symbols to lists of Compound attributes,
+ * then continue on with repeating annotations processing.
+ */
+ private <T extends Attribute.Compound> void annotateNow(Symbol toAnnotate,
+ List<JCAnnotation> withAnnotations, Env<AttrContext> env, boolean typeAnnotations)
+ {
+ Map<TypeSymbol, ListBuffer<T>> annotated = new LinkedHashMap<>();
+ Map<T, DiagnosticPosition> pos = new HashMap<>();
+ boolean allowRepeatedAnnos = this.allowRepeatedAnnos;
+
+ for (List<JCAnnotation> al = withAnnotations; !al.isEmpty(); al = al.tail) {
+ JCAnnotation a = al.head;
+
+ T c;
+ if (typeAnnotations) {
+ @SuppressWarnings("unchecked")
+ T tmp = (T)attributeTypeAnnotation(a, syms.annotationType, env);
+ c = tmp;
+ } else {
+ @SuppressWarnings("unchecked")
+ T tmp = (T)attributeAnnotation(a, syms.annotationType, env);
+ c = tmp;
+ }
+
+ Assert.checkNonNull(c, "Failed to create annotation");
+
+ if (annotated.containsKey(a.type.tsym)) {
+ if (!allowRepeatedAnnos) {
+ log.error(a.pos(), "repeatable.annotations.not.supported.in.source");
+ allowRepeatedAnnos = true;
+ }
+ ListBuffer<T> l = annotated.get(a.type.tsym);
+ l = l.append(c);
+ annotated.put(a.type.tsym, l);
+ pos.put(c, a.pos());
+ } else {
+ annotated.put(a.type.tsym, ListBuffer.of(c));
+ pos.put(c, a.pos());
+ }
+
+ // Note: @Deprecated has no effect on local variables and parameters
+ if (!c.type.isErroneous()
+ && toAnnotate.owner.kind != MTH
+ && types.isSameType(c.type, syms.deprecatedType)) {
+ toAnnotate.flags_field |= Flags.DEPRECATED;
+ }
+ }
+
+ List<T> buf = List.nil();
+ for (ListBuffer<T> lb : annotated.values()) {
+ if (lb.size() == 1) {
+ buf = buf.prepend(lb.first());
+ } else {
+ AnnotationContext<T> ctx = new AnnotationContext<>(env, annotated, pos, typeAnnotations);
+ T res = makeContainerAnnotation(lb.toList(), ctx, toAnnotate);
+ if (res != null)
+ buf = buf.prepend(res);
+ }
+ }
+
+ if (typeAnnotations) {
+ @SuppressWarnings("unchecked")
+ List<TypeCompound> attrs = (List<TypeCompound>)buf.reverse();
+ toAnnotate.appendUniqueTypeAttributes(attrs);
+ } else {
+ @SuppressWarnings("unchecked")
+ List<Attribute.Compound> attrs = (List<Attribute.Compound>)buf.reverse();
+ toAnnotate.resetAnnotations();
+ toAnnotate.setDeclarationAttributes(attrs);
}
}
- /** A client that needs to run during {@link #flush()} registers an worker
- * into one of the queues defined in this class. The queues are: {@link #earlier(Worker)},
- * {@link #normal(Worker)}, {@link #typeAnnotation(Worker)}, {@link #repeated(Worker)},
- * {@link #afterRepeated(Worker)}, {@link #validate(Worker)}.
- * The {@link Worker#run()} method will called inside the {@link #flush()}
- * call. Queues are empties in the abovementioned order.
+ /**
+ * Attribute and store a semantic representation of the annotation tree {@code tree} into the
+ * tree.attribute field.
+ *
+ * @param tree the tree representing an annotation
+ * @param expectedAnnotationType the expected (super)type of the annotation
+ * @param env the current env in where the annotation instance is found
*/
- public interface Worker {
- void run();
- String toString();
+ public Attribute.Compound attributeAnnotation(JCAnnotation tree, Type expectedAnnotationType,
+ Env<AttrContext> env)
+ {
+ // The attribute might have been entered if it is Target or Repetable
+ // Because TreeCopier does not copy type, redo this if type is null
+ if (tree.attribute != null && tree.type != null)
+ return tree.attribute;
+
+ List<Pair<MethodSymbol, Attribute>> elems = attributeAnnotationValues(tree, expectedAnnotationType, env);
+ Attribute.Compound ac = new Attribute.Compound(tree.type, elems);
+
+ return tree.attribute = ac;
+ }
+
+ /** Attribute and store a semantic representation of the type annotation tree {@code tree} into
+ * the tree.attribute field.
+ *
+ * @param a the tree representing an annotation
+ * @param expectedAnnotationType the expected (super)type of the annotation
+ * @param env the the current env in where the annotation instance is found
+ */
+ public Attribute.TypeCompound attributeTypeAnnotation(JCAnnotation a, Type expectedAnnotationType,
+ Env<AttrContext> env)
+ {
+ // The attribute might have been entered if it is Target or Repetable
+ // Because TreeCopier does not copy type, redo this if type is null
+ if (a.attribute == null || a.type == null || !(a.attribute instanceof Attribute.TypeCompound)) {
+ // Create a new TypeCompound
+ List<Pair<MethodSymbol,Attribute>> elems =
+ attributeAnnotationValues(a, expectedAnnotationType, env);
+
+ Attribute.TypeCompound tc =
+ new Attribute.TypeCompound(a.type, elems, TypeAnnotationPosition.unknown);
+ a.attribute = tc;
+ return tc;
+ } else {
+ // Use an existing TypeCompound
+ return (Attribute.TypeCompound)a.attribute;
+ }
}
/**
+ * Attribute annotation elements creating a list of pairs of the Symbol representing that
+ * element and the value of that element as an Attribute. */
+ private List<Pair<MethodSymbol, Attribute>> attributeAnnotationValues(JCAnnotation a,
+ Type expected, Env<AttrContext> env)
+ {
+ // The annotation might have had its type attributed (but not
+ // checked) by attr.attribAnnotationTypes during MemberEnter,
+ // in which case we do not need to do it again.
+ Type at = (a.annotationType.type != null ?
+ a.annotationType.type : attr.attribType(a.annotationType, env));
+ a.type = chk.checkType(a.annotationType.pos(), at, expected);
+
+ boolean isError = a.type.isErroneous();
+ if (!a.type.tsym.isAnnotationType() && !isError) {
+ log.error(a.annotationType.pos(),
+ "not.annotation.type", a.type.toString());
+ isError = true;
+ }
+
+ // List of name=value pairs (or implicit "value=" if size 1)
+ List<JCExpression> args = a.args;
+
+ boolean elidedValue = false;
+ // special case: elided "value=" assumed
+ if (args.length() == 1 && !args.head.hasTag(ASSIGN)) {
+ args.head = make.at(args.head.pos).
+ Assign(make.Ident(names.value), args.head);
+ elidedValue = true;
+ }
+
+ ListBuffer<Pair<MethodSymbol,Attribute>> buf = new ListBuffer<>();
+ for (List<JCExpression> tl = args; tl.nonEmpty(); tl = tl.tail) {
+ Pair<MethodSymbol, Attribute> p = attributeAnnotationNameValuePair(tl.head, a.type, isError, env, elidedValue);
+ if (p != null && !p.fst.type.isErroneous())
+ buf.append(p);
+ }
+ return buf.toList();
+ }
+
+ // where
+ private Pair<MethodSymbol, Attribute> attributeAnnotationNameValuePair(JCExpression nameValuePair,
+ Type thisAnnotationType, boolean badAnnotation, Env<AttrContext> env, boolean elidedValue)
+ {
+ if (!nameValuePair.hasTag(ASSIGN)) {
+ log.error(nameValuePair.pos(), "annotation.value.must.be.name.value");
+ attributeAnnotationValue(nameValuePair.type = syms.errType, nameValuePair, env);
+ return null;
+ }
+ JCAssign assign = (JCAssign)nameValuePair;
+ if (!assign.lhs.hasTag(IDENT)) {
+ log.error(nameValuePair.pos(), "annotation.value.must.be.name.value");
+ attributeAnnotationValue(nameValuePair.type = syms.errType, nameValuePair, env);
+ return null;
+ }
+
+ // Resolve element to MethodSym
+ JCIdent left = (JCIdent)assign.lhs;
+ Symbol method = resolve.resolveQualifiedMethod(elidedValue ? assign.rhs.pos() : left.pos(),
+ env, thisAnnotationType,
+ left.name, List.<Type>nil(), null);
+ left.sym = method;
+ left.type = method.type;
+ if (method.owner != thisAnnotationType.tsym && !badAnnotation)
+ log.error(left.pos(), "no.annotation.member", left.name, thisAnnotationType);
+ Type resultType = method.type.getReturnType();
+
+ // Compute value part
+ Attribute value = attributeAnnotationValue(resultType, assign.rhs, env);
+ nameValuePair.type = resultType;
+
+ return method.type.isErroneous() ? null : new Pair<>((MethodSymbol)method, value);
+
+ }
+
+ /** Attribute an annotation element value */
+ private Attribute attributeAnnotationValue(Type expectedElementType, JCExpression tree,
+ Env<AttrContext> env)
+ {
+ //first, try completing the symbol for the annotation value - if acompletion
+ //error is thrown, we should recover gracefully, and display an
+ //ordinary resolution diagnostic.
+ try {
+ expectedElementType.tsym.complete();
+ } catch(CompletionFailure e) {
+ log.error(tree.pos(), "cant.resolve", Kinds.kindName(e.sym), e.sym);
+ expectedElementType = syms.errType;
+ }
+
+ if (expectedElementType.hasTag(ARRAY)) {
+ return getAnnotationArrayValue(expectedElementType, tree, env);
+
+ }
+
+ //error recovery
+ if (tree.hasTag(NEWARRAY)) {
+ if (!expectedElementType.isErroneous())
+ log.error(tree.pos(), "annotation.value.not.allowable.type");
+ JCNewArray na = (JCNewArray)tree;
+ if (na.elemtype != null) {
+ log.error(na.elemtype.pos(), "new.not.allowed.in.annotation");
+ }
+ for (List<JCExpression> l = na.elems; l.nonEmpty(); l=l.tail) {
+ attributeAnnotationValue(syms.errType,
+ l.head,
+ env);
+ }
+ return new Attribute.Error(syms.errType);
+ }
+
+ if (expectedElementType.tsym.isAnnotationType()) {
+ if (tree.hasTag(ANNOTATION)) {
+ return attributeAnnotation((JCAnnotation)tree, expectedElementType, env);
+ } else {
+ log.error(tree.pos(), "annotation.value.must.be.annotation");
+ expectedElementType = syms.errType;
+ }
+ }
+
+ //error recovery
+ if (tree.hasTag(ANNOTATION)) {
+ if (!expectedElementType.isErroneous())
+ log.error(tree.pos(), "annotation.not.valid.for.type", expectedElementType);
+ attributeAnnotation((JCAnnotation)tree, syms.errType, env);
+ return new Attribute.Error(((JCAnnotation)tree).annotationType.type);
+ }
+
+ if (expectedElementType.isPrimitive() ||
+ (types.isSameType(expectedElementType, syms.stringType) && !expectedElementType.hasTag(TypeTag.ERROR))) {
+ return getAnnotationPrimitiveValue(expectedElementType, tree, env);
+ }
+
+ if (expectedElementType.tsym == syms.classType.tsym) {
+ return getAnnotationClassValue(expectedElementType, tree, env);
+ }
+
+ if (expectedElementType.hasTag(CLASS) &&
+ (expectedElementType.tsym.flags() & Flags.ENUM) != 0) {
+ return getAnnotationEnumValue(expectedElementType, tree, env);
+ }
+
+ //error recovery:
+ if (!expectedElementType.isErroneous())
+ log.error(tree.pos(), "annotation.value.not.allowable.type");
+ return new Attribute.Error(attr.attribExpr(tree, env, expectedElementType));
+ }
+
+ private Attribute getAnnotationEnumValue(Type expectedElementType, JCExpression tree, Env<AttrContext> env) {
+ Type result = attr.attribExpr(tree, env, expectedElementType);
+ Symbol sym = TreeInfo.symbol(tree);
+ if (sym == null ||
+ TreeInfo.nonstaticSelect(tree) ||
+ sym.kind != VAR ||
+ (sym.flags() & Flags.ENUM) == 0) {
+ log.error(tree.pos(), "enum.annotation.must.be.enum.constant");
+ return new Attribute.Error(result.getOriginalType());
+ }
+ VarSymbol enumerator = (VarSymbol) sym;
+ return new Attribute.Enum(expectedElementType, enumerator);
+ }
+
+ private Attribute getAnnotationClassValue(Type expectedElementType, JCExpression tree, Env<AttrContext> env) {
+ Type result = attr.attribExpr(tree, env, expectedElementType);
+ if (result.isErroneous()) {
+ // Does it look like an unresolved class literal?
+ if (TreeInfo.name(tree) == names._class &&
+ ((JCFieldAccess) tree).selected.type.isErroneous()) {
+ Name n = (((JCFieldAccess) tree).selected).type.tsym.flatName();
+ return new Attribute.UnresolvedClass(expectedElementType,
+ types.createErrorType(n,
+ syms.unknownSymbol, syms.classType));
+ } else {
+ return new Attribute.Error(result.getOriginalType());
+ }
+ }
+
+ // Class literals look like field accesses of a field named class
+ // at the tree level
+ if (TreeInfo.name(tree) != names._class) {
+ log.error(tree.pos(), "annotation.value.must.be.class.literal");
+ return new Attribute.Error(syms.errType);
+ }
+ return new Attribute.Class(types,
+ (((JCFieldAccess) tree).selected).type);
+ }
+
+ private Attribute getAnnotationPrimitiveValue(Type expectedElementType, JCExpression tree, Env<AttrContext> env) {
+ Type result = attr.attribExpr(tree, env, expectedElementType);
+ if (result.isErroneous())
+ return new Attribute.Error(result.getOriginalType());
+ if (result.constValue() == null) {
+ log.error(tree.pos(), "attribute.value.must.be.constant");
+ return new Attribute.Error(expectedElementType);
+ }
+ result = cfolder.coerce(result, expectedElementType);
+ return new Attribute.Constant(expectedElementType, result.constValue());
+ }
+
+ private Attribute getAnnotationArrayValue(Type expectedElementType, JCExpression tree, Env<AttrContext> env) {
+ // Special case, implicit array
+ if (!tree.hasTag(NEWARRAY)) {
+ tree = make.at(tree.pos).
+ NewArray(null, List.<JCExpression>nil(), List.of(tree));
+ }
+
+ JCNewArray na = (JCNewArray)tree;
+ if (na.elemtype != null) {
+ log.error(na.elemtype.pos(), "new.not.allowed.in.annotation");
+ }
+ ListBuffer<Attribute> buf = new ListBuffer<>();
+ for (List<JCExpression> l = na.elems; l.nonEmpty(); l=l.tail) {
+ buf.append(attributeAnnotationValue(types.elemtype(expectedElementType),
+ l.head,
+ env));
+ }
+ na.type = expectedElementType;
+ return new Attribute.
+ Array(expectedElementType, buf.toArray(new Attribute[buf.length()]));
+ }
+
+ /* *********************************
+ * Support for repeating annotations
+ ***********************************/
+
+ /**
* This context contains all the information needed to synthesize new
- * annotations trees by the completer for repeating annotations.
+ * annotations trees for repeating annotations.
*/
private class AnnotationContext<T extends Attribute.Compound> {
public final Env<AttrContext> env;
@@ -209,280 +690,15 @@
this.pos = pos;
this.isTypeCompound = isTypeCompound;
}
-
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("RepeatedContext[");
- for (Map.Entry<Symbol.TypeSymbol, ListBuffer<T>> entry :
- annotated.entrySet()) {
- sb.append(" ");
- sb.append(entry.getKey());
- sb.append(" = { ");
- sb.append(entry.getValue());
- sb.append(" }");
- }
- sb.append(" ]");
- return sb.toString();
- }
}
- private static class Placeholder<T extends Attribute.Compound> extends Attribute.Compound {
-
- private final Annotate.AnnotationContext<T> ctx;
- private final List<T> placeholderFor;
- private final Symbol on;
-
- public Placeholder(Annotate.AnnotationContext<T> ctx,
- List<T> placeholderFor, Symbol on) {
- super(on.type, List.<Pair<Symbol.MethodSymbol, Attribute>>nil(),
- placeholderFor.head.position);
- this.ctx = ctx;
- this.placeholderFor = placeholderFor;
- this.on = on;
- }
-
- @Override @DefinedBy(Api.LANGUAGE_MODEL)
- public String toString() {
- return "<placeholder: " + placeholderFor + " on: " + on + ">";
- }
-
- public List<T> getPlaceholderFor() {
- return placeholderFor;
- }
-
- public Annotate.AnnotationContext<T> getRepeatedContext() {
- return ctx;
- }
- }
-
-
-/* ********************************************************************
- * Compute an attribute from its annotation.
- *********************************************************************/
-
- /** Process a single compound annotation, returning its
- * Attribute. Used from MemberEnter for attaching the attributes
- * to the annotated symbol.
- */
- Attribute.Compound enterAnnotation(JCAnnotation a,
- Type expected,
- Env<AttrContext> env) {
- List<Pair<MethodSymbol,Attribute>> elems =
- enterAttributeValues(a, expected, env);
- Attribute.Compound ac = new Attribute.Compound(a.type, elems);
- a.attribute = ac;
-
- return ac;
- }
-
- Attribute.TypeCompound enterTypeAnnotation(JCAnnotation a,
- Type expected,
- Env<AttrContext> env) {
- List<Pair<MethodSymbol,Attribute>> elems =
- enterAttributeValues(a, expected, env);
-
- if (a.attribute == null || !(a.attribute instanceof Attribute.TypeCompound)) {
- // Create a new TypeCompound
-
- Attribute.TypeCompound tc =
- new Attribute.TypeCompound(a.type, elems,
- // TODO: Eventually, we will get rid of this use of
- // unknown, because we'll get a position from
- // MemberEnter (task 8027262).
- TypeAnnotationPosition.unknown);
- a.attribute = tc;
- return tc;
- } else {
- // Use an existing TypeCompound
- return (Attribute.TypeCompound)a.attribute;
- }
- }
-
- private List<Pair<MethodSymbol,Attribute>>
- enterAttributeValues(JCAnnotation a,
- Type expected,
- Env<AttrContext> env) {
- // The annotation might have had its type attributed (but not
- // checked) by attr.attribAnnotationTypes during MemberEnter,
- // in which case we do not need to do it again.
- Type at = (a.annotationType.type != null ? a.annotationType.type
- : attr.attribType(a.annotationType, env));
- a.type = chk.checkType(a.annotationType.pos(), at, expected);
- boolean isError = a.type.isErroneous();
- if ((a.type.tsym.flags() & Flags.ANNOTATION) == 0 && !isError) {
- log.error(a.annotationType.pos(),
- "not.annotation.type", a.type.toString());
- isError = true;
- }
- List<JCExpression> args = a.args;
- boolean elidedValue = false;
- if (args.length() == 1 && !args.head.hasTag(ASSIGN)) {
- // special case: elided "value=" assumed
- elidedValue = true;
- args.head = make.at(args.head.pos).
- Assign(make.Ident(names.value), args.head);
- }
- ListBuffer<Pair<MethodSymbol,Attribute>> buf =
- new ListBuffer<>();
- for (List<JCExpression> tl = args; tl.nonEmpty(); tl = tl.tail) {
- JCExpression t = tl.head;
- if (!t.hasTag(ASSIGN)) {
- log.error(t.pos(), "annotation.value.must.be.name.value");
- enterAttributeValue(t.type = syms.errType, t, env);
- continue;
- }
- JCAssign assign = (JCAssign)t;
- if (!assign.lhs.hasTag(IDENT)) {
- log.error(t.pos(), "annotation.value.must.be.name.value");
- enterAttributeValue(t.type = syms.errType, t, env);
- continue;
- }
- JCIdent left = (JCIdent)assign.lhs;
- Symbol method = rs.resolveQualifiedMethod(elidedValue ? assign.rhs.pos() : left.pos(),
- env,
- a.type,
- left.name,
- List.<Type>nil(),
- null);
- left.sym = method;
- left.type = method.type;
- if (method.owner != a.type.tsym && !isError)
- log.error(left.pos(), "no.annotation.member", left.name, a.type);
- Type result = method.type.getReturnType();
- Attribute value = enterAttributeValue(result, assign.rhs, env);
- if (!method.type.isErroneous())
- buf.append(new Pair<>((MethodSymbol)method, value));
- t.type = result;
- }
- return buf.toList();
- }
-
- Attribute enterAttributeValue(Type expected,
- JCExpression tree,
- Env<AttrContext> env) {
- //first, try completing the attribution value sym - if a completion
- //error is thrown, we should recover gracefully, and display an
- //ordinary resolution diagnostic.
- try {
- expected.tsym.complete();
- } catch(CompletionFailure e) {
- log.error(tree.pos(), "cant.resolve", Kinds.kindName(e.sym), e.sym);
- expected = syms.errType;
- }
- if (expected.hasTag(ARRAY)) {
- if (!tree.hasTag(NEWARRAY)) {
- tree = make.at(tree.pos).
- NewArray(null, List.<JCExpression>nil(), List.of(tree));
- }
- JCNewArray na = (JCNewArray)tree;
- if (na.elemtype != null) {
- log.error(na.elemtype.pos(), "new.not.allowed.in.annotation");
- }
- ListBuffer<Attribute> buf = new ListBuffer<>();
- for (List<JCExpression> l = na.elems; l.nonEmpty(); l=l.tail) {
- buf.append(enterAttributeValue(types.elemtype(expected),
- l.head,
- env));
- }
- na.type = expected;
- return new Attribute.
- Array(expected, buf.toArray(new Attribute[buf.length()]));
- }
- if (tree.hasTag(NEWARRAY)) { //error recovery
- if (!expected.isErroneous())
- log.error(tree.pos(), "annotation.value.not.allowable.type");
- JCNewArray na = (JCNewArray)tree;
- if (na.elemtype != null) {
- log.error(na.elemtype.pos(), "new.not.allowed.in.annotation");
- }
- for (List<JCExpression> l = na.elems; l.nonEmpty(); l=l.tail) {
- enterAttributeValue(syms.errType,
- l.head,
- env);
- }
- return new Attribute.Error(syms.errType);
- }
- if ((expected.tsym.flags() & Flags.ANNOTATION) != 0) {
- if (tree.hasTag(ANNOTATION)) {
- return enterAnnotation((JCAnnotation)tree, expected, env);
- } else {
- log.error(tree.pos(), "annotation.value.must.be.annotation");
- expected = syms.errType;
- }
- }
- if (tree.hasTag(ANNOTATION)) { //error recovery
- if (!expected.isErroneous())
- log.error(tree.pos(), "annotation.not.valid.for.type", expected);
- enterAnnotation((JCAnnotation)tree, syms.errType, env);
- return new Attribute.Error(((JCAnnotation)tree).annotationType.type);
- }
- if (expected.isPrimitive() ||
- (types.isSameType(expected, syms.stringType) && !expected.hasTag(TypeTag.ERROR))) {
- Type result = attr.attribExpr(tree, env, expected);
- if (result.isErroneous())
- return new Attribute.Error(result.getOriginalType());
- if (result.constValue() == null) {
- log.error(tree.pos(), "attribute.value.must.be.constant");
- return new Attribute.Error(expected);
- }
- result = cfolder.coerce(result, expected);
- return new Attribute.Constant(expected, result.constValue());
- }
- if (expected.tsym == syms.classType.tsym) {
- Type result = attr.attribExpr(tree, env, expected);
- if (result.isErroneous()) {
- // Does it look like an unresolved class literal?
- if (TreeInfo.name(tree) == names._class &&
- ((JCFieldAccess) tree).selected.type.isErroneous()) {
- Name n = (((JCFieldAccess) tree).selected).type.tsym.flatName();
- return new Attribute.UnresolvedClass(expected,
- types.createErrorType(n,
- syms.unknownSymbol, syms.classType));
- } else {
- return new Attribute.Error(result.getOriginalType());
- }
- }
-
- // Class literals look like field accesses of a field named class
- // at the tree level
- if (TreeInfo.name(tree) != names._class) {
- log.error(tree.pos(), "annotation.value.must.be.class.literal");
- return new Attribute.Error(syms.errType);
- }
- return new Attribute.Class(types,
- (((JCFieldAccess) tree).selected).type);
- }
- if (expected.hasTag(CLASS) &&
- (expected.tsym.flags() & Flags.ENUM) != 0) {
- Type result = attr.attribExpr(tree, env, expected);
- Symbol sym = TreeInfo.symbol(tree);
- if (sym == null ||
- TreeInfo.nonstaticSelect(tree) ||
- sym.kind != VAR ||
- (sym.flags() & Flags.ENUM) == 0) {
- log.error(tree.pos(), "enum.annotation.must.be.enum.constant");
- return new Attribute.Error(result.getOriginalType());
- }
- VarSymbol enumerator = (VarSymbol) sym;
- return new Attribute.Enum(expected, enumerator);
- }
- //error recovery:
- if (!expected.isErroneous())
- log.error(tree.pos(), "annotation.value.not.allowable.type");
- return new Attribute.Error(attr.attribExpr(tree, env, expected));
- }
-
- /* *********************************
- * Support for repeating annotations
- ***********************************/
-
/* Process repeated annotations. This method returns the
* synthesized container annotation or null IFF all repeating
* annotation are invalid. This method reports errors/warnings.
*/
private <T extends Attribute.Compound> T processRepeatedAnnotations(List<T> annotations,
- AnnotationContext<T> ctx,
- Symbol on) {
+ AnnotationContext<T> ctx, Symbol on)
+ {
T firstOccurrence = annotations.head;
List<Attribute> repeated = List.nil();
Type origAnnoType = null;
@@ -490,14 +706,10 @@
Type targetContainerType = null;
MethodSymbol containerValueSymbol = null;
- Assert.check(!annotations.isEmpty() &&
- !annotations.tail.isEmpty()); // i.e. size() > 1
+ Assert.check(!annotations.isEmpty() && !annotations.tail.isEmpty()); // i.e. size() > 1
int count = 0;
- for (List<T> al = annotations;
- !al.isEmpty();
- al = al.tail)
- {
+ for (List<T> al = annotations; !al.isEmpty(); al = al.tail) {
count++;
// There must be more than a single anno in the annotation list
@@ -532,18 +744,23 @@
repeated = repeated.prepend(currentAnno);
}
+ if (!repeated.isEmpty() && targetContainerType == null) {
+ log.error(ctx.pos.get(annotations.head), "duplicate.annotation.invalid.repeated", origAnnoType);
+ return null;
+ }
+
if (!repeated.isEmpty()) {
repeated = repeated.reverse();
TreeMaker m = make.at(ctx.pos.get(firstOccurrence));
Pair<MethodSymbol, Attribute> p =
new Pair<MethodSymbol, Attribute>(containerValueSymbol,
- new Attribute.Array(arrayOfOrigAnnoType, repeated));
+ new Attribute.Array(arrayOfOrigAnnoType, repeated));
if (ctx.isTypeCompound) {
/* TODO: the following code would be cleaner:
Attribute.TypeCompound at = new Attribute.TypeCompound(targetContainerType, List.of(p),
((Attribute.TypeCompound)annotations.head).position);
JCTypeAnnotation annoTree = m.TypeAnnotation(at);
- at = enterTypeAnnotation(annoTree, targetContainerType, ctx.env);
+ at = attributeTypeAnnotation(annoTree, targetContainerType, ctx.env);
*/
// However, we directly construct the TypeCompound to keep the
// direct relation to the contained TypeCompounds.
@@ -562,12 +779,13 @@
JCAnnotation annoTree = m.Annotation(c);
if (!chk.annotationApplicable(annoTree, on))
- log.error(annoTree.pos(), "invalid.repeatable.annotation.incompatible.target", targetContainerType, origAnnoType);
+ log.error(annoTree.pos(), "invalid.repeatable.annotation.incompatible.target",
+ targetContainerType, origAnnoType);
if (!chk.validateAnnotationDeferErrors(annoTree))
log.error(annoTree.pos(), "duplicate.annotation.invalid.repeated", origAnnoType);
- c = enterAnnotation(annoTree, targetContainerType, ctx.env);
+ c = attributeAnnotation(annoTree, targetContainerType, ctx.env);
c.setSynthesized(true);
@SuppressWarnings("unchecked")
@@ -579,17 +797,19 @@
}
}
- /** Fetches the actual Type that should be the containing annotation. */
+ /**
+ * Fetches the actual Type that should be the containing annotation.
+ */
private Type getContainingType(Attribute.Compound currentAnno,
- DiagnosticPosition pos,
- boolean reportError)
+ DiagnosticPosition pos,
+ boolean reportError)
{
Type origAnnoType = currentAnno.type;
TypeSymbol origAnnoDecl = origAnnoType.tsym;
// Fetch the Repeatable annotation from the current
// annotation's declaration, or null if it has none
- Attribute.Compound ca = origAnnoDecl.attribute(syms.repeatableType.tsym);
+ Attribute.Compound ca = origAnnoDecl.getAnnotationTypeMetadata().getRepeatable();
if (ca == null) { // has no Repeatable annotation
if (reportError)
log.error(pos, "duplicate.annotation.missing.container", origAnnoType, syms.repeatableType);
@@ -597,7 +817,7 @@
}
return filterSame(extractContainingType(ca, pos, origAnnoDecl),
- origAnnoType);
+ origAnnoType);
}
// returns null if t is same as 's', returns 't' otherwise
@@ -611,8 +831,8 @@
/** Extract the actual Type to be used for a containing annotation. */
private Type extractContainingType(Attribute.Compound ca,
- DiagnosticPosition pos,
- TypeSymbol annoDecl)
+ DiagnosticPosition pos,
+ TypeSymbol annoDecl)
{
// The next three checks check that the Repeatable annotation
// on the declaration of the annotation type that is repeating is
@@ -657,7 +877,7 @@
nr_value_elems++;
if (nr_value_elems == 1 &&
- elm.kind == MTH) {
+ elm.kind == MTH) {
containerValueSymbol = (MethodSymbol)elm;
} else {
error = true;
@@ -665,14 +885,14 @@
}
if (error) {
log.error(pos,
- "invalid.repeatable.annotation.multiple.values",
- targetContainerType,
- nr_value_elems);
+ "invalid.repeatable.annotation.multiple.values",
+ targetContainerType,
+ nr_value_elems);
return null;
} else if (nr_value_elems == 0) {
log.error(pos,
- "invalid.repeatable.annotation.no.value",
- targetContainerType);
+ "invalid.repeatable.annotation.no.value",
+ targetContainerType);
return null;
}
@@ -680,8 +900,8 @@
// probably "impossible" to fail this
if (containerValueSymbol.kind != MTH) {
log.error(pos,
- "invalid.repeatable.annotation.invalid.value",
- targetContainerType);
+ "invalid.repeatable.annotation.invalid.value",
+ targetContainerType);
fatalError = true;
}
@@ -690,174 +910,24 @@
Type valueRetType = containerValueSymbol.type.getReturnType();
Type expectedType = types.makeArrayType(originalAnnoType);
if (!(types.isArray(valueRetType) &&
- types.isSameType(expectedType, valueRetType))) {
+ types.isSameType(expectedType, valueRetType))) {
log.error(pos,
- "invalid.repeatable.annotation.value.return",
- targetContainerType,
- valueRetType,
- expectedType);
+ "invalid.repeatable.annotation.value.return",
+ targetContainerType,
+ valueRetType,
+ expectedType);
fatalError = true;
}
- if (error) {
- fatalError = true;
- }
-
- // The conditions for a valid containing annotation are made
- // in Check.validateRepeatedAnnotaton();
return fatalError ? null : containerValueSymbol;
}
- private <T extends Attribute.Compound> AnnotationContext<T>
- prepareEnterAnnotations(List<JCAnnotation> annotations,
- Env<AttrContext> env,
- Symbol sym,
- AttributeCreator<T> creator,
- boolean isTypeCompound) {
- Map<TypeSymbol, ListBuffer<T>> annotated = new LinkedHashMap<>();
- Map<T, DiagnosticPosition> pos = new HashMap<>();
-
- for (List<JCAnnotation> al = annotations; !al.isEmpty(); al = al.tail) {
- JCAnnotation a = al.head;
- T c = creator.create(a, syms.annotationType, env);
-
- Assert.checkNonNull(c, "Failed to create annotation");
-
- if (annotated.containsKey(a.type.tsym)) {
- if (!allowRepeatedAnnos) {
- log.error(a.pos(), "repeatable.annotations.not.supported.in.source");
- allowRepeatedAnnos = true;
- }
- ListBuffer<T> l = annotated.get(a.type.tsym);
- l = l.append(c);
- annotated.put(a.type.tsym, l);
- pos.put(c, a.pos());
- } else {
- annotated.put(a.type.tsym, ListBuffer.of(c));
- pos.put(c, a.pos());
- }
-
- // Note: @Deprecated has no effect on local variables and parameters
- if (!c.type.isErroneous()
- && sym.owner.kind != MTH
- && types.isSameType(c.type, syms.deprecatedType)) {
- sym.flags_field |= Flags.DEPRECATED;
- }
- }
-
- return new AnnotationContext<>(env, annotated, pos,
- isTypeCompound);
- }
-
- // Gather up annotations into a map from type symbols to lists of
- // Compound attributes, then continue on with repeating
- // annotations processing
- private <T extends Attribute.Compound>
- void attachAttributesLater(final List<JCAnnotation> annotations,
- final Env<AttrContext> env,
- final Symbol sym,
- final boolean isTypeCompound,
- final AttributeCreator<T> creator,
- final AttributeAttacher<T> attacher) {
- final AnnotationContext<T> ctx =
- prepareEnterAnnotations(annotations, env, sym, creator, isTypeCompound);
- final Map<Symbol.TypeSymbol, ListBuffer<T>> annotated =
- ctx.annotated;
- boolean hasRepeated = false;
-
- List<T> buf = List.<T>nil();
- for (ListBuffer<T> lb : annotated.values()) {
- if (lb.size() == 1) {
- buf = buf.prepend(lb.first());
- } else {
- @SuppressWarnings("unchecked")
- T res = (T) new Placeholder<>(ctx, lb.toList(), sym);
- buf = buf.prepend(res);
- hasRepeated = true;
- }
- }
-
- final List<T> attrs = buf.reverse();
-
- if (!isTypeCompound) {
- // Attach declaration attributes early, so
- // that @Repeatable and other annotations get attached.
- // Since the attacher uses setDeclarationAttributes, this
- // will be overwritten later.
- attacher.attach(sym, attrs);
- }
- if (hasRepeated) {
- repeated(new Annotate.Worker() {
- @Override
- public String toString() {
- return "repeated annotation pass of: " + sym + " in: " + sym.owner;
- }
-
- @Override
- public void run() {
- JavaFileObject oldSource =
- log.useSource(env.toplevel.sourcefile);
- try {
- attacher.attach(sym, replacePlaceholders(attrs, ctx, sym));
- } finally {
- log.useSource(oldSource);
- }
- }
- });
- } else {
- attacher.attach(sym, attrs);
- }
- }
-
- private interface AttributeAttacher<T extends Attribute.Compound> {
- public void attach(Symbol sym, List<T> attrs);
- }
-
- private final AttributeAttacher<Attribute.Compound> declAnnotationsAttacher =
- new AttributeAttacher<Attribute.Compound>() {
- @Override
- public void attach(Symbol sym, List<Attribute.Compound> attrs) {
- sym.resetAnnotations();
- sym.setDeclarationAttributes(attrs);
- }
- };
-
- private final AttributeAttacher<Attribute.TypeCompound> typeAnnotationsAttacher =
- new AttributeAttacher<Attribute.TypeCompound>() {
- @Override
- public void attach(Symbol sym, List<Attribute.TypeCompound> attrs) {
- sym.appendUniqueTypeAttributes(attrs);
- }
- };
-
- private <T extends Attribute.Compound> List<T>
- replacePlaceholders(List<T> buf,
- Annotate.AnnotationContext<T> ctx,
- Symbol sym) {
- List<T> result = List.nil();
- for (T a : buf) {
- if (a instanceof Placeholder) {
- @SuppressWarnings("unchecked")
- T replacement = replaceOne((Placeholder<T>) a, ctx, sym);
-
- if (null != replacement) {
- result = result.prepend(replacement);
- }
- } else {
- result = result.prepend(a);
- }
- }
-
- return result.reverse();
- }
-
- private <T extends Attribute.Compound> T replaceOne(Placeholder<T> placeholder,
- Annotate.AnnotationContext<T> ctx,
- Symbol sym) {
+ private <T extends Attribute.Compound> T makeContainerAnnotation(List<T> toBeReplaced,
+ AnnotationContext<T> ctx, Symbol sym)
+ {
// Process repeated annotations
T validRepeated =
- processRepeatedAnnotations(placeholder.getPlaceholderFor(),
- ctx, sym);
+ processRepeatedAnnotations(toBeReplaced, ctx, sym);
if (validRepeated != null) {
// Check that the container isn't manually
@@ -865,7 +935,8 @@
// its contained annotation.
ListBuffer<T> manualContainer = ctx.annotated.get(validRepeated.type.tsym);
if (manualContainer != null) {
- log.error(ctx.pos.get(manualContainer.first()), "invalid.repeatable.annotation.repeated.and.container.present",
+ log.error(ctx.pos.get(manualContainer.first()),
+ "invalid.repeatable.annotation.repeated.and.container.present",
manualContainer.first().type.tsym);
}
}
@@ -874,107 +945,16 @@
return validRepeated;
}
-/* ********************************************************************
- * Annotation processing
- *********************************************************************/
-
- /** Queue annotations for later processing. */
- void annotateLater(final List<JCAnnotation> annotations,
- final Env<AttrContext> localEnv,
- final Symbol s,
- final DiagnosticPosition deferPos) {
- if (annotations.isEmpty()) {
- return;
- }
- if (s.kind != PCK) {
- s.resetAnnotations(); // mark Annotations as incomplete for now
- }
- normal(new Annotate.Worker() {
- @Override
- public String toString() {
- return "annotate " + annotations + " onto " + s + " in " + s.owner;
- }
-
- @Override
- public void run() {
- Assert.check(s.kind == PCK || s.annotationsPendingCompletion());
- JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile);
- DiagnosticPosition prevLintPos =
- deferPos != null
- ? deferredLintHandler.setPos(deferPos)
- : deferredLintHandler.immediate();
- Lint prevLint = deferPos != null ? null : chk.setLint(lint);
- try {
- if (s.hasAnnotations() &&
- annotations.nonEmpty())
- log.error(annotations.head.pos,
- "already.annotated",
- Kinds.kindName(s), s);
- actualEnterAnnotations(annotations, localEnv, s);
- } finally {
- if (prevLint != null)
- chk.setLint(prevLint);
- deferredLintHandler.setPos(prevLintPos);
- log.useSource(prev);
- }
- }
- });
+ /********************
+ * Type annotations *
+ ********************/
- validate(new Annotate.Worker() { //validate annotations
- @Override
- public void run() {
- JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile);
- try {
- chk.validateAnnotations(annotations, s);
- } finally {
- log.useSource(prev);
- }
- }
- });
- }
-
- private interface AttributeCreator<T extends Attribute.Compound> {
- public T create(JCAnnotation a, Type expected, Env<AttrContext> env);
- }
-
- // TODO: When SE8 features can be used, these can go away and be
- // replaced by method refs.
- private final AttributeCreator<Attribute.Compound> enterAnnotationsCreator =
- new AttributeCreator<Attribute.Compound>() {
- @Override
- public Attribute.Compound create(JCAnnotation a,
- Type expected,
- Env<AttrContext> env) {
- return enterAnnotation(a, syms.annotationType, env);
- }
- };
- private final AttributeCreator<Attribute.TypeCompound> enterTypeAnnotationsCreator =
- new AttributeCreator<Attribute.TypeCompound>() {
- @Override
- public Attribute.TypeCompound create(JCAnnotation a,
- Type expected,
- Env<AttrContext> env) {
- return enterTypeAnnotation(a, syms.annotationType, env);
- }
- };
-
- /** Enter a set of annotations. */
- private void actualEnterAnnotations(List<JCAnnotation> annotations,
- Env<AttrContext> env,
- Symbol s) {
- Assert.checkNonNull(s, "Symbol argument to actualEnterAnnotations is null");
- attachAttributesLater(annotations, env, s, false,
- enterAnnotationsCreator,
- declAnnotationsAttacher);
- }
-
- /*
- * If the symbol is non-null, attach the type annotation to it.
+ /**
+ * Attribute the list of annotations and enter them onto s.
*/
- private void actualEnterTypeAnnotations(final List<JCAnnotation> annotations,
- final Env<AttrContext> env,
- final Symbol s,
- final DiagnosticPosition deferPos) {
+ public void enterTypeAnnotations(List<JCAnnotation> annotations, Env<AttrContext> env,
+ Symbol s, DiagnosticPosition deferPos)
+ {
Assert.checkNonNull(s, "Symbol argument to actualEnterTypeAnnotations is nul/");
JavaFileObject prev = log.useSource(env.toplevel.sourcefile);
DiagnosticPosition prevLintPos = null;
@@ -983,9 +963,7 @@
prevLintPos = deferredLintHandler.setPos(deferPos);
}
try {
- attachAttributesLater(annotations, env, s, true,
- enterTypeAnnotationsCreator,
- typeAnnotationsAttacher);
+ annotateNow(s, annotations, env, true);
} finally {
if (prevLintPos != null)
deferredLintHandler.setPos(prevLintPos);
@@ -993,21 +971,61 @@
}
}
- public void annotateTypeLater(final JCTree tree,
- final Env<AttrContext> env,
- final Symbol sym,
- final DiagnosticPosition deferPos) {
+ /**
+ * Enqueue tree for scanning of type annotations, attaching to the Symbol sym.
+ */
+ public void queueScanTreeAndTypeAnnotate(JCTree tree, Env<AttrContext> env, Symbol sym,
+ DiagnosticPosition deferPos)
+ {
Assert.checkNonNull(sym);
- normal(new Annotate.Worker() {
- @Override
- public String toString() {
- return "type annotate " + tree + " onto " + sym + " in " + sym.owner;
- }
- @Override
- public void run() {
- tree.accept(new TypeAnnotate(env, sym, deferPos));
- }
- });
+ normal(new Runnable() {
+ @Override
+ public String toString() {
+ return "type annotate " + tree + " onto " + sym + " in " + sym.owner;
+ }
+
+ @Override
+ public void run() {
+ tree.accept(new TypeAnnotate(env, sym, deferPos));
+ }
+ });
+ }
+
+ /**
+ * Apply the annotations to the particular type.
+ */
+ public void annotateTypeSecondStage(JCTree tree, List<JCAnnotation> annotations, Type storeAt) {
+ typeAnnotation(new Runnable() {
+ @Override
+ public String toString() {
+ return "Type annotate 2:nd stage " + annotations + " onto " + tree;
+ }
+
+ @Override
+ public void run() {
+ List<Attribute.TypeCompound> compounds = fromAnnotations(annotations);
+ Assert.check(annotations.size() == compounds.size());
+ storeAt.getMetadataOfKind(Kind.ANNOTATIONS).combine(new TypeMetadata.Annotations(compounds));
+ }
+ });
+ }
+
+ /**
+ * Apply the annotations to the particular type.
+ */
+ public void annotateTypeParameterSecondStage(JCTree tree, List<JCAnnotation> annotations) {
+ typeAnnotation(new Runnable() {
+ @Override
+ public String toString() {
+ return "Type annotate 2:nd stage " + annotations + " onto " + tree;
+ }
+
+ @Override
+ public void run() {
+ List<Attribute.TypeCompound> compounds = fromAnnotations(annotations);
+ Assert.check(annotations.size() == compounds.size());
+ }
+ });
}
/**
@@ -1019,9 +1037,7 @@
private final Symbol sym;
private DiagnosticPosition deferPos;
- public TypeAnnotate(final Env<AttrContext> env,
- final Symbol sym,
- final DiagnosticPosition deferPos) {
+ public TypeAnnotate(Env<AttrContext> env, Symbol sym, DiagnosticPosition deferPos) {
this.env = env;
this.sym = sym;
@@ -1029,27 +1045,28 @@
}
@Override
- public void visitAnnotatedType(final JCAnnotatedType tree) {
- actualEnterTypeAnnotations(tree.annotations, env, sym, deferPos);
- super.visitAnnotatedType(tree);
+ public void visitAnnotatedType(JCAnnotatedType tree) {
+ enterTypeAnnotations(tree.annotations, env, sym, deferPos);
+ scan(tree.underlyingType);
}
@Override
- public void visitTypeParameter(final JCTypeParameter tree) {
- actualEnterTypeAnnotations(tree.annotations, env, sym, deferPos);
- super.visitTypeParameter(tree);
+ public void visitTypeParameter(JCTypeParameter tree) {
+ enterTypeAnnotations(tree.annotations, env, sym, deferPos);
+ scan(tree.bounds);
}
@Override
- public void visitNewArray(final JCNewArray tree) {
- actualEnterTypeAnnotations(tree.annotations, env, sym, deferPos);
+ public void visitNewArray(JCNewArray tree) {
+ enterTypeAnnotations(tree.annotations, env, sym, deferPos);
for (List<JCAnnotation> dimAnnos : tree.dimAnnotations)
- actualEnterTypeAnnotations(dimAnnos, env, sym, deferPos);
- super.visitNewArray(tree);
+ enterTypeAnnotations(dimAnnos, env, sym, deferPos);
+ scan(tree.elemtype);
+ scan(tree.elems);
}
@Override
- public void visitMethodDef(final JCMethodDecl tree) {
+ public void visitMethodDef(JCMethodDecl tree) {
scan(tree.mods);
scan(tree.restype);
scan(tree.typarams);
@@ -1058,11 +1075,10 @@
scan(tree.thrown);
scan(tree.defaultValue);
// Do not annotate the body, just the signature.
- // scan(tree.body);
}
@Override
- public void visitVarDef(final JCVariableDecl tree) {
+ public void visitVarDef(JCVariableDecl tree) {
DiagnosticPosition prevPos = deferPos;
deferPos = tree.pos();
try {
@@ -1094,4 +1110,238 @@
}
}
}
+
+ /*********************
+ * Completer support *
+ *********************/
+
+ private AnnotationTypeCompleter theSourceCompleter = new AnnotationTypeCompleter() {
+ @Override
+ public void complete(ClassSymbol sym) throws CompletionFailure {
+ Env<AttrContext> context = typeEnvs.get(sym);
+ Annotate.this.attributeAnnotationType(context);
+ }
+ };
+
+ /* Last stage completer to enter just enough annotations to have a prototype annotation type.
+ * This currently means entering @Target and @Repetable.
+ */
+ public AnnotationTypeCompleter annotationTypeSourceCompleter() {
+ return theSourceCompleter;
+ }
+
+ private void attributeAnnotationType(Env<AttrContext> env) {
+ Assert.check(((JCClassDecl)env.tree).sym.isAnnotationType(),
+ "Trying to annotation type complete a non-annotation type");
+
+ JavaFileObject prev = log.useSource(env.toplevel.sourcefile);
+ try {
+ JCClassDecl tree = (JCClassDecl)env.tree;
+ AnnotationTypeVisitor v = new AnnotationTypeVisitor(attr, chk, syms, typeEnvs);
+ v.scanAnnotationType(tree);
+ tree.sym.getAnnotationTypeMetadata().setRepeatable(v.repeatable);
+ tree.sym.getAnnotationTypeMetadata().setTarget(v.target);
+ } finally {
+ log.useSource(prev);
+ }
+ }
+
+ public Attribute unfinishedDefaultValue() {
+ return theUnfinishedDefaultValue;
+ }
+
+ public static interface AnnotationTypeCompleter {
+ void complete(ClassSymbol sym) throws CompletionFailure;
+ }
+
+ /** Visitor to determine a prototype annotation type for a class declaring an annotation type.
+ *
+ * <p><b>This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.</b>
+ */
+ public class AnnotationTypeVisitor extends TreeScanner {
+ private Env<AttrContext> env;
+
+ private final Attr attr;
+ private final Check check;
+ private final Symtab tab;
+ private final TypeEnvs typeEnvs;
+
+ private Compound target;
+ private Compound repeatable;
+
+ public AnnotationTypeVisitor(Attr attr, Check check, Symtab tab, TypeEnvs typeEnvs) {
+ this.attr = attr;
+ this.check = check;
+ this.tab = tab;
+ this.typeEnvs = typeEnvs;
+ }
+
+ public Compound getRepeatable() {
+ return repeatable;
+ }
+
+ public Compound getTarget() {
+ return target;
+ }
+
+ public void scanAnnotationType(JCClassDecl decl) {
+ visitClassDef(decl);
+ }
+
+ @Override
+ public void visitClassDef(JCClassDecl tree) {
+ Env<AttrContext> prevEnv = env;
+ env = typeEnvs.get(tree.sym);
+ try {
+ scan(tree.mods); // look for repeatable and target
+ // don't descend into body
+ } finally {
+ env = prevEnv;
+ }
+ }
+
+ @Override
+ public void visitAnnotation(JCAnnotation tree) {
+ Type t = tree.annotationType.type;
+ if (t == null) {
+ t = attr.attribType(tree.annotationType, env);
+ tree.annotationType.type = t = check.checkType(tree.annotationType.pos(), t, tab.annotationType);
+ }
+
+ if (t == tab.annotationTargetType) {
+ target = Annotate.this.attributeAnnotation(tree, tab.annotationTargetType, env);
+ } else if (t == tab.repeatableType) {
+ repeatable = Annotate.this.attributeAnnotation(tree, tab.repeatableType, env);
+ }
+ }
+ }
+
+ /** Represents the semantics of an Annotation Type.
+ *
+ * <p><b>This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.</b>
+ */
+ public static class AnnotationTypeMetadata {
+ final ClassSymbol metaDataFor;
+ private Compound target;
+ private Compound repeatable;
+ private AnnotationTypeCompleter annotationTypeCompleter;
+
+ public AnnotationTypeMetadata(ClassSymbol metaDataFor, AnnotationTypeCompleter annotationTypeCompleter) {
+ this.metaDataFor = metaDataFor;
+ this.annotationTypeCompleter = annotationTypeCompleter;
+ }
+
+ private void init() {
+ // Make sure metaDataFor is member entered
+ while (metaDataFor.completer != null)
+ metaDataFor.complete();
+
+ if (annotationTypeCompleter != null) {
+ AnnotationTypeCompleter c = annotationTypeCompleter;
+ annotationTypeCompleter = null;
+ c.complete(metaDataFor);
+ }
+ }
+
+ public void complete() {
+ init();
+ }
+
+ public Compound getRepeatable() {
+ init();
+ return repeatable;
+ }
+
+ public void setRepeatable(Compound repeatable) {
+ Assert.checkNull(this.repeatable);
+ this.repeatable = repeatable;
+ }
+
+ public Compound getTarget() {
+ init();
+ return target;
+ }
+
+ public void setTarget(Compound target) {
+ Assert.checkNull(this.target);
+ this.target = target;
+ }
+
+ public Set<MethodSymbol> getAnnotationElements() {
+ init();
+ Set<MethodSymbol> members = new LinkedHashSet<>();
+ WriteableScope s = metaDataFor.members();
+ Iterable<Symbol> ss = s.getSymbols(NON_RECURSIVE);
+ for (Symbol sym : ss)
+ if (sym.kind == MTH &&
+ sym.name != sym.name.table.names.clinit &&
+ (sym.flags() & SYNTHETIC) == 0)
+ members.add((MethodSymbol)sym);
+ return members;
+ }
+
+ public Set<MethodSymbol> getAnnotationElementsWithDefault() {
+ init();
+ Set<MethodSymbol> members = getAnnotationElements();
+ Set<MethodSymbol> res = new LinkedHashSet<>();
+ for (MethodSymbol m : members)
+ if (m.defaultValue != null)
+ res.add(m);
+ return res;
+ }
+
+ @Override
+ public String toString() {
+ return "Annotation type for: " + metaDataFor;
+ }
+
+ public boolean isMetadataForAnnotationType() { return true; }
+
+ public static AnnotationTypeMetadata notAnAnnotationType() {
+ return NOT_AN_ANNOTATION_TYPE;
+ }
+
+ private static final AnnotationTypeMetadata NOT_AN_ANNOTATION_TYPE =
+ new AnnotationTypeMetadata(null, null) {
+ @Override
+ public void complete() {
+ } // do nothing
+
+ @Override
+ public String toString() {
+ return "Not an annotation type";
+ }
+
+ @Override
+ public Set<MethodSymbol> getAnnotationElements() {
+ return new LinkedHashSet<>(0);
+ }
+
+ @Override
+ public Set<MethodSymbol> getAnnotationElementsWithDefault() {
+ return new LinkedHashSet<>(0);
+ }
+
+ @Override
+ public boolean isMetadataForAnnotationType() {
+ return false;
+ }
+
+ @Override
+ public Compound getTarget() {
+ return null;
+ }
+
+ @Override
+ public Compound getRepeatable() {
+ return null;
+ }
+ };
+ }
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java Tue Apr 14 12:10:00 2015 -0700
@@ -40,12 +40,17 @@
import com.sun.tools.javac.code.Scope.WriteableScope;
import com.sun.tools.javac.code.Symbol.*;
import com.sun.tools.javac.code.Type.*;
+import com.sun.tools.javac.code.TypeMetadata.Annotations;
import com.sun.tools.javac.code.Types.FunctionDescriptorLookupError;
import com.sun.tools.javac.comp.Check.CheckContext;
import com.sun.tools.javac.comp.DeferredAttr.AttrMode;
import com.sun.tools.javac.comp.Infer.InferenceContext;
import com.sun.tools.javac.comp.Infer.FreeTypeListener;
import com.sun.tools.javac.jvm.*;
+import static com.sun.tools.javac.resources.CompilerProperties.Fragments.Diamond;
+import static com.sun.tools.javac.resources.CompilerProperties.Fragments.DiamondInvalidArg;
+import static com.sun.tools.javac.resources.CompilerProperties.Fragments.DiamondInvalidArgs;
+import com.sun.tools.javac.resources.CompilerProperties.Errors;
import com.sun.tools.javac.resources.CompilerProperties.Fragments;
import com.sun.tools.javac.tree.*;
import com.sun.tools.javac.tree.JCTree.*;
@@ -54,6 +59,7 @@
import com.sun.tools.javac.util.DefinedBy.Api;
import com.sun.tools.javac.util.Dependencies.AttributionKind;
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
+import com.sun.tools.javac.util.JCDiagnostic.Fragment;
import com.sun.tools.javac.util.List;
import static com.sun.tools.javac.code.Flags.*;
import static com.sun.tools.javac.code.Flags.ANNOTATION;
@@ -98,11 +104,11 @@
final Target target;
final Types types;
final JCDiagnostic.Factory diags;
- final Annotate annotate;
final TypeAnnotations typeAnnotations;
final DeferredLintHandler deferredLintHandler;
final TypeEnvs typeEnvs;
final Dependencies dependencies;
+ final Annotate annotate;
public static Attr instance(Context context) {
Attr instance = context.get(attrKey);
@@ -219,6 +225,26 @@
final Type found,
final KindSelector ownkind,
final ResultInfo resultInfo) {
+ return check(tree, found, ownkind, resultInfo, true);
+ }
+ /** Check kind and type of given tree against protokind and prototype.
+ * If check succeeds, store type in tree and return it.
+ * If check fails, store errType in tree and return it.
+ * No checks are performed if the prototype is a method type.
+ * It is not necessary in this case since we know that kind and type
+ * are correct.
+ *
+ * @param tree The tree whose kind and type is checked
+ * @param found The computed type of the tree
+ * @param ownkind The computed kind of the tree
+ * @param resultInfo The expected result of the tree
+ * @param recheckPostInference If true and inference is underway, arrange to recheck the tree after inference finishes.
+ */
+ Type check(final JCTree tree,
+ final Type found,
+ final KindSelector ownkind,
+ final ResultInfo resultInfo,
+ boolean recheckPostInference) {
InferenceContext inferenceContext = resultInfo.checkContext.inferenceContext();
Type owntype;
boolean shouldCheck = !found.hasTag(ERROR) &&
@@ -233,12 +259,14 @@
//delay the check if there are inference variables in the found type
//this means we are dealing with a partially inferred poly expression
owntype = shouldCheck ? resultInfo.pt : found;
- inferenceContext.addFreeTypeListener(List.of(found, resultInfo.pt),
- instantiatedContext -> {
- ResultInfo pendingResult =
- resultInfo.dup(inferenceContext.asInstType(resultInfo.pt));
- check(tree, inferenceContext.asInstType(found), ownkind, pendingResult);
- });
+ if (recheckPostInference) {
+ inferenceContext.addFreeTypeListener(List.of(found, resultInfo.pt),
+ instantiatedContext -> {
+ ResultInfo pendingResult =
+ resultInfo.dup(inferenceContext.asInstType(resultInfo.pt));
+ check(tree, inferenceContext.asInstType(found), ownkind, pendingResult, false);
+ });
+ }
} else {
owntype = shouldCheck ?
resultInfo.check(tree, found) :
@@ -862,7 +890,7 @@
} else {
chk.checkOverrideClashes(tree.pos(), env.enclClass.type, m);
}
- chk.checkOverride(tree, m);
+ chk.checkOverride(env, tree, m);
if (isDefaultMethod && types.overridesObjectMethod(m.enclClass(), m)) {
log.error(tree, "default.overrides.object.member", m.name, Kinds.kindName(m.location()), m.location());
@@ -970,7 +998,7 @@
}
// Attribute all type annotations in the body
- annotate.annotateTypeLater(tree.body, localEnv, m, null);
+ annotate.queueScanTreeAndTypeAnnotate(tree.body, localEnv, m, null);
annotate.flush();
// Attribute method body.
@@ -993,16 +1021,16 @@
env.info.scope.enter(tree.sym);
} else {
try {
- annotate.enterStart();
+ annotate.blockAnnotations();
memberEnter.memberEnter(tree, env);
} finally {
- annotate.enterDone();
+ annotate.unblockAnnotations();
}
}
} else {
if (tree.init != null) {
// Field initializer expression need to be entered.
- annotate.annotateTypeLater(tree.init, env, tree.sym, tree.pos());
+ annotate.queueScanTreeAndTypeAnnotate(tree.init, env, tree.sym, tree.pos());
annotate.flush();
}
}
@@ -1063,7 +1091,7 @@
if ((tree.flags & STATIC) != 0) localEnv.info.staticLevel++;
// Attribute all type annotations in the block
- annotate.annotateTypeLater(tree, localEnv, localEnv.info.scope.owner, null);
+ annotate.queueScanTreeAndTypeAnnotate(tree, localEnv, localEnv.info.scope.owner, null);
annotate.flush();
attribStats(tree.stats, localEnv);
@@ -1926,9 +1954,16 @@
// Attribute clazz expression and store
// symbol + type back into the attributed tree.
- Type clazztype = TreeInfo.isEnumInit(env.tree) ?
- attribIdentAsEnumType(env, (JCIdent)clazz) :
- attribType(clazz, env);
+ Type clazztype;
+
+ try {
+ env.info.isNewClass = true;
+ clazztype = TreeInfo.isEnumInit(env.tree) ?
+ attribIdentAsEnumType(env, (JCIdent)clazz) :
+ attribType(clazz, env);
+ } finally {
+ env.info.isNewClass = false;
+ }
clazztype = chk.checkDiamond(tree, clazztype);
chk.validate(clazz, localEnv);
@@ -1969,11 +2004,16 @@
(((JCVariableDecl) env.tree).mods.flags & Flags.ENUM) == 0 ||
((JCVariableDecl) env.tree).init != tree))
log.error(tree.pos(), "enum.cant.be.instantiated");
+
+ boolean isSpeculativeDiamondInferenceRound = TreeInfo.isDiamond(tree) &&
+ resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.SPECULATIVE;
+ boolean skipNonDiamondPath = false;
// Check that class is not abstract
- if (cdef == null &&
+ if (cdef == null && !isSpeculativeDiamondInferenceRound && // class body may be nulled out in speculative tree copy
(clazztype.tsym.flags() & (ABSTRACT | INTERFACE)) != 0) {
log.error(tree.pos(), "abstract.cant.be.instantiated",
clazztype.tsym);
+ skipNonDiamondPath = true;
} else if (cdef != null && clazztype.tsym.isInterface()) {
// Check that no constructor arguments are given to
// anonymous classes implementing an interface
@@ -1986,7 +2026,9 @@
// Error recovery: pretend no arguments were supplied.
argtypes = List.nil();
typeargtypes = List.nil();
- } else if (TreeInfo.isDiamond(tree)) {
+ skipNonDiamondPath = true;
+ }
+ if (TreeInfo.isDiamond(tree)) {
ClassType site = new ClassType(clazztype.getEnclosingType(),
clazztype.tsym.type.getTypeArguments(),
clazztype.tsym,
@@ -2022,7 +2064,7 @@
tree.clazz.type = types.createErrorType(clazztype);
if (!constructorType.isErroneous()) {
- tree.clazz.type = clazztype = constructorType.getReturnType();
+ tree.clazz.type = clazz.type = constructorType.getReturnType();
tree.constructorType = types.createMethodTypeWithReturn(constructorType, syms.voidType);
}
clazztype = chk.checkClassType(tree.clazz, tree.clazz.type, true);
@@ -2031,7 +2073,7 @@
// Resolve the called constructor under the assumption
// that we are referring to a superclass instance of the
// current instance (JLS ???).
- else {
+ else if (!skipNonDiamondPath) {
//the following code alters some of the fields in the current
//AttrContext - hence, the current context must be dup'ed in
//order to avoid downstream failures
@@ -2052,70 +2094,8 @@
}
if (cdef != null) {
- // We are seeing an anonymous class instance creation.
- // In this case, the class instance creation
- // expression
- //
- // E.new <typeargs1>C<typargs2>(args) { ... }
- //
- // is represented internally as
- //
- // E . new <typeargs1>C<typargs2>(args) ( class <empty-name> { ... } ) .
- //
- // This expression is then *transformed* as follows:
- //
- // (1) add an extends or implements clause
- // (2) add a constructor.
- //
- // For instance, if C is a class, and ET is the type of E,
- // the expression
- //
- // E.new <typeargs1>C<typargs2>(args) { ... }
- //
- // is translated to (where X is a fresh name and typarams is the
- // parameter list of the super constructor):
- //
- // new <typeargs1>X(<*nullchk*>E, args) where
- // X extends C<typargs2> {
- // <typarams> X(ET e, args) {
- // e.<typeargs1>super(args)
- // }
- // ...
- // }
-
- if (clazztype.tsym.isInterface()) {
- cdef.implementing = List.of(clazz);
- } else {
- cdef.extending = clazz;
- }
-
- if (resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.CHECK &&
- isSerializable(clazztype)) {
- localEnv.info.isSerializable = true;
- }
-
- attribStat(cdef, localEnv);
-
- // If an outer instance is given,
- // prefix it to the constructor arguments
- // and delete it from the new expression
- if (tree.encl != null && !clazztype.tsym.isInterface()) {
- tree.args = tree.args.prepend(makeNullCheck(tree.encl));
- argtypes = argtypes.prepend(tree.encl.type);
- tree.encl = null;
- }
-
- // Reassign clazztype and recompute constructor.
- clazztype = cdef.sym.type;
- Symbol sym = tree.constructor = rs.resolveConstructor(
- tree.pos(), localEnv, clazztype, argtypes, typeargtypes);
- Assert.check(!sym.kind.isOverloadError());
- tree.constructor = sym;
- tree.constructorType = checkId(noCheckTree,
- clazztype,
- tree.constructor,
- localEnv,
- new ResultInfo(pkind, newMethodTemplate(syms.voidType, argtypes, typeargtypes)));
+ visitAnonymousClassDefinition(tree, clazz, clazztype, cdef, localEnv, argtypes, typeargtypes, pkind);
+ return;
}
if (tree.constructor != null && tree.constructor.kind == MTH)
@@ -2133,6 +2113,125 @@
chk.validate(tree.typeargs, localEnv);
}
+ // where
+ private void visitAnonymousClassDefinition(JCNewClass tree, JCExpression clazz, Type clazztype,
+ JCClassDecl cdef, Env<AttrContext> localEnv,
+ List<Type> argtypes, List<Type> typeargtypes,
+ KindSelector pkind) {
+ // We are seeing an anonymous class instance creation.
+ // In this case, the class instance creation
+ // expression
+ //
+ // E.new <typeargs1>C<typargs2>(args) { ... }
+ //
+ // is represented internally as
+ //
+ // E . new <typeargs1>C<typargs2>(args) ( class <empty-name> { ... } ) .
+ //
+ // This expression is then *transformed* as follows:
+ //
+ // (1) add an extends or implements clause
+ // (2) add a constructor.
+ //
+ // For instance, if C is a class, and ET is the type of E,
+ // the expression
+ //
+ // E.new <typeargs1>C<typargs2>(args) { ... }
+ //
+ // is translated to (where X is a fresh name and typarams is the
+ // parameter list of the super constructor):
+ //
+ // new <typeargs1>X(<*nullchk*>E, args) where
+ // X extends C<typargs2> {
+ // <typarams> X(ET e, args) {
+ // e.<typeargs1>super(args)
+ // }
+ // ...
+ // }
+ InferenceContext inferenceContext = resultInfo.checkContext.inferenceContext();
+ final boolean isDiamond = TreeInfo.isDiamond(tree);
+ if (isDiamond
+ && ((tree.constructorType != null && inferenceContext.free(tree.constructorType))
+ || (tree.clazz.type != null && inferenceContext.free(tree.clazz.type)))) {
+ inferenceContext.addFreeTypeListener(List.of(tree.constructorType, tree.clazz.type),
+ instantiatedContext -> {
+ tree.constructorType = instantiatedContext.asInstType(tree.constructorType);
+ clazz.type = instantiatedContext.asInstType(clazz.type);
+ visitAnonymousClassDefinition(tree, clazz, clazz.type, cdef, localEnv, argtypes, typeargtypes, pkind);
+ });
+ } else {
+ if (isDiamond && clazztype.hasTag(CLASS)) {
+ List<Type> invalidDiamondArgs = chk.checkDiamondDenotable((ClassType)clazztype);
+ if (!clazztype.isErroneous() && invalidDiamondArgs.nonEmpty()) {
+ // One or more types inferred in the previous steps is non-denotable.
+ Fragment fragment = Diamond(clazztype.tsym);
+ log.error(tree.clazz.pos(),
+ Errors.CantApplyDiamond1(
+ fragment,
+ invalidDiamondArgs.size() > 1 ?
+ DiamondInvalidArgs(invalidDiamondArgs, fragment) :
+ DiamondInvalidArg(invalidDiamondArgs, fragment)));
+ }
+ // For <>(){}, inferred types must also be accessible.
+ for (Type t : clazztype.getTypeArguments()) {
+ rs.checkAccessibleType(env, t);
+ }
+ }
+
+ // If we already errored, be careful to avoid a further avalanche. ErrorType answers
+ // false for isInterface call even when the original type is an interface.
+ boolean implementing = clazztype.tsym.isInterface() ||
+ clazztype.isErroneous() && clazztype.getOriginalType().tsym.isInterface();
+
+ if (implementing) {
+ cdef.implementing = List.of(clazz);
+ } else {
+ cdef.extending = clazz;
+ }
+
+ if (resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.CHECK &&
+ isSerializable(clazztype)) {
+ localEnv.info.isSerializable = true;
+ }
+
+ attribStat(cdef, localEnv);
+
+ List<Type> finalargtypes;
+ // If an outer instance is given,
+ // prefix it to the constructor arguments
+ // and delete it from the new expression
+ if (tree.encl != null && !clazztype.tsym.isInterface()) {
+ tree.args = tree.args.prepend(makeNullCheck(tree.encl));
+ finalargtypes = argtypes.prepend(tree.encl.type);
+ tree.encl = null;
+ } else {
+ finalargtypes = argtypes;
+ }
+
+ // Reassign clazztype and recompute constructor. As this necessarily involves
+ // another attribution pass for deferred types in the case of <>, replicate
+ // them. Original arguments have right decorations already.
+ if (isDiamond && pkind.contains(KindSelector.POLY)) {
+ finalargtypes = finalargtypes.map(deferredAttr.deferredCopier);
+ }
+
+ clazztype = cdef.sym.type;
+ Symbol sym = tree.constructor = rs.resolveConstructor(
+ tree.pos(), localEnv, clazztype, finalargtypes, typeargtypes);
+ Assert.check(!sym.kind.isResolutionError());
+ tree.constructor = sym;
+ tree.constructorType = checkId(noCheckTree,
+ clazztype,
+ tree.constructor,
+ localEnv,
+ new ResultInfo(pkind, newMethodTemplate(syms.voidType, finalargtypes, typeargtypes)));
+ }
+ Type owntype = (tree.constructor != null && tree.constructor.kind == MTH) ?
+ clazztype : types.createErrorType(tree.type);
+ result = check(tree, owntype, KindSelector.VAL, resultInfo, false);
+ chk.validate(tree.typeargs, localEnv);
+ }
+
/** Make an attributed null check tree.
*/
public JCExpression makeNullCheck(JCExpression arg) {
@@ -2647,17 +2746,20 @@
Symbol refSym = refResult.fst;
Resolve.ReferenceLookupHelper lookupHelper = refResult.snd;
+ /** this switch will need to go away and be replaced by the new RESOLUTION_TARGET testing
+ * JDK-8075541
+ */
if (refSym.kind != MTH) {
boolean targetError;
switch (refSym.kind) {
case ABSENT_MTH:
+ case MISSING_ENCL:
targetError = false;
break;
case WRONG_MTH:
case WRONG_MTHS:
case AMBIGUOUS:
case HIDDEN:
- case MISSING_ENCL:
case STATICERR:
targetError = true;
break;
@@ -3908,7 +4010,7 @@
TypeVar typeVar = (TypeVar) tree.type;
if (tree.annotations != null && tree.annotations.nonEmpty()) {
- annotateType(tree, tree.annotations);
+ annotate.annotateTypeParameterSecondStage(tree, tree.annotations);
}
if (!typeVar.bound.isErroneous()) {
@@ -3998,45 +4100,17 @@
}
public void visitAnnotation(JCAnnotation tree) {
- Assert.error("should be handled in Annotate");
+ Assert.error("should be handled in annotate");
}
public void visitAnnotatedType(JCAnnotatedType tree) {
- Type underlyingType = attribType(tree.getUnderlyingType(), env);
- this.attribAnnotationTypes(tree.annotations, env);
- annotateType(tree, tree.annotations);
- result = tree.type = underlyingType;
- }
-
- /**
- * Apply the annotations to the particular type.
- */
- public void annotateType(final JCTree tree, final List<JCAnnotation> annotations) {
- annotate.typeAnnotation(new Annotate.Worker() {
- @Override
- public String toString() {
- return "annotate " + annotations + " onto " + tree;
- }
- @Override
- public void run() {
- List<Attribute.TypeCompound> compounds = fromAnnotations(annotations);
- Assert.check(annotations.size() == compounds.size());
- tree.type = tree.type.annotatedType(compounds);
- }
- });
- }
-
- private static List<Attribute.TypeCompound> fromAnnotations(List<JCAnnotation> annotations) {
- if (annotations.isEmpty()) {
- return List.nil();
- }
-
- ListBuffer<Attribute.TypeCompound> buf = new ListBuffer<>();
- for (JCAnnotation anno : annotations) {
- Assert.checkNonNull(anno.attribute);
- buf.append((Attribute.TypeCompound) anno.attribute);
- }
- return buf.toList();
+ attribAnnotationTypes(tree.annotations, env);
+ Type underlyingType = attribType(tree.underlyingType, env);
+ Type annotatedType = underlyingType.annotatedType(Annotations.TO_BE_SET);
+
+ if (!env.info.isNewClass)
+ annotate.annotateTypeSecondStage(tree, tree.annotations, annotatedType);
+ result = tree.type = annotatedType;
}
public void visitErroneous(JCErroneous tree) {
@@ -4204,8 +4278,9 @@
log.error(tree.typarams.head.pos(),
"intf.annotation.cant.have.type.params");
- // If this annotation has a @Repeatable, validate
- Attribute.Compound repeatable = c.attribute(syms.repeatableType.tsym);
+ // If this annotation type has a @Repeatable, validate
+ Attribute.Compound repeatable = c.getAnnotationTypeMetadata().getRepeatable();
+ // If this annotation type has a @Repeatable, validate
if (repeatable != null) {
// get diagnostic position for error reporting
DiagnosticPosition cbPos = getDiagnosticPosition(tree, repeatable.type);
@@ -4581,7 +4656,7 @@
// This method will raise an error for such a type.
for (JCAnnotation ai : annotations) {
if (!ai.type.isErroneous() &&
- typeAnnotations.annotationType(ai.attribute, sym) == TypeAnnotations.AnnotationType.DECLARATION) {
+ typeAnnotations.annotationTargetType(ai.attribute, sym) == TypeAnnotations.AnnotationType.DECLARATION) {
log.error(ai.pos(), "annotation.type.not.applicable");
}
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/AttrContext.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/AttrContext.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -63,6 +63,16 @@
*/
boolean isSpeculative = false;
+ /**
+ * Is this an attribution environment for an anonymous class instantiated using <> ?
+ */
+ boolean isAnonymousDiamond = false;
+
+ /**
+ * Is this an attribution environment for an instance creation expression?
+ */
+ boolean isNewClass = false;
+
/** Are arguments to current function applications boxed into an array for varargs?
*/
Resolve.MethodResolutionPhase pendingResolutionPhase = null;
@@ -100,6 +110,8 @@
info.defaultSuperCallSite = defaultSuperCallSite;
info.isSerializable = isSerializable;
info.isSpeculative = isSpeculative;
+ info.isAnonymousDiamond = isAnonymousDiamond;
+ info.isNewClass = isNewClass;
return info;
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java Tue Apr 14 12:10:00 2015 -0700
@@ -31,7 +31,10 @@
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.code.Attribute.Compound;
+import com.sun.tools.javac.comp.Annotate.AnnotationTypeMetadata;
import com.sun.tools.javac.jvm.*;
+import com.sun.tools.javac.resources.CompilerProperties.Errors;
+import com.sun.tools.javac.resources.CompilerProperties.Fragments;
import com.sun.tools.javac.tree.*;
import com.sun.tools.javac.util.*;
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
@@ -79,11 +82,13 @@
private final DeferredAttr deferredAttr;
private final Infer infer;
private final Types types;
+ private final TypeAnnotations typeAnnotations;
private final JCDiagnostic.Factory diags;
private boolean warnOnSyntheticConflicts;
private boolean suppressAbortOnBadClassFile;
private boolean enableSunApiLintControl;
private final JavaFileManager fileManager;
+ private final Source source;
private final Profile profile;
private final boolean warnOnAccessToSensitiveMembers;
@@ -117,16 +122,18 @@
deferredAttr = DeferredAttr.instance(context);
infer = Infer.instance(context);
types = Types.instance(context);
+ typeAnnotations = TypeAnnotations.instance(context);
diags = JCDiagnostic.Factory.instance(context);
Options options = Options.instance(context);
lint = Lint.instance(context);
fileManager = context.get(JavaFileManager.class);
- Source source = Source.instance(context);
+ source = Source.instance(context);
allowSimplifiedVarargs = source.allowSimplifiedVarargs();
allowDefaultMethods = source.allowDefaultMethods();
allowStrictMethodClashCheck = source.allowStrictMethodClashCheck();
allowPrivateSafeVarargs = source.allowPrivateSafeVarargs();
+ allowDiamondWithAnonymousClassCreation = source.allowDiamondWithAnonymousClassCreation();
complexInference = options.isSet("complexinference");
warnOnSyntheticConflicts = options.isSet("warnOnSyntheticConflicts");
suppressAbortOnBadClassFile = options.isSet("suppressAbortOnBadClassFile");
@@ -169,6 +176,10 @@
*/
boolean allowPrivateSafeVarargs;
+ /** Switch: can diamond inference be used in anonymous instance creation ?
+ */
+ boolean allowDiamondWithAnonymousClassCreation;
+
/** Switch: -complexinference option set?
*/
boolean complexInference;
@@ -518,7 +529,7 @@
* @param found The type that was found.
* @param req The type that was required.
*/
- Type checkType(DiagnosticPosition pos, Type found, Type req) {
+ public Type checkType(DiagnosticPosition pos, Type found, Type req) {
return checkType(pos, found, req, basicHandler);
}
@@ -579,7 +590,7 @@
public void report() {
if (lint.isEnabled(Lint.LintCategory.CAST))
log.warning(Lint.LintCategory.CAST,
- tree.pos(), "redundant.cast", tree.expr.type);
+ tree.pos(), "redundant.cast", tree.clazz.type);
}
});
}
@@ -773,10 +784,9 @@
if (!TreeInfo.isDiamond(tree) ||
t.isErroneous()) {
return checkClassType(tree.clazz.pos(), t, true);
- } else if (tree.def != null) {
+ } else if (tree.def != null && !allowDiamondWithAnonymousClassCreation) {
log.error(tree.clazz.pos(),
- "cant.apply.diamond.1",
- t, diags.fragment("diamond.and.anon.class", t));
+ Errors.CantApplyDiamond1(t, Fragments.DiamondAndAnonClassNotSupportedInSource(source.name)));
return types.createErrorType(t);
} else if (t.tsym.type.getTypeArguments().isEmpty()) {
log.error(tree.clazz.pos(),
@@ -794,6 +804,59 @@
}
}
+ /** Check that the type inferred using the diamond operator does not contain
+ * non-denotable types such as captured types or intersection types.
+ * @param t the type inferred using the diamond operator
+ * @return the (possibly empty) list of non-denotable types.
+ */
+ List<Type> checkDiamondDenotable(ClassType t) {
+ ListBuffer<Type> buf = new ListBuffer<>();
+ for (Type arg : t.getTypeArguments()) {
+ if (!diamondTypeChecker.visit(arg, null)) {
+ buf.append(arg);
+ }
+ }
+ return buf.toList();
+ }
+ // where
+
+ /** diamondTypeChecker: A type visitor that descends down the given type looking for non-denotable
+ * types. The visit methods return false as soon as a non-denotable type is encountered and true
+ * otherwise.
+ */
+ private static final Types.SimpleVisitor<Boolean, Void> diamondTypeChecker = new Types.SimpleVisitor<Boolean, Void>() {
+ @Override
+ public Boolean visitType(Type t, Void s) {
+ return true;
+ }
+ @Override
+ public Boolean visitClassType(ClassType t, Void s) {
+ if (t.isCompound()) {
+ return false;
+ }
+ for (Type targ : t.getTypeArguments()) {
+ if (!visit(targ, s)) {
+ return false;
+ }
+ }
+ return true;
+ }
+ @Override
+ public Boolean visitCapturedType(CapturedType t, Void s) {
+ return false;
+ }
+
+ @Override
+ public Boolean visitArrayType(ArrayType t, Void s) {
+ return visit(t.elemtype, s);
+ }
+
+ @Override
+ public Boolean visitWildcardType(WildcardType t, Void s) {
+ return visit(t.type, s);
+ }
+ };
+
void checkVarargsMethodDecl(Env<AttrContext> env, JCMethodDecl tree) {
MethodSymbol m = tree.sym;
if (!allowSimplifiedVarargs) return;
@@ -1917,7 +1980,7 @@
* for errors.
* @param m The overriding method.
*/
- void checkOverride(JCMethodDecl tree, MethodSymbol m) {
+ void checkOverride(Env<AttrContext> env, JCMethodDecl tree, MethodSymbol m) {
ClassSymbol origin = (ClassSymbol)m.owner;
if ((origin.flags() & ENUM) != 0 && names.finalize.equals(m.name))
if (m.overrides(syms.enumFinalFinalize, origin, types, false)) {
@@ -1934,7 +1997,12 @@
}
}
- if (m.attribute(syms.overrideType.tsym) != null && !isOverrider(m)) {
+ // Check if this method must override a super method due to being annotated with @Override
+ // or by virtue of being a member of a diamond inferred anonymous class. Latter case is to
+ // be treated "as if as they were annotated" with @Override.
+ boolean mustOverride = m.attribute(syms.overrideType.tsym) != null ||
+ (env.info.isAnonymousDiamond && !m.isConstructor() && !m.isPrivate());
+ if (mustOverride && !isOverrider(m)) {
DiagnosticPosition pos = tree.pos();
for (JCAnnotation a : tree.getModifiers().annotations) {
if (a.annotationType.type.tsym == syms.overrideType.tsym) {
@@ -2765,7 +2833,7 @@
}
}
- private void validateRetention(Symbol container, Symbol contained, DiagnosticPosition pos) {
+ private void validateRetention(TypeSymbol container, TypeSymbol contained, DiagnosticPosition pos) {
Attribute.RetentionPolicy containerRetention = types.getRetention(container);
Attribute.RetentionPolicy containedRetention = types.getRetention(contained);
@@ -2804,7 +2872,7 @@
}
}
- private void validateTarget(Symbol container, Symbol contained, DiagnosticPosition pos) {
+ private void validateTarget(TypeSymbol container, TypeSymbol contained, DiagnosticPosition pos) {
// The set of targets the container is applicable to must be a subset
// (with respect to annotation target semantics) of the set of targets
// the contained is applicable to. The target sets may be implicit or
@@ -2931,33 +2999,19 @@
/** Is the annotation applicable to types? */
protected boolean isTypeAnnotation(JCAnnotation a, boolean isTypeParameter) {
- Attribute.Compound atTarget =
- a.annotationType.type.tsym.attribute(syms.annotationTargetType.tsym);
- if (atTarget == null) {
- // An annotation without @Target is not a type annotation.
- return false;
- }
-
- Attribute atValue = atTarget.member(names.value);
- if (!(atValue instanceof Attribute.Array)) {
- return false; // error recovery
+ List<Attribute> targets = typeAnnotations.annotationTargets(a.attribute);
+ return (targets == null) ?
+ false :
+ targets.stream()
+ .anyMatch(attr -> isTypeAnnotation(attr, isTypeParameter));
+ }
+ //where
+ boolean isTypeAnnotation(Attribute a, boolean isTypeParameter) {
+ Attribute.Enum e = (Attribute.Enum)a;
+ return (e.value.name == names.TYPE_USE ||
+ (isTypeParameter && e.value.name == names.TYPE_PARAMETER));
}
- Attribute.Array arr = (Attribute.Array) atValue;
- for (Attribute app : arr.values) {
- if (!(app instanceof Attribute.Enum)) {
- return false; // recovery
- }
- Attribute.Enum e = (Attribute.Enum) app;
-
- if (e.value.name == names.TYPE_USE)
- return true;
- else if (isTypeParameter && e.value.name == names.TYPE_PARAMETER)
- return true;
- }
- return false;
- }
-
/** Is the annotation applicable to the symbol? */
boolean annotationApplicable(JCAnnotation a, Symbol s) {
Attribute.Array arr = getAttributeTargetAttribute(a.annotationType.type.tsym);
@@ -2978,51 +3032,55 @@
}
}
for (Name target : targets) {
- if (target == names.TYPE)
- { if (s.kind == TYP) return true; }
- else if (target == names.FIELD)
- { if (s.kind == VAR && s.owner.kind != MTH) return true; }
- else if (target == names.METHOD)
- { if (s.kind == MTH && !s.isConstructor()) return true; }
- else if (target == names.PARAMETER)
- { if (s.kind == VAR && s.owner.kind == MTH &&
- (s.flags() & PARAMETER) != 0)
+ if (target == names.TYPE) {
+ if (s.kind == TYP)
+ return true;
+ } else if (target == names.FIELD) {
+ if (s.kind == VAR && s.owner.kind != MTH)
return true;
- }
- else if (target == names.CONSTRUCTOR)
- { if (s.kind == MTH && s.isConstructor()) return true; }
- else if (target == names.LOCAL_VARIABLE)
- { if (s.kind == VAR && s.owner.kind == MTH &&
- (s.flags() & PARAMETER) == 0)
+ } else if (target == names.METHOD) {
+ if (s.kind == MTH && !s.isConstructor())
+ return true;
+ } else if (target == names.PARAMETER) {
+ if (s.kind == VAR && s.owner.kind == MTH &&
+ (s.flags() & PARAMETER) != 0) {
return true;
}
- else if (target == names.ANNOTATION_TYPE)
- { if (s.kind == TYP && (s.flags() & ANNOTATION) != 0)
+ } else if (target == names.CONSTRUCTOR) {
+ if (s.kind == MTH && s.isConstructor())
+ return true;
+ } else if (target == names.LOCAL_VARIABLE) {
+ if (s.kind == VAR && s.owner.kind == MTH &&
+ (s.flags() & PARAMETER) == 0) {
+ return true;
+ }
+ } else if (target == names.ANNOTATION_TYPE) {
+ if (s.kind == TYP && (s.flags() & ANNOTATION) != 0) {
return true;
}
- else if (target == names.PACKAGE)
- { if (s.kind == PCK) return true; }
- else if (target == names.TYPE_USE)
- { if (s.kind == TYP || s.kind == VAR ||
- (s.kind == MTH && !s.isConstructor() &&
- !s.type.getReturnType().hasTag(VOID)) ||
- (s.kind == MTH && s.isConstructor()))
+ } else if (target == names.PACKAGE) {
+ if (s.kind == PCK)
+ return true;
+ } else if (target == names.TYPE_USE) {
+ if (s.kind == TYP || s.kind == VAR ||
+ (s.kind == MTH && !s.isConstructor() &&
+ !s.type.getReturnType().hasTag(VOID)) ||
+ (s.kind == MTH && s.isConstructor())) {
return true;
}
- else if (target == names.TYPE_PARAMETER)
- { if (s.kind == TYP && s.type.hasTag(TYPEVAR))
+ } else if (target == names.TYPE_PARAMETER) {
+ if (s.kind == TYP && s.type.hasTag(TYPEVAR))
return true;
- }
- else
- return true; // recovery
+ } else
+ return true; // Unknown ElementType. This should be an error at declaration site,
+ // assume applicable.
}
return false;
}
- Attribute.Array getAttributeTargetAttribute(Symbol s) {
- Attribute.Compound atTarget =
- s.attribute(syms.annotationTargetType.tsym);
+ Attribute.Array getAttributeTargetAttribute(TypeSymbol s) {
+ Attribute.Compound atTarget = s.getAnnotationTypeMetadata().getTarget();
if (atTarget == null) return null; // ok, is applicable
Attribute atValue = atTarget.member(names.value);
if (!(atValue instanceof Attribute.Array)) return null; // error recovery
@@ -3052,32 +3110,33 @@
private boolean validateAnnotation(JCAnnotation a) {
boolean isValid = true;
+ AnnotationTypeMetadata metadata = a.annotationType.type.tsym.getAnnotationTypeMetadata();
+
// collect an inventory of the annotation elements
- Set<MethodSymbol> members = new LinkedHashSet<>();
- for (Symbol sym : a.annotationType.type.tsym.members().getSymbols(NON_RECURSIVE))
- if (sym.kind == MTH && sym.name != names.clinit &&
- (sym.flags() & SYNTHETIC) == 0)
- members.add((MethodSymbol) sym);
+ Set<MethodSymbol> elements = metadata.getAnnotationElements();
// remove the ones that are assigned values
for (JCTree arg : a.args) {
if (!arg.hasTag(ASSIGN)) continue; // recovery
- JCAssign assign = (JCAssign) arg;
+ JCAssign assign = (JCAssign)arg;
Symbol m = TreeInfo.symbol(assign.lhs);
if (m == null || m.type.isErroneous()) continue;
- if (!members.remove(m)) {
+ if (!elements.remove(m)) {
isValid = false;
log.error(assign.lhs.pos(), "duplicate.annotation.member.value",
- m.name, a.type);
+ m.name, a.type);
}
}
// all the remaining ones better have default values
List<Name> missingDefaults = List.nil();
- for (MethodSymbol m : members) {
- if (m.defaultValue == null && !m.type.isErroneous()) {
+ Set<MethodSymbol> membersWithDefault = metadata.getAnnotationElementsWithDefault();
+ for (MethodSymbol m : elements) {
+ if (m.type.isErroneous())
+ continue;
+
+ if (!membersWithDefault.contains(m))
missingDefaults = missingDefaults.append(m.name);
- }
}
missingDefaults = missingDefaults.reverse();
if (missingDefaults.nonEmpty()) {
@@ -3088,12 +3147,18 @@
log.error(a.pos(), key, a.type, missingDefaults);
}
+ return isValid && validateTargetAnnotationValue(a);
+ }
+
+ /* Validate the special java.lang.annotation.Target annotation */
+ boolean validateTargetAnnotationValue(JCAnnotation a) {
// special case: java.lang.annotation.Target must not have
// repeated values in its value member
if (a.annotationType.type.tsym != syms.annotationTargetType.tsym ||
- a.args.tail == null)
- return isValid;
-
+ a.args.tail == null)
+ return true;
+
+ boolean isValid = true;
if (!a.args.head.hasTag(ASSIGN)) return false; // error recovery
JCAssign assign = (JCAssign) a.args.head;
Symbol m = TreeInfo.symbol(assign.lhs);
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Tue Apr 14 12:10:00 2015 -0700
@@ -26,6 +26,7 @@
package com.sun.tools.javac.comp;
import com.sun.source.tree.LambdaExpressionTree.BodyKind;
+import com.sun.source.tree.NewClassTree;
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.code.Type.TypeMapping;
import com.sun.tools.javac.comp.Resolve.ResolveError;
@@ -81,6 +82,8 @@
final Log log;
final Symtab syms;
final TreeMaker make;
+ final TreeCopier<Void> treeCopier;
+ final TypeMapping<Void> deferredCopier;
final Types types;
final Flow flow;
final Names names;
@@ -125,6 +128,35 @@
return "Empty deferred context!";
}
};
+
+ // For speculative attribution, skip the class definition in <>.
+ treeCopier =
+ new TreeCopier<Void>(make) {
+ @Override @DefinedBy(Api.COMPILER_TREE)
+ public JCTree visitNewClass(NewClassTree node, Void p) {
+ JCNewClass t = (JCNewClass) node;
+ if (TreeInfo.isDiamond(t)) {
+ JCExpression encl = copy(t.encl, p);
+ List<JCExpression> typeargs = copy(t.typeargs, p);
+ JCExpression clazz = copy(t.clazz, p);
+ List<JCExpression> args = copy(t.args, p);
+ JCClassDecl def = null;
+ return make.at(t.pos).NewClass(encl, typeargs, clazz, args, def);
+ } else {
+ return super.visitNewClass(node, p);
+ }
+ }
+ };
+ deferredCopier = new TypeMapping<Void> () {
+ @Override
+ public Type visitType(Type t, Void v) {
+ if (t.hasTag(DEFERRED)) {
+ DeferredType dt = (DeferredType) t;
+ return new DeferredType(treeCopier.copy(dt.tree), dt.env);
+ }
+ return t;
+ }
+ };
}
/** shared tree for stuck expressions */
@@ -144,14 +176,14 @@
SpeculativeCache speculativeCache;
DeferredType(JCExpression tree, Env<AttrContext> env) {
- super(null, TypeMetadata.empty);
+ super(null, TypeMetadata.EMPTY);
this.tree = tree;
this.env = attr.copyEnv(env);
this.speculativeCache = new SpeculativeCache();
}
@Override
- public DeferredType clone(TypeMetadata md) {
+ public DeferredType cloneWithMetadata(TypeMetadata md) {
throw new AssertionError("Cannot add metadata to a deferred type");
}
@@ -364,7 +396,7 @@
* disabled during speculative type-checking.
*/
JCTree attribSpeculative(JCTree tree, Env<AttrContext> env, ResultInfo resultInfo) {
- return attribSpeculative(tree, env, resultInfo, new TreeCopier<>(make),
+ return attribSpeculative(tree, env, resultInfo, treeCopier,
(newTree)->new DeferredAttrDiagHandler(log, newTree));
}
@@ -1209,8 +1241,8 @@
rs.getMemberReference(tree, localEnv, mref2,
exprTree.type, tree.name);
tree.sym = res;
- if (res.kind.isOverloadError() ||
- res.type.hasTag(FORALL) ||
+ if (res.kind.isResolutionTargetError() ||
+ res.type != null && res.type.hasTag(FORALL) ||
(res.flags() & Flags.VARARGS) != 0 ||
(TreeInfo.isStaticSelector(exprTree, tree.name.table.names) &&
exprTree.type.isRaw())) {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,6 @@
package com.sun.tools.javac.comp;
-import java.util.*;
import javax.tools.JavaFileObject;
import javax.tools.JavaFileManager;
@@ -34,7 +33,6 @@
import com.sun.tools.javac.code.Scope.*;
import com.sun.tools.javac.code.Symbol.*;
import com.sun.tools.javac.code.Type.*;
-import com.sun.tools.javac.jvm.*;
import com.sun.tools.javac.main.Option.PkgInfo;
import com.sun.tools.javac.tree.*;
import com.sun.tools.javac.tree.JCTree.*;
@@ -87,11 +85,11 @@
public class Enter extends JCTree.Visitor {
protected static final Context.Key<Enter> enterKey = new Context.Key<>();
+ Annotate annotate;
Log log;
Symtab syms;
Check chk;
TreeMaker make;
- Annotate annotate;
TypeEnter typeEnter;
Types types;
Lint lint;
@@ -192,6 +190,7 @@
localEnv.info.isSelfCall = false;
localEnv.info.lint = null; // leave this to be filled in by Attr,
// when annotations have been processed
+ localEnv.info.isAnonymousDiamond = TreeInfo.isDiamond(env.tree);
return localEnv;
}
@@ -252,11 +251,13 @@
Env<AttrContext> prevEnv = this.env;
try {
this.env = env;
+ annotate.blockAnnotations();
tree.accept(this);
return result;
} catch (CompletionFailure ex) {
return chk.completionError(tree.pos(), ex);
} finally {
+ annotate.unblockAnnotations();
this.env = prevEnv;
}
}
@@ -473,7 +474,7 @@
* @param c The class symbol to be processed or null to process all.
*/
public void complete(List<JCCompilationUnit> trees, ClassSymbol c) {
- annotate.enterStart();
+ annotate.blockAnnotations();
ListBuffer<ClassSymbol> prevUncompleted = uncompleted;
if (typeEnter.completionEnabled) uncompleted = new ListBuffer<>();
@@ -496,7 +497,7 @@
}
} finally {
uncompleted = prevUncompleted;
- annotate.enterDone();
+ annotate.unblockAnnotations();
}
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Tue Apr 14 12:10:00 2015 -0700
@@ -1885,7 +1885,7 @@
* Translate a symbol of a given kind into something suitable for the
* synthetic lambda body
*/
- Symbol translate(Name name, final Symbol sym, LambdaSymbolKind skind) {
+ Symbol translate(final Symbol sym, LambdaSymbolKind skind) {
Symbol ret;
switch (skind) {
case CAPTURED_THIS:
@@ -1893,7 +1893,7 @@
break;
case TYPE_VAR:
// Just erase the type var
- ret = new VarSymbol(sym.flags(), name,
+ ret = new VarSymbol(sym.flags(), sym.name,
types.erasure(sym.type), sym.owner);
/* this information should also be kept for LVT generation at Gen
@@ -1902,7 +1902,7 @@
((VarSymbol)ret).pos = ((VarSymbol)sym).pos;
break;
case CAPTURED_VAR:
- ret = new VarSymbol(SYNTHETIC | FINAL | PARAMETER, name, types.erasure(sym.type), translatedSym) {
+ ret = new VarSymbol(SYNTHETIC | FINAL | PARAMETER, sym.name, types.erasure(sym.type), translatedSym) {
@Override
public Symbol baseSymbol() {
//keep mapping with original captured symbol
@@ -1911,16 +1911,16 @@
};
break;
case LOCAL_VAR:
- ret = new VarSymbol(sym.flags() & FINAL, name, sym.type, translatedSym);
+ ret = new VarSymbol(sym.flags() & FINAL, sym.name, sym.type, translatedSym);
((VarSymbol) ret).pos = ((VarSymbol) sym).pos;
break;
case PARAM:
- ret = new VarSymbol((sym.flags() & FINAL) | PARAMETER, name, types.erasure(sym.type), translatedSym);
+ ret = new VarSymbol((sym.flags() & FINAL) | PARAMETER, sym.name, types.erasure(sym.type), translatedSym);
((VarSymbol) ret).pos = ((VarSymbol) sym).pos;
break;
default:
- ret = makeSyntheticVar(FINAL, name, types.erasure(sym.type), translatedSym);
- ((VarSymbol) ret).pos = ((VarSymbol) sym).pos;
+ Assert.error(skind.name());
+ throw new AssertionError();
}
if (ret != sym) {
ret.setDeclarationAttributes(sym.getRawAttributes());
@@ -1931,27 +1931,8 @@
void addSymbol(Symbol sym, LambdaSymbolKind skind) {
Map<Symbol, Symbol> transMap = getSymbolMap(skind);
- Name preferredName;
- switch (skind) {
- case CAPTURED_THIS:
- preferredName = names.fromString("encl$" + transMap.size());
- break;
- case CAPTURED_VAR:
- preferredName = names.fromString("cap$" + transMap.size());
- break;
- case LOCAL_VAR:
- preferredName = sym.name;
- break;
- case PARAM:
- preferredName = sym.name;
- break;
- case TYPE_VAR:
- preferredName = sym.name;
- break;
- default: throw new AssertionError();
- }
if (!transMap.containsKey(sym)) {
- transMap.put(sym, translate(preferredName, sym, skind));
+ transMap.put(sym, translate(sym, skind));
}
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java Tue Apr 14 12:10:00 2015 -0700
@@ -2766,20 +2766,6 @@
return translationMap;
}
- public void visitAnnotatedType(JCAnnotatedType tree) {
- // No need to retain type annotations in the tree
- // tree.annotations = translate(tree.annotations);
- tree.annotations = List.nil();
- tree.underlyingType = translate(tree.underlyingType);
- // but maintain type annotations in the type.
- if (tree.type.isAnnotated()) {
- tree.type = tree.underlyingType.type.annotatedType(tree.type.getAnnotationMirrors());
- } else if (tree.underlyingType.type.isAnnotated()) {
- tree.type = tree.underlyingType.type;
- }
- result = tree;
- }
-
public void visitTypeCast(JCTypeCast tree) {
tree.clazz = translate(tree.clazz);
if (tree.type.isPrimitive() != tree.expr.type.isPrimitive())
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MemberEnter.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MemberEnter.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,8 +25,6 @@
package com.sun.tools.javac.comp;
-import javax.tools.JavaFileObject;
-
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.code.Scope.WriteableScope;
import com.sun.tools.javac.tree.*;
@@ -224,10 +222,12 @@
annotate.annotateLater(tree.mods.annotations, localEnv, m, tree.pos());
// Visit the signature of the method. Note that
// TypeAnnotate doesn't descend into the body.
- annotate.annotateTypeLater(tree, localEnv, m, tree.pos());
+ annotate.queueScanTreeAndTypeAnnotate(tree, localEnv, m, tree.pos());
- if (tree.defaultValue != null)
- annotateDefaultValueLater(tree.defaultValue, localEnv, m, tree.pos());
+ if (tree.defaultValue != null) {
+ m.defaultValue = annotate.unfinishedDefaultValue(); // set it to temporary sentinel for now
+ annotate.annotateDefaultValueLater(tree.defaultValue, localEnv, m, tree.pos());
+ }
}
/** Create a fresh environment for method bodies.
@@ -255,6 +255,7 @@
localEnv.info.staticLevel++;
}
DiagnosticPosition prevLintPos = deferredLintHandler.setPos(tree.pos());
+
try {
if (TreeInfo.isEnumInit(tree)) {
attr.attribIdentAsEnumType(localEnv, (JCIdent)tree.vartype);
@@ -297,7 +298,7 @@
}
annotate.annotateLater(tree.mods.annotations, localEnv, v, tree.pos());
- annotate.annotateTypeLater(tree.vartype, localEnv, v, tree.pos());
+ annotate.queueScanTreeAndTypeAnnotate(tree.vartype, localEnv, v, tree.pos());
v.pos = tree.pos;
}
@@ -434,53 +435,4 @@
Env<AttrContext> iEnv = initEnv(tree, env);
return iEnv;
}
-
- /** Queue processing of an attribute default value. */
- void annotateDefaultValueLater(final JCExpression defaultValue,
- final Env<AttrContext> localEnv,
- final MethodSymbol m,
- final DiagnosticPosition deferPos) {
- annotate.normal(new Annotate.Worker() {
- @Override
- public String toString() {
- return "annotate " + m.owner + "." +
- m + " default " + defaultValue;
- }
-
- @Override
- public void run() {
- JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile);
- DiagnosticPosition prevLintPos = deferredLintHandler.setPos(deferPos);
- try {
- enterDefaultValue(defaultValue, localEnv, m);
- } finally {
- deferredLintHandler.setPos(prevLintPos);
- log.useSource(prev);
- }
- }
- });
- annotate.validate(new Annotate.Worker() { //validate annotations
- @Override
- public void run() {
- JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile);
- try {
- // if default value is an annotation, check it is a well-formed
- // annotation value (e.g. no duplicate values, no missing values, etc.)
- chk.validateAnnotationTree(defaultValue);
- } finally {
- log.useSource(prev);
- }
- }
- });
- }
-
- /** Enter a default value for an attribute method. */
- private void enterDefaultValue(final JCExpression defaultValue,
- final Env<AttrContext> localEnv,
- final MethodSymbol m) {
- m.defaultValue = annotate.enterAttributeValue(m.type.getReturnType(),
- defaultValue,
- localEnv);
- }
-
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -194,7 +194,7 @@
void reportVerboseResolutionDiagnostic(DiagnosticPosition dpos, Name name, Type site,
List<Type> argtypes, List<Type> typeargtypes, Symbol bestSoFar) {
- boolean success = !bestSoFar.kind.isOverloadError();
+ boolean success = !bestSoFar.kind.isResolutionError();
if (success && !verboseResolutionMode.contains(VerboseResolutionMode.SUCCESS)) {
return;
@@ -1389,7 +1389,7 @@
if (currentSymbol.kind != VAR)
continue;
// invariant: sym.kind == Symbol.Kind.VAR
- if (!bestSoFar.kind.isOverloadError() &&
+ if (!bestSoFar.kind.isResolutionError() &&
currentSymbol.owner != bestSoFar.owner)
return new AmbiguityError(bestSoFar, currentSymbol);
else if (!bestSoFar.kind.betterThan(VAR)) {
@@ -1432,11 +1432,11 @@
!sym.isInheritedIn(site.tsym, types)) {
return bestSoFar;
} else if (useVarargs && (sym.flags() & VARARGS) == 0) {
- return bestSoFar.kind.isOverloadError() ?
+ return bestSoFar.kind.isResolutionError() ?
new BadVarargsMethod((ResolveError)bestSoFar.baseSymbol()) :
bestSoFar;
}
- Assert.check(!sym.kind.isOverloadError());
+ Assert.check(!sym.kind.isResolutionError());
try {
Type mt = rawInstantiate(env, site, sym, null, argtypes, typeargtypes,
allowBoxing, useVarargs, types.noWarnings);
@@ -1457,7 +1457,7 @@
? new AccessError(env, site, sym)
: bestSoFar;
}
- return (bestSoFar.kind.isOverloadError() && bestSoFar.kind != AMBIGUOUS)
+ return (bestSoFar.kind.isResolutionError() && bestSoFar.kind != AMBIGUOUS)
? sym
: mostSpecific(argtypes, sym, bestSoFar, env, site, useVarargs);
}
@@ -1939,8 +1939,8 @@
bestSoFar.kind != AMBIGUOUS && l.nonEmpty();
l = l.tail) {
sym = findMemberType(env, site, name, l.head.tsym);
- if (!bestSoFar.kind.isOverloadError() &&
- !sym.kind.isOverloadError() &&
+ if (!bestSoFar.kind.isResolutionError() &&
+ !sym.kind.isResolutionError() &&
sym.owner != bestSoFar.owner)
bestSoFar = new AmbiguityError(bestSoFar, sym);
else
@@ -2176,7 +2176,7 @@
List<Type> argtypes,
List<Type> typeargtypes,
LogResolveHelper logResolveHelper) {
- if (sym.kind.isOverloadError()) {
+ if (sym.kind.isResolutionError()) {
ResolveError errSym = (ResolveError)sym.baseSymbol();
sym = errSym.access(name, qualified ? site.tsym : syms.noSymbol);
argtypes = logResolveHelper.getArgumentTypes(errSym, sym, name, argtypes);
@@ -2366,7 +2366,7 @@
}
@Override
Symbol access(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, Symbol sym) {
- if (sym.kind.isOverloadError()) {
+ if (sym.kind.isResolutionError()) {
sym = super.access(env, pos, location, sym);
} else if (allowMethodHandles) {
MethodSymbol msym = (MethodSymbol)sym;
@@ -2523,7 +2523,7 @@
}
@Override
Symbol access(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, Symbol sym) {
- if (sym.kind.isOverloadError()) {
+ if (sym.kind.isResolutionError()) {
if (sym.kind != WRONG_MTH &&
sym.kind != WRONG_MTHS) {
sym = super.access(env, pos, location, sym);
@@ -2555,7 +2555,8 @@
boolean allowBoxing,
boolean useVarargs) {
Symbol bestSoFar = methodNotFound;
- for (final Symbol sym : site.tsym.members().getSymbolsByName(names.init)) {
+ TypeSymbol tsym = site.tsym.isInterface() ? syms.objectType.tsym : site.tsym;
+ for (final Symbol sym : tsym.members().getSymbolsByName(names.init)) {
//- System.out.println(" e " + e.sym);
if (sym.kind == MTH &&
(sym.flags_field & SYNTHETIC) == 0) {
@@ -2933,7 +2934,7 @@
*/
final boolean shouldStop(Symbol sym, MethodResolutionPhase phase) {
return phase.ordinal() > maxPhase.ordinal() ||
- !sym.kind.isOverloadError() || sym.kind == AMBIGUOUS;
+ !sym.kind.isResolutionError() || sym.kind == AMBIGUOUS;
}
/**
@@ -2979,7 +2980,7 @@
@Override
Symbol access(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, Symbol sym) {
- if (sym.kind.isOverloadError()) {
+ if (sym.kind.isResolutionError()) {
//if nothing is found return the 'first' error
sym = accessMethod(sym, pos, location, site, name, true, argtypes, typeargtypes);
}
@@ -3321,7 +3322,7 @@
boolean hasEnclosingInstance(Env<AttrContext> env, Type type) {
Symbol encl = resolveSelfContainingInternal(env, type.tsym, false);
- return encl != null && !encl.kind.isOverloadError();
+ return encl != null && !encl.kind.isResolutionError();
}
private Symbol resolveSelfContainingInternal(Env<AttrContext> env,
@@ -3503,7 +3504,7 @@
@Override
public Symbol access(Name name, TypeSymbol location) {
- if (!sym.kind.isOverloadError() && sym.kind.matches(KindSelector.TYP))
+ if (!sym.kind.isResolutionError() && sym.kind.matches(KindSelector.TYP))
return types.createErrorType(name, location, sym.type).tsym;
else
return sym;
@@ -4053,7 +4054,7 @@
} else {
key = "bad.instance.method.in.unbound.lookup";
}
- return sym.kind.isOverloadError() ?
+ return sym.kind.isResolutionError() ?
((ResolveError)sym).getDiagnostic(dkind, pos, location, site, name, argtypes, typeargtypes) :
diags.create(dkind, log.currentSource(), pos, key, Kinds.kindName(sym), sym);
}
@@ -4232,8 +4233,8 @@
@Override
public Symbol mergeResults(Symbol bestSoFar, Symbol sym) {
//Check invariants (see {@code LookupHelper.shouldStop})
- Assert.check(bestSoFar.kind.isOverloadError() && bestSoFar.kind != AMBIGUOUS);
- if (!sym.kind.isOverloadError()) {
+ Assert.check(bestSoFar.kind.isResolutionError() && bestSoFar.kind != AMBIGUOUS);
+ if (!sym.kind.isResolutionError()) {
//varargs resolution successful
return sym;
} else {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java Tue Apr 14 12:10:00 2015 -0700
@@ -28,6 +28,7 @@
import java.util.*;
import com.sun.tools.javac.code.*;
+import com.sun.tools.javac.code.Attribute.TypeCompound;
import com.sun.tools.javac.code.Symbol.*;
import com.sun.tools.javac.tree.*;
import com.sun.tools.javac.tree.JCTree.*;
@@ -68,6 +69,7 @@
private TreeMaker make;
private Enter enter;
private Types types;
+ private Annotate annotate;
private final Resolve resolve;
private final CompileStates compileStates;
@@ -91,6 +93,7 @@
Source source = Source.instance(context);
allowInterfaceBridges = source.allowDefaultMethods();
allowGraphInference = source.allowGraphInference();
+ annotate = Annotate.instance(context);
}
/** A hashtable mapping bridge methods to the methods they override after
@@ -751,6 +754,15 @@
result = tree;
}
+ public void visitAnnotatedType(JCAnnotatedType tree) {
+ // For now, we need to keep the annotations in the tree because of the current
+ // MultiCatch implementation wrt type annotations
+ List<TypeCompound> mirrors = annotate.fromAnnotations(tree.annotations);
+ tree.underlyingType = translate(tree.underlyingType);
+ tree.type = tree.underlyingType.type.annotatedType(mirrors);
+ result = tree;
+ }
+
public void visitTypeCast(JCTypeCast tree) {
tree.clazz = translate(tree.clazz, null);
Type originalTarget = tree.type;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -36,6 +36,7 @@
import com.sun.tools.javac.code.Scope.NamedImportScope;
import com.sun.tools.javac.code.Scope.StarImportScope;
import com.sun.tools.javac.code.Scope.WriteableScope;
+import com.sun.tools.javac.comp.Annotate.AnnotationTypeMetadata;
import com.sun.tools.javac.tree.*;
import com.sun.tools.javac.util.*;
import com.sun.tools.javac.util.DefinedBy.Api;
@@ -135,6 +136,7 @@
lint = Lint.instance(context);
typeEnvs = TypeEnvs.instance(context);
dependencies = Dependencies.instance(context);
+ Source source = Source.instance(context);
allowTypeAnnos = source.allowTypeAnnotations();
allowDeprecationOnImport = source.allowDeprecationOnImport();
}
@@ -164,7 +166,7 @@
Env<AttrContext> topEnv = enter.topLevelEnv(tree);
finishImports(tree, () -> { completeClass.resolveImports(tree, topEnv); });
}
- }
+ }
}
/* ********************************************************************
@@ -184,7 +186,7 @@
}
try {
- annotate.enterStart();
+ annotate.blockAnnotations();
sym.flags_field |= UNATTRIBUTED;
List<Env<AttrContext>> queue;
@@ -206,7 +208,7 @@
}
}
} finally {
- annotate.enterDone();
+ annotate.unblockAnnotations();
}
}
@@ -780,9 +782,9 @@
Env<AttrContext> baseEnv = baseEnv(tree, env);
if (tree.extending != null)
- annotate.annotateTypeLater(tree.extending, baseEnv, sym, tree.pos());
+ annotate.queueScanTreeAndTypeAnnotate(tree.extending, baseEnv, sym, tree.pos());
for (JCExpression impl : tree.implementing)
- annotate.annotateTypeLater(impl, baseEnv, sym, tree.pos());
+ annotate.queueScanTreeAndTypeAnnotate(impl, baseEnv, sym, tree.pos());
annotate.flush();
attribSuperTypes(env, baseEnv);
@@ -800,7 +802,7 @@
attr.attribTypeVariables(tree.typarams, baseEnv);
for (JCTypeParameter tp : tree.typarams)
- annotate.annotateTypeLater(tp, baseEnv, sym, tree.pos());
+ annotate.queueScanTreeAndTypeAnnotate(tp, baseEnv, sym, tree.pos());
// check that no package exists with same fully qualified name,
// but admit classes in the unnamed package which have the same
@@ -899,6 +901,11 @@
addEnumMembers(tree, env);
}
memberEnter.memberEnter(tree.defs, env);
+
+ if (tree.sym.isAnnotationType()) {
+ Assert.checkNull(tree.sym.completer);
+ tree.sym.setAnnotationTypeMetadata(new AnnotationTypeMetadata(tree.sym, annotate.annotationTypeSourceCompleter()));
+ }
}
/** Add the implicit members for an enum type
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,447 @@
+/*
+ * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.javac.file;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStreamWriter;
+import java.lang.ref.SoftReference;
+import java.lang.reflect.Constructor;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CoderResult;
+import java.nio.charset.CodingErrorAction;
+import java.nio.charset.IllegalCharsetNameException;
+import java.nio.charset.UnsupportedCharsetException;
+import java.nio.file.Path;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileObject;
+import javax.tools.JavaFileObject.Kind;
+
+import com.sun.tools.javac.code.Lint;
+import com.sun.tools.javac.code.Source;
+import com.sun.tools.javac.file.FSInfo;
+import com.sun.tools.javac.file.Locations;
+import com.sun.tools.javac.main.Option;
+import com.sun.tools.javac.main.OptionHelper;
+import com.sun.tools.javac.main.OptionHelper.GrumpyHelper;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.DefinedBy;
+import com.sun.tools.javac.util.DefinedBy.Api;
+import com.sun.tools.javac.util.JCDiagnostic.SimpleDiagnosticPosition;
+import com.sun.tools.javac.util.Log;
+import com.sun.tools.javac.util.Options;
+
+/**
+ * Utility methods for building a filemanager.
+ * There are no references here to file-system specific objects such as
+ * java.io.File or java.nio.file.Path.
+ */
+public abstract class BaseFileManager implements JavaFileManager {
+ protected BaseFileManager(Charset charset) {
+ this.charset = charset;
+ byteBufferCache = new ByteBufferCache();
+ locations = createLocations();
+ }
+
+ /**
+ * Set the context for JavacPathFileManager.
+ * @param context the context containing items to be associated with the file manager
+ */
+ public void setContext(Context context) {
+ log = Log.instance(context);
+ options = Options.instance(context);
+ classLoaderClass = options.get("procloader");
+ locations.update(log, Lint.instance(context), FSInfo.instance(context));
+ }
+
+ protected Locations createLocations() {
+ return new Locations();
+ }
+
+ /**
+ * The log to be used for error reporting.
+ */
+ public Log log;
+
+ /**
+ * User provided charset (through javax.tools).
+ */
+ protected Charset charset;
+
+ protected Options options;
+
+ protected String classLoaderClass;
+
+ protected Locations locations;
+
+ /**
+ * A flag for clients to use to indicate that this file manager should
+ * be closed when it is no longer required.
+ */
+ public boolean autoClose;
+
+ protected Source getSource() {
+ String sourceName = options.get(Option.SOURCE);
+ Source source = null;
+ if (sourceName != null)
+ source = Source.lookup(sourceName);
+ return (source != null ? source : Source.DEFAULT);
+ }
+
+ protected ClassLoader getClassLoader(URL[] urls) {
+ ClassLoader thisClassLoader = getClass().getClassLoader();
+
+ // Allow the following to specify a closeable classloader
+ // other than URLClassLoader.
+
+ // 1: Allow client to specify the class to use via hidden option
+ if (classLoaderClass != null) {
+ try {
+ Class<? extends ClassLoader> loader =
+ Class.forName(classLoaderClass).asSubclass(ClassLoader.class);
+ Class<?>[] constrArgTypes = { URL[].class, ClassLoader.class };
+ Constructor<? extends ClassLoader> constr = loader.getConstructor(constrArgTypes);
+ return constr.newInstance(urls, thisClassLoader);
+ } catch (ReflectiveOperationException t) {
+ // ignore errors loading user-provided class loader, fall through
+ }
+ }
+ return new URLClassLoader(urls, thisClassLoader);
+ }
+
+ public boolean isDefaultBootClassPath() {
+ return locations.isDefaultBootClassPath();
+ }
+
+ // <editor-fold defaultstate="collapsed" desc="Option handling">
+ @Override @DefinedBy(Api.COMPILER)
+ public boolean handleOption(String current, Iterator<String> remaining) {
+ OptionHelper helper = new GrumpyHelper(log) {
+ @Override
+ public String get(Option option) {
+ return options.get(option.getText());
+ }
+
+ @Override
+ public void put(String name, String value) {
+ options.put(name, value);
+ }
+
+ @Override
+ public void remove(String name) {
+ options.remove(name);
+ }
+
+ @Override
+ public boolean handleFileManagerOption(Option option, String value) {
+ return handleOption(option, value);
+ }
+ };
+
+ for (Option o: javacFileManagerOptions) {
+ if (o.matches(current)) {
+ if (o.hasArg()) {
+ if (remaining.hasNext()) {
+ if (!o.process(helper, current, remaining.next()))
+ return true;
+ }
+ } else {
+ if (!o.process(helper, current))
+ return true;
+ }
+ // operand missing, or process returned true
+ throw new IllegalArgumentException(current);
+ }
+ }
+
+ return false;
+ }
+ // where
+ private static final Set<Option> javacFileManagerOptions =
+ Option.getJavacFileManagerOptions();
+
+ @Override @DefinedBy(Api.COMPILER)
+ public int isSupportedOption(String option) {
+ for (Option o : javacFileManagerOptions) {
+ if (o.matches(option))
+ return o.hasArg() ? 1 : 0;
+ }
+ return -1;
+ }
+
+ /**
+ * Common back end for OptionHelper handleFileManagerOption.
+ * @param option the option whose value to be set
+ * @param value the value for the option
+ * @return true if successful, and false otherwise
+ */
+ public boolean handleOption(Option option, String value) {
+ return locations.handleOption(option, value);
+ }
+
+ /**
+ * Call handleOption for collection of options and corresponding values.
+ * @param map a collection of options and corresponding values
+ * @return true if all the calls are successful
+ */
+ public boolean handleOptions(Map<Option, String> map) {
+ boolean ok = true;
+ for (Map.Entry<Option, String> e: map.entrySet())
+ ok = ok & handleOption(e.getKey(), e.getValue());
+ return ok;
+ }
+
+ // </editor-fold>
+
+ // <editor-fold defaultstate="collapsed" desc="Encoding">
+ private String defaultEncodingName;
+ private String getDefaultEncodingName() {
+ if (defaultEncodingName == null) {
+ defaultEncodingName =
+ new OutputStreamWriter(new ByteArrayOutputStream()).getEncoding();
+ }
+ return defaultEncodingName;
+ }
+
+ public String getEncodingName() {
+ String encName = options.get(Option.ENCODING);
+ if (encName == null)
+ return getDefaultEncodingName();
+ else
+ return encName;
+ }
+
+ @SuppressWarnings("cast")
+ public CharBuffer decode(ByteBuffer inbuf, boolean ignoreEncodingErrors) {
+ String encodingName = getEncodingName();
+ CharsetDecoder decoder;
+ try {
+ decoder = getDecoder(encodingName, ignoreEncodingErrors);
+ } catch (IllegalCharsetNameException | UnsupportedCharsetException e) {
+ log.error("unsupported.encoding", encodingName);
+ return (CharBuffer)CharBuffer.allocate(1).flip();
+ }
+
+ // slightly overestimate the buffer size to avoid reallocation.
+ float factor =
+ decoder.averageCharsPerByte() * 0.8f +
+ decoder.maxCharsPerByte() * 0.2f;
+ CharBuffer dest = CharBuffer.
+ allocate(10 + (int)(inbuf.remaining()*factor));
+
+ while (true) {
+ CoderResult result = decoder.decode(inbuf, dest, true);
+ dest.flip();
+
+ if (result.isUnderflow()) { // done reading
+ // make sure there is at least one extra character
+ if (dest.limit() == dest.capacity()) {
+ dest = CharBuffer.allocate(dest.capacity()+1).put(dest);
+ dest.flip();
+ }
+ return dest;
+ } else if (result.isOverflow()) { // buffer too small; expand
+ int newCapacity =
+ 10 + dest.capacity() +
+ (int)(inbuf.remaining()*decoder.maxCharsPerByte());
+ dest = CharBuffer.allocate(newCapacity).put(dest);
+ } else if (result.isMalformed() || result.isUnmappable()) {
+ // bad character in input
+
+ log.error(new SimpleDiagnosticPosition(dest.limit()),
+ "illegal.char.for.encoding",
+ charset == null ? encodingName : charset.name());
+
+ // skip past the coding error
+ inbuf.position(inbuf.position() + result.length());
+
+ // undo the flip() to prepare the output buffer
+ // for more translation
+ dest.position(dest.limit());
+ dest.limit(dest.capacity());
+ dest.put((char)0xfffd); // backward compatible
+ } else {
+ throw new AssertionError(result);
+ }
+ }
+ // unreached
+ }
+
+ public CharsetDecoder getDecoder(String encodingName, boolean ignoreEncodingErrors) {
+ Charset cs = (this.charset == null)
+ ? Charset.forName(encodingName)
+ : this.charset;
+ CharsetDecoder decoder = cs.newDecoder();
+
+ CodingErrorAction action;
+ if (ignoreEncodingErrors)
+ action = CodingErrorAction.REPLACE;
+ else
+ action = CodingErrorAction.REPORT;
+
+ return decoder
+ .onMalformedInput(action)
+ .onUnmappableCharacter(action);
+ }
+ // </editor-fold>
+
+ // <editor-fold defaultstate="collapsed" desc="ByteBuffers">
+ /**
+ * Make a byte buffer from an input stream.
+ * @param in the stream
+ * @return a byte buffer containing the contents of the stream
+ * @throws IOException if an error occurred while reading the stream
+ */
+ @SuppressWarnings("cast")
+ public ByteBuffer makeByteBuffer(InputStream in)
+ throws IOException {
+ int limit = in.available();
+ if (limit < 1024) limit = 1024;
+ ByteBuffer result = byteBufferCache.get(limit);
+ int position = 0;
+ while (in.available() != 0) {
+ if (position >= limit)
+ // expand buffer
+ result = ByteBuffer.
+ allocate(limit <<= 1).
+ put((ByteBuffer)result.flip());
+ int count = in.read(result.array(),
+ position,
+ limit - position);
+ if (count < 0) break;
+ result.position(position += count);
+ }
+ return (ByteBuffer)result.flip();
+ }
+
+ public void recycleByteBuffer(ByteBuffer bb) {
+ byteBufferCache.put(bb);
+ }
+
+ /**
+ * A single-element cache of direct byte buffers.
+ */
+ @SuppressWarnings("cast")
+ private static class ByteBufferCache {
+ private ByteBuffer cached;
+ ByteBuffer get(int capacity) {
+ if (capacity < 20480) capacity = 20480;
+ ByteBuffer result =
+ (cached != null && cached.capacity() >= capacity)
+ ? (ByteBuffer)cached.clear()
+ : ByteBuffer.allocate(capacity + capacity>>1);
+ cached = null;
+ return result;
+ }
+ void put(ByteBuffer x) {
+ cached = x;
+ }
+ }
+
+ private final ByteBufferCache byteBufferCache;
+ // </editor-fold>
+
+ // <editor-fold defaultstate="collapsed" desc="Content cache">
+ public CharBuffer getCachedContent(JavaFileObject file) {
+ ContentCacheEntry e = contentCache.get(file);
+ if (e == null)
+ return null;
+
+ if (!e.isValid(file)) {
+ contentCache.remove(file);
+ return null;
+ }
+
+ return e.getValue();
+ }
+
+ public void cache(JavaFileObject file, CharBuffer cb) {
+ contentCache.put(file, new ContentCacheEntry(file, cb));
+ }
+
+ public void flushCache(JavaFileObject file) {
+ contentCache.remove(file);
+ }
+
+ protected final Map<JavaFileObject, ContentCacheEntry> contentCache = new HashMap<>();
+
+ protected static class ContentCacheEntry {
+ final long timestamp;
+ final SoftReference<CharBuffer> ref;
+
+ ContentCacheEntry(JavaFileObject file, CharBuffer cb) {
+ this.timestamp = file.getLastModified();
+ this.ref = new SoftReference<>(cb);
+ }
+
+ boolean isValid(JavaFileObject file) {
+ return timestamp == file.getLastModified();
+ }
+
+ CharBuffer getValue() {
+ return ref.get();
+ }
+ }
+ // </editor-fold>
+
+ public static Kind getKind(Path path) {
+ return getKind(path.getFileName().toString());
+ }
+
+ public static Kind getKind(String name) {
+ if (name.endsWith(Kind.CLASS.extension))
+ return Kind.CLASS;
+ else if (name.endsWith(Kind.SOURCE.extension))
+ return Kind.SOURCE;
+ else if (name.endsWith(Kind.HTML.extension))
+ return Kind.HTML;
+ else
+ return Kind.OTHER;
+ }
+
+ protected static <T> T nullCheck(T o) {
+ return Objects.requireNonNull(o);
+ }
+
+ protected static <T> Collection<T> nullCheck(Collection<T> it) {
+ for (T t : it)
+ Objects.requireNonNull(t);
+ return it;
+ }
+}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileObject.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileObject.java Tue Apr 14 12:10:00 2015 -0700
@@ -38,7 +38,6 @@
import javax.tools.FileObject;
import javax.tools.JavaFileObject;
-import com.sun.tools.javac.util.BaseFileManager;
import com.sun.tools.javac.util.DefinedBy;
import com.sun.tools.javac.util.DefinedBy.Api;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JRTIndex.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JRTIndex.java Tue Apr 14 12:10:00 2015 -0700
@@ -48,7 +48,6 @@
import javax.tools.FileObject;
import com.sun.tools.javac.file.RelativePath.RelativeDirectory;
-import com.sun.tools.javac.nio.PathFileObject;
import com.sun.tools.javac.util.Context;
/**
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java Tue Apr 14 12:10:00 2015 -0700
@@ -63,8 +63,6 @@
import com.sun.tools.javac.file.RelativePath.RelativeDirectory;
import com.sun.tools.javac.file.RelativePath.RelativeFile;
-import com.sun.tools.javac.nio.PathFileObject;
-import com.sun.tools.javac.util.BaseFileManager;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.DefinedBy;
import com.sun.tools.javac.util.DefinedBy.Api;
@@ -73,8 +71,6 @@
import static javax.tools.StandardLocation.*;
-import static com.sun.tools.javac.util.BaseFileManager.getKind;
-
/**
* This class provides access to the source, class and other files
* used by the compiler and related tools.
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java Tue Apr 14 12:10:00 2015 -0700
@@ -108,37 +108,23 @@
// Locations can use Paths.get(URI.create("jrt:"))
static final Path JRT_MARKER_FILE = Paths.get("JRT_MARKER_FILE");
- public Locations() {
+ Locations() {
initHandlers();
}
// could replace Lint by "boolean warn"
- public void update(Log log, Lint lint, FSInfo fsInfo) {
+ void update(Log log, Lint lint, FSInfo fsInfo) {
this.log = log;
warn = lint.isEnabled(Lint.LintCategory.PATH);
this.fsInfo = fsInfo;
}
- public Collection<Path> bootClassPath() {
- return getLocation(PLATFORM_CLASS_PATH);
- }
-
- public boolean isDefaultBootClassPath() {
+ boolean isDefaultBootClassPath() {
BootClassPathLocationHandler h
= (BootClassPathLocationHandler) getHandler(PLATFORM_CLASS_PATH);
return h.isDefault();
}
- public Collection<Path> userClassPath() {
- return getLocation(CLASS_PATH);
- }
-
- public Collection<Path> sourcePath() {
- Collection<Path> p = getLocation(SOURCE_PATH);
- // TODO: this should be handled by the LocationHandler
- return p == null || p.isEmpty() ? null : p;
- }
-
/**
* Split a search path into its elements. Empty path elements will be ignored.
*
@@ -753,7 +739,7 @@
}
}
- public boolean handleOption(Option option, String value) {
+ boolean handleOption(Option option, String value) {
LocationHandler h = handlersForOption.get(option);
return (h == null ? false : h.handleOption(option, value));
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/PathFileObject.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,331 @@
+/*
+ * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.javac.file;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.net.URI;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.CharsetDecoder;
+import java.nio.file.Files;
+import java.nio.file.LinkOption;
+import java.nio.file.Path;
+import java.util.Objects;
+
+import javax.lang.model.element.Modifier;
+import javax.lang.model.element.NestingKind;
+import javax.tools.JavaFileObject;
+
+import com.sun.tools.javac.util.DefinedBy;
+import com.sun.tools.javac.util.DefinedBy.Api;
+
+
+/**
+ * Implementation of JavaFileObject using java.nio.file API.
+ *
+ * <p>PathFileObjects are, for the most part, straightforward wrappers around
+ * Path objects. The primary complexity is the support for "inferBinaryName".
+ * This is left as an abstract method, implemented by each of a number of
+ * different factory methods, which compute the binary name based on
+ * information available at the time the file object is created.
+ *
+ * <p><b>This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.</b>
+ */
+public abstract class PathFileObject implements JavaFileObject {
+ private final BaseFileManager fileManager;
+ private final Path path;
+
+ /**
+ * Create a PathFileObject within a directory, such that the binary name
+ * can be inferred from the relationship to the parent directory.
+ */
+ static PathFileObject createDirectoryPathFileObject(BaseFileManager fileManager,
+ final Path path, final Path dir) {
+ return new PathFileObject(fileManager, path) {
+ @Override
+ public String inferBinaryName(Iterable<? extends Path> paths) {
+ return toBinaryName(dir.relativize(path));
+ }
+ };
+ }
+
+ /**
+ * Create a PathFileObject in a file system such as a jar file, such that
+ * the binary name can be inferred from its position within the filesystem.
+ */
+ public static PathFileObject createJarPathFileObject(BaseFileManager fileManager,
+ final Path path) {
+ return new PathFileObject(fileManager, path) {
+ @Override
+ public String inferBinaryName(Iterable<? extends Path> paths) {
+ return toBinaryName(path);
+ }
+ };
+ }
+
+ /**
+ * Create a PathFileObject in a modular file system, such as jrt:, such that
+ * the binary name can be inferred from its position within the filesystem.
+ */
+ public static PathFileObject createJRTPathFileObject(BaseFileManager fileManager,
+ final Path path) {
+ return new PathFileObject(fileManager, path) {
+ @Override
+ public String inferBinaryName(Iterable<? extends Path> paths) {
+ // use subpath to ignore the leading component containing the module name
+ return toBinaryName(path.subpath(1, path.getNameCount()));
+ }
+ };
+ }
+
+ /**
+ * Create a PathFileObject whose binary name can be inferred from the
+ * relative path to a sibling.
+ */
+ static PathFileObject createSiblingPathFileObject(BaseFileManager fileManager,
+ final Path path, final String relativePath) {
+ return new PathFileObject(fileManager, path) {
+ @Override
+ public String inferBinaryName(Iterable<? extends Path> paths) {
+ return toBinaryName(relativePath, "/");
+ }
+ };
+ }
+
+ /**
+ * Create a PathFileObject whose binary name might be inferred from its
+ * position on a search path.
+ */
+ static PathFileObject createSimplePathFileObject(BaseFileManager fileManager,
+ final Path path) {
+ return new PathFileObject(fileManager, path) {
+ @Override
+ public String inferBinaryName(Iterable<? extends Path> paths) {
+ Path absPath = path.toAbsolutePath();
+ for (Path p: paths) {
+ Path ap = p.toAbsolutePath();
+ if (absPath.startsWith(ap)) {
+ try {
+ Path rp = ap.relativize(absPath);
+ if (rp != null) // maybe null if absPath same as ap
+ return toBinaryName(rp);
+ } catch (IllegalArgumentException e) {
+ // ignore this p if cannot relativize path to p
+ }
+ }
+ }
+ return null;
+ }
+ };
+ }
+
+ protected PathFileObject(BaseFileManager fileManager, Path path) {
+ this.fileManager = Objects.requireNonNull(fileManager);
+ this.path = Objects.requireNonNull(path);
+ }
+
+ public abstract String inferBinaryName(Iterable<? extends Path> paths);
+
+ /**
+ * Return the Path for this object.
+ * @return the Path for this object.
+ */
+ public Path getPath() {
+ return path;
+ }
+
+ @Override @DefinedBy(Api.COMPILER)
+ public Kind getKind() {
+ return BaseFileManager.getKind(path.getFileName().toString());
+ }
+
+ @Override @DefinedBy(Api.COMPILER)
+ public boolean isNameCompatible(String simpleName, Kind kind) {
+ Objects.requireNonNull(simpleName);
+ // null check
+ if (kind == Kind.OTHER && getKind() != kind) {
+ return false;
+ }
+ String sn = simpleName + kind.extension;
+ String pn = path.getFileName().toString();
+ if (pn.equals(sn)) {
+ return true;
+ }
+ if (pn.equalsIgnoreCase(sn)) {
+ try {
+ // allow for Windows
+ return path.toRealPath(LinkOption.NOFOLLOW_LINKS).getFileName().toString().equals(sn);
+ } catch (IOException e) {
+ }
+ }
+ return false;
+ }
+
+ @Override @DefinedBy(Api.COMPILER)
+ public NestingKind getNestingKind() {
+ return null;
+ }
+
+ @Override @DefinedBy(Api.COMPILER)
+ public Modifier getAccessLevel() {
+ return null;
+ }
+
+ @Override @DefinedBy(Api.COMPILER)
+ public URI toUri() {
+ return path.toUri();
+ }
+
+ @Override @DefinedBy(Api.COMPILER)
+ public String getName() {
+ return path.toString();
+ }
+
+ @Override @DefinedBy(Api.COMPILER)
+ public InputStream openInputStream() throws IOException {
+ return Files.newInputStream(path);
+ }
+
+ @Override @DefinedBy(Api.COMPILER)
+ public OutputStream openOutputStream() throws IOException {
+ fileManager.flushCache(this);
+ ensureParentDirectoriesExist();
+ return Files.newOutputStream(path);
+ }
+
+ @Override @DefinedBy(Api.COMPILER)
+ public Reader openReader(boolean ignoreEncodingErrors) throws IOException {
+ CharsetDecoder decoder = fileManager.getDecoder(fileManager.getEncodingName(), ignoreEncodingErrors);
+ return new InputStreamReader(openInputStream(), decoder);
+ }
+
+ @Override @DefinedBy(Api.COMPILER)
+ public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
+ CharBuffer cb = fileManager.getCachedContent(this);
+ if (cb == null) {
+ try (InputStream in = openInputStream()) {
+ ByteBuffer bb = fileManager.makeByteBuffer(in);
+ JavaFileObject prev = fileManager.log.useSource(this);
+ try {
+ cb = fileManager.decode(bb, ignoreEncodingErrors);
+ } finally {
+ fileManager.log.useSource(prev);
+ }
+ fileManager.recycleByteBuffer(bb);
+ if (!ignoreEncodingErrors) {
+ fileManager.cache(this, cb);
+ }
+ }
+ }
+ return cb;
+ }
+
+ @Override @DefinedBy(Api.COMPILER)
+ public Writer openWriter() throws IOException {
+ fileManager.flushCache(this);
+ ensureParentDirectoriesExist();
+ return new OutputStreamWriter(Files.newOutputStream(path), fileManager.getEncodingName());
+ }
+
+ @Override @DefinedBy(Api.COMPILER)
+ public long getLastModified() {
+ try {
+ return Files.getLastModifiedTime(path).toMillis();
+ } catch (IOException e) {
+ return -1;
+ }
+ }
+
+ @Override @DefinedBy(Api.COMPILER)
+ public boolean delete() {
+ try {
+ Files.delete(path);
+ return true;
+ } catch (IOException e) {
+ return false;
+ }
+ }
+
+ public boolean isSameFile(PathFileObject other) {
+ try {
+ return Files.isSameFile(path, other.path);
+ } catch (IOException e) {
+ return false;
+ }
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ return (other instanceof PathFileObject && path.equals(((PathFileObject) other).path));
+ }
+
+ @Override
+ public int hashCode() {
+ return path.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + "[" + path + "]";
+ }
+
+ private void ensureParentDirectoriesExist() throws IOException {
+ Path parent = path.getParent();
+ if (parent != null)
+ Files.createDirectories(parent);
+ }
+
+ private long size() {
+ try {
+ return Files.size(path);
+ } catch (IOException e) {
+ return -1;
+ }
+ }
+
+ protected static String toBinaryName(Path relativePath) {
+ return toBinaryName(relativePath.toString(),
+ relativePath.getFileSystem().getSeparator());
+ }
+
+ protected static String toBinaryName(String relativePath, String sep) {
+ return removeExtension(relativePath).replace(sep, ".");
+ }
+
+ protected static String removeExtension(String fileName) {
+ int lastDot = fileName.lastIndexOf(".");
+ return (lastDot == -1 ? fileName : fileName.substring(0, lastDot));
+ }
+}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java Tue Apr 14 12:10:00 2015 -0700
@@ -36,17 +36,17 @@
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-
import javax.tools.JavaFileManager;
import javax.tools.JavaFileObject;
-
+import com.sun.tools.javac.comp.Annotate;
+import com.sun.tools.javac.comp.Annotate.AnnotationTypeCompleter;
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.code.Lint.LintCategory;
import com.sun.tools.javac.code.Scope.WriteableScope;
import com.sun.tools.javac.code.Symbol.*;
import com.sun.tools.javac.code.Symtab;
import com.sun.tools.javac.code.Type.*;
-import com.sun.tools.javac.comp.Annotate;
+import com.sun.tools.javac.comp.Annotate.AnnotationTypeMetadata;
import com.sun.tools.javac.file.BaseFileObject;
import com.sun.tools.javac.jvm.ClassFile.NameAndType;
import com.sun.tools.javac.jvm.ClassFile.Version;
@@ -81,7 +81,7 @@
public static final int INITIAL_BUFFER_SIZE = 0x0fff0;
- Annotate annotate;
+ private final Annotate annotate;
/** Switch: verbose output.
*/
@@ -190,6 +190,18 @@
*/
Set<Name> warnedAttrs = new HashSet<>();
+ /**
+ * The prototype @Target Attribute.Compound if this class is an annotation annotated with
+ * @Target
+ */
+ CompoundAnnotationProxy target;
+
+ /**
+ * The prototype @Repetable Attribute.Compound if this class is an annotation annotated with
+ * @Repeatable
+ */
+ CompoundAnnotationProxy repeatable;
+
/** Get the ClassReader instance for this invocation. */
public static ClassReader instance(Context context) {
ClassReader instance = context.get(classReaderKey);
@@ -201,6 +213,7 @@
/** Construct a new class reader. */
protected ClassReader(Context context) {
context.put(classReaderKey, this);
+ annotate = Annotate.instance(context);
names = Names.instance(context);
syms = Symtab.instance(context);
types = Types.instance(context);
@@ -212,9 +225,8 @@
log = Log.instance(context);
Options options = Options.instance(context);
- annotate = Annotate.instance(context);
- verbose = options.isSet(VERBOSE);
- checkClassFile = options.isSet("-checkclassfile");
+ verbose = options.isSet(VERBOSE);
+ checkClassFile = options.isSet("-checkclassfile");
Source source = Source.instance(context);
allowSimplifiedVarargs = source.allowSimplifiedVarargs();
@@ -1304,6 +1316,13 @@
ListBuffer<CompoundAnnotationProxy> proxies = new ListBuffer<>();
for (int i = 0; i<numAttributes; i++) {
CompoundAnnotationProxy proxy = readCompoundAnnotation();
+
+ if (proxy.type.tsym == syms.annotationTargetType.tsym) {
+ target = proxy;
+ } else if (proxy.type.tsym == syms.repeatableType.tsym) {
+ repeatable = proxy;
+ }
+
proxies.append(proxy);
}
annotate.normal(new AnnotationCompleter(sym, proxies.toList()));
@@ -1705,8 +1724,11 @@
}
class AnnotationDeproxy implements ProxyVisitor {
- private ClassSymbol requestingOwner = currentOwner.kind == MTH
- ? currentOwner.enclClass() : (ClassSymbol)currentOwner;
+ private ClassSymbol requestingOwner;
+
+ AnnotationDeproxy(ClassSymbol owner) {
+ this.requestingOwner = owner;
+ }
List<Attribute.Compound> deproxyCompoundList(List<CompoundAnnotationProxy> pl) {
// also must fill in types!!!!
@@ -1855,19 +1877,19 @@
}
}
- class AnnotationDefaultCompleter extends AnnotationDeproxy implements Annotate.Worker {
+ class AnnotationDefaultCompleter extends AnnotationDeproxy implements Runnable {
final MethodSymbol sym;
final Attribute value;
final JavaFileObject classFile = currentClassFile;
- @Override
- public String toString() {
- return " ClassReader store default for " + sym.owner + "." + sym + " is " + value;
- }
+
AnnotationDefaultCompleter(MethodSymbol sym, Attribute value) {
+ super(currentOwner.kind == MTH
+ ? currentOwner.enclClass() : (ClassSymbol)currentOwner);
this.sym = sym;
this.value = value;
}
- // implement Annotate.Worker.run()
+
+ @Override
public void run() {
JavaFileObject previousClassFile = currentClassFile;
try {
@@ -1880,22 +1902,27 @@
currentClassFile = previousClassFile;
}
}
+
+ @Override
+ public String toString() {
+ return " ClassReader store default for " + sym.owner + "." + sym + " is " + value;
+ }
}
- class AnnotationCompleter extends AnnotationDeproxy implements Annotate.Worker {
+ class AnnotationCompleter extends AnnotationDeproxy implements Runnable {
final Symbol sym;
final List<CompoundAnnotationProxy> l;
final JavaFileObject classFile;
- @Override
- public String toString() {
- return " ClassReader annotate " + sym.owner + "." + sym + " with " + l;
- }
+
AnnotationCompleter(Symbol sym, List<CompoundAnnotationProxy> l) {
+ super(currentOwner.kind == MTH
+ ? currentOwner.enclClass() : (ClassSymbol)currentOwner);
this.sym = sym;
this.l = l;
this.classFile = currentClassFile;
}
- // implement Annotate.Worker.run()
+
+ @Override
public void run() {
JavaFileObject previousClassFile = currentClassFile;
try {
@@ -1910,6 +1937,11 @@
currentClassFile = previousClassFile;
}
}
+
+ @Override
+ public String toString() {
+ return " ClassReader annotate " + sym.owner + "." + sym + " with " + l;
+ }
}
class TypeAnnotationCompleter extends AnnotationCompleter {
@@ -2298,6 +2330,8 @@
currentClassFile = c.classfile;
warnedAttrs.clear();
filling = true;
+ target = null;
+ repeatable = null;
try {
bp = 0;
buf = readInputStream(buf, c.classfile.openInputStream());
@@ -2318,6 +2352,12 @@
Name name = missingTypeVariables.head.tsym.name;
throw badClassFile("undecl.type.var", name);
}
+
+ if ((c.flags_field & Flags.ANNOTATION) != 0) {
+ c.setAnnotationTypeMetadata(new AnnotationTypeMetadata(c, new CompleterDeproxy(c, target, repeatable)));
+ } else {
+ c.setAnnotationTypeMetadata(AnnotationTypeMetadata.notAnAnnotationType());
+ }
} catch (IOException ex) {
throw badClassFile("unable.to.access.file", ex.getMessage());
} catch (ArrayIndexOutOfBoundsException ex) {
@@ -2515,4 +2555,42 @@
return name.hashCode();
}
}
+
+ private class CompleterDeproxy implements AnnotationTypeCompleter {
+ ClassSymbol proxyOn;
+ CompoundAnnotationProxy target;
+ CompoundAnnotationProxy repeatable;
+
+ public CompleterDeproxy(ClassSymbol c, CompoundAnnotationProxy target,
+ CompoundAnnotationProxy repeatable)
+ {
+ this.proxyOn = c;
+ this.target = target;
+ this.repeatable = repeatable;
+ }
+
+ @Override
+ public void complete(ClassSymbol sym) {
+ Assert.check(proxyOn == sym);
+ Attribute.Compound theTarget = null, theRepeatable = null;
+ AnnotationDeproxy deproxy;
+
+ try {
+ if (target != null) {
+ deproxy = new AnnotationDeproxy(proxyOn);
+ theTarget = deproxy.deproxyCompound(target);
+ }
+
+ if (repeatable != null) {
+ deproxy = new AnnotationDeproxy(proxyOn);
+ theRepeatable = deproxy.deproxyCompound(repeatable);
+ }
+ } catch (Exception e) {
+ throw new CompletionFailure(sym, e.getMessage());
+ }
+
+ sym.getAnnotationTypeMetadata().setTarget(theTarget);
+ sym.getAnnotationTypeMetadata().setRepeatable(theRepeatable);
+ }
+ }
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Code.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Code.java Tue Apr 14 12:10:00 2015 -0700
@@ -497,13 +497,9 @@
case aaload: {
state.pop(1);// index
Type a = state.stack[state.stacksize-1];
+ Assert.check(!a.hasTag(BOT)); // null type as is cannot be indexed.
state.pop(1);
- //sometimes 'null type' is treated as a one-dimensional array type
- //see Gen.visitLiteral - we should handle this case accordingly
- Type stackType = a.hasTag(BOT) ?
- syms.objectType :
- types.erasure(types.elemtype(a));
- state.push(stackType); }
+ state.push(types.erasure(types.elemtype(a))); }
break;
case goto_:
markDead();
@@ -2166,7 +2162,11 @@
boolean keepLocalVariables = varDebugInfo ||
(var.sym.isExceptionParameter() && var.sym.hasTypeAnnotations());
if (!keepLocalVariables) return;
- if ((var.sym.flags() & Flags.SYNTHETIC) != 0) return;
+ //don't keep synthetic vars, unless they are lambda method parameters
+ boolean ignoredSyntheticVar = (var.sym.flags() & Flags.SYNTHETIC) != 0 &&
+ ((var.sym.owner.flags() & Flags.LAMBDA_METHOD) == 0 ||
+ (var.sym.flags() & Flags.PARAMETER) == 0);
+ if (ignoredSyntheticVar) return;
if (varBuffer == null)
varBuffer = new LocalVar[20];
else
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java Tue Apr 14 12:10:00 2015 -0700
@@ -75,6 +75,7 @@
private final Types types;
private final Lower lower;
private final Flow flow;
+ private final Annotate annotate;
/** Format of stackmap tables to be generated. */
private final Code.StackMapFormat stackMap;
@@ -142,6 +143,7 @@
}
this.jsrlimit = setjsrlimit;
this.useJsrLocally = false; // reset in visitTry
+ annotate = Annotate.instance(context);
}
/** Switches
@@ -1468,21 +1470,18 @@
int startpc, int endpc,
List<Integer> gaps) {
if (startpc != endpc) {
- List<JCExpression> subClauses = TreeInfo.isMultiCatch(tree) ?
- ((JCTypeUnion)tree.param.vartype).alternatives :
- List.of(tree.param.vartype);
+ List<Pair<List<Attribute.TypeCompound>, JCExpression>> catchTypeExprs
+ = catchTypesWithAnnotations(tree);
while (gaps.nonEmpty()) {
- for (JCExpression subCatch : subClauses) {
+ for (Pair<List<Attribute.TypeCompound>, JCExpression> subCatch1 : catchTypeExprs) {
+ JCExpression subCatch = subCatch1.snd;
int catchType = makeRef(tree.pos(), subCatch.type);
int end = gaps.head.intValue();
registerCatch(tree.pos(),
startpc, end, code.curCP(),
catchType);
- if (subCatch.type.isAnnotated()) {
- for (Attribute.TypeCompound tc :
- subCatch.type.getAnnotationMirrors()) {
+ for (Attribute.TypeCompound tc : subCatch1.fst) {
tc.position.setCatchInfo(catchType, startpc);
- }
}
}
gaps = gaps.tail;
@@ -1490,16 +1489,14 @@
gaps = gaps.tail;
}
if (startpc < endpc) {
- for (JCExpression subCatch : subClauses) {
+ for (Pair<List<Attribute.TypeCompound>, JCExpression> subCatch1 : catchTypeExprs) {
+ JCExpression subCatch = subCatch1.snd;
int catchType = makeRef(tree.pos(), subCatch.type);
registerCatch(tree.pos(),
startpc, endpc, code.curCP(),
catchType);
- if (subCatch.type.isAnnotated()) {
- for (Attribute.TypeCompound tc :
- subCatch.type.getAnnotationMirrors()) {
- tc.position.setCatchInfo(catchType, startpc);
- }
+ for (Attribute.TypeCompound tc : subCatch1.fst) {
+ tc.position.setCatchInfo(catchType, startpc);
}
}
}
@@ -1507,7 +1504,7 @@
code.statBegin(tree.pos);
code.markStatBegin();
int limit = code.nextreg;
- int exlocal = code.newLocal(exparam);
+ code.newLocal(exparam);
items.makeLocalItem(exparam).store();
code.statBegin(TreeInfo.firstStatPos(tree.body));
genStat(tree.body, env, CRT_BLOCK);
@@ -1515,6 +1512,30 @@
code.statBegin(TreeInfo.endPos(tree.body));
}
}
+ // where
+ List<Pair<List<Attribute.TypeCompound>, JCExpression>> catchTypesWithAnnotations(JCCatch tree) {
+ return TreeInfo.isMultiCatch(tree) ?
+ catchTypesWithAnnotationsFromMulticatch((JCTypeUnion)tree.param.vartype, tree.param.sym.getRawTypeAttributes()) :
+ List.of(new Pair<>(tree.param.sym.getRawTypeAttributes(), tree.param.vartype));
+ }
+ // where
+ List<Pair<List<Attribute.TypeCompound>, JCExpression>> catchTypesWithAnnotationsFromMulticatch(JCTypeUnion tree, List<TypeCompound> first) {
+ List<JCExpression> alts = tree.alternatives;
+ List<Pair<List<TypeCompound>, JCExpression>> res = List.of(new Pair<>(first, alts.head));
+ alts = alts.tail;
+
+ while(alts != null && alts.head != null) {
+ JCExpression alt = alts.head;
+ if (alt instanceof JCAnnotatedType) {
+ JCAnnotatedType a = (JCAnnotatedType)alt;
+ res = res.prepend(new Pair<>(annotate.fromAnnotations(a.annotations), alt));
+ } else {
+ res = res.prepend(new Pair<>(List.nil(), alt));
+ }
+ alts = alts.tail;
+ }
+ return res.reverse();
+ }
/** Register a catch clause in the "Exceptions" code-attribute.
*/
@@ -1860,6 +1881,13 @@
public void visitAssign(JCAssign tree) {
Item l = genExpr(tree.lhs, tree.lhs.type);
genExpr(tree.rhs, tree.lhs.type).load();
+ if (tree.rhs.type.hasTag(BOT)) {
+ /* This is just a case of widening reference conversion that per 5.1.5 simply calls
+ for "regarding a reference as having some other type in a manner that can be proved
+ correct at compile time."
+ */
+ code.state.forceStackTop(tree.lhs.type);
+ }
result = items.makeAssignItem(l);
}
@@ -2045,7 +2073,7 @@
code.emitop2(new_, makeRef(pos, stringBufferType));
code.emitop0(dup);
callMethod(
- pos, stringBufferType, names.init, List.<Type>nil(), false);
+ pos, stringBufferType, names.init, List.<Type>nil(), false);
}
/** Append value (on tos) to string buffer (on tos - 1).
@@ -2093,11 +2121,11 @@
*/
void bufferToString(DiagnosticPosition pos) {
callMethod(
- pos,
- stringBufferType,
- names.toString,
- List.<Type>nil(),
- false);
+ pos,
+ stringBufferType,
+ names.toString,
+ List.<Type>nil(),
+ false);
}
/** Complete generating code for operation, with left operand
@@ -2272,12 +2300,7 @@
public void visitLiteral(JCLiteral tree) {
if (tree.type.hasTag(BOT)) {
code.emitop0(aconst_null);
- if (types.dimensions(pt) > 1) {
- code.emitop2(checkcast, makeRef(tree.pos(), pt));
- result = items.makeStackItem(pt);
- } else {
- result = items.makeStackItem(tree.type);
- }
+ result = items.makeStackItem(tree.type);
}
else
result = items.makeImmediateItem(tree.type, tree.value);
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/UninitializedType.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/UninitializedType.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -59,7 +59,7 @@
}
@Override
- public UninitializedType clone(final TypeMetadata md) {
+ public UninitializedType cloneWithMetadata(final TypeMetadata md) {
return new UninitializedType(tag, qtype, offset, md);
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java Tue Apr 14 12:10:00 2015 -0700
@@ -42,7 +42,7 @@
import com.sun.tools.javac.jvm.Profile;
import com.sun.tools.javac.jvm.Target;
import com.sun.tools.javac.main.OptionHelper.GrumpyHelper;
-import com.sun.tools.javac.util.BaseFileManager;
+import com.sun.tools.javac.file.BaseFileManager;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.ListBuffer;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java Tue Apr 14 12:10:00 2015 -0700
@@ -39,6 +39,7 @@
import com.sun.tools.javac.api.BasicJavacTask;
import com.sun.tools.javac.file.CacheFSInfo;
+import com.sun.tools.javac.file.BaseFileManager;
import com.sun.tools.javac.file.JavacFileManager;
import com.sun.tools.javac.processing.AnnotationProcessingError;
import com.sun.tools.javac.util.*;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacTypes.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacTypes.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,11 +25,13 @@
package com.sun.tools.javac.model;
+import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
+import java.util.stream.Collectors;
import javax.lang.model.element.*;
import javax.lang.model.type.*;
@@ -115,14 +117,17 @@
@DefinedBy(Api.LANGUAGE_MODEL)
public List<Type> directSupertypes(TypeMirror t) {
validateTypeNotIn(t, EXEC_OR_PKG);
- return types.directSupertypes((Type) t);
+ Type ty = (Type)t;
+ return types.directSupertypes(ty).stream()
+ .map(Type::stripMetadataIfNeeded)
+ .collect(Collectors.toList());
}
@DefinedBy(Api.LANGUAGE_MODEL)
public TypeMirror erasure(TypeMirror t) {
if (t.getKind() == TypeKind.PACKAGE)
throw new IllegalArgumentException(t.toString());
- return types.erasure((Type) t);
+ return types.erasure((Type)t).stripMetadataIfNeeded();
}
@DefinedBy(Api.LANGUAGE_MODEL)
@@ -143,7 +148,7 @@
@DefinedBy(Api.LANGUAGE_MODEL)
public TypeMirror capture(TypeMirror t) {
validateTypeNotIn(t, EXEC_OR_PKG);
- return types.capture((Type) t);
+ return types.capture((Type)t).stripMetadataIfNeeded();
}
@DefinedBy(Api.LANGUAGE_MODEL)
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,547 +0,0 @@
-/*
- * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.tools.javac.nio;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.nio.charset.Charset;
-import java.nio.file.FileSystem;
-import java.nio.file.FileSystems;
-import java.nio.file.FileVisitOption;
-import java.nio.file.FileVisitResult;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.SimpleFileVisitor;
-import java.nio.file.attribute.BasicFileAttributes;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.lang.model.SourceVersion;
-import javax.tools.FileObject;
-import javax.tools.JavaFileManager;
-import javax.tools.JavaFileObject;
-import javax.tools.JavaFileObject.Kind;
-import javax.tools.StandardLocation;
-
-import com.sun.tools.javac.util.BaseFileManager;
-import com.sun.tools.javac.util.Context;
-import com.sun.tools.javac.util.DefinedBy;
-import com.sun.tools.javac.util.DefinedBy.Api;
-import com.sun.tools.javac.util.List;
-import com.sun.tools.javac.util.ListBuffer;
-
-import static java.nio.file.FileVisitOption.*;
-
-import static javax.tools.StandardLocation.*;
-
-import static com.sun.tools.javac.main.Option.*;
-
-
-// NOTE the imports carefully for this compilation unit.
-//
-// Path: java.nio.file.Path -- the new NIO type for which this file manager exists
-//
-// Paths: com.sun.tools.javac.file.Paths -- legacy javac type for handling path options
-// The other Paths (java.nio.file.Paths) is not used
-
-// NOTE this and related classes depend on new API in JDK 7.
-// This requires special handling while bootstrapping the JDK build,
-// when these classes might not yet have been compiled. To workaround
-// this, the build arranges to make stubs of these classes available
-// when compiling this and related classes. The set of stub files
-// is specified in make/build.properties.
-
-/**
- * Implementation of PathFileManager: a JavaFileManager based on the use
- * of java.nio.file.Path.
- *
- * <p>Just as a Path is somewhat analagous to a File, so too is this
- * JavacPathFileManager analogous to JavacFileManager, as it relates to the
- * support of FileObjects based on File objects (i.e. just RegularFileObject,
- * not ZipFileObject and its variants.)
- *
- * <p>The default values for the standard locations supported by this file
- * manager are the same as the default values provided by JavacFileManager --
- * i.e. as determined by the javac.file.Paths class. To override these values,
- * call {@link #setLocation}.
- *
- * <p>To reduce confusion with Path objects, the locations such as "class path",
- * "source path", etc, are generically referred to here as "search paths".
- *
- * <p><b>This is NOT part of any supported API.
- * If you write code that depends on this, you do so at your own risk.
- * This code and its internal interfaces are subject to change or
- * deletion without notice.</b>
- */
-public class JavacPathFileManager extends BaseFileManager implements PathFileManager {
- protected FileSystem defaultFileSystem;
-
- /**
- * Create a JavacPathFileManager using a given context, optionally registering
- * it as the JavaFileManager for that context.
- */
- public JavacPathFileManager(Context context, boolean register, Charset charset) {
- super(charset);
- if (register)
- context.put(JavaFileManager.class, this);
- pathsForLocation = new HashMap<>();
- fileSystems = new HashMap<>();
- setContext(context);
- }
-
- /**
- * Set the context for JavacPathFileManager.
- */
- @Override
- public void setContext(Context context) {
- super.setContext(context);
- }
-
- @Override
- public FileSystem getDefaultFileSystem() {
- if (defaultFileSystem == null)
- defaultFileSystem = FileSystems.getDefault();
- return defaultFileSystem;
- }
-
- @Override
- public void setDefaultFileSystem(FileSystem fs) {
- defaultFileSystem = fs;
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public void flush() throws IOException {
- contentCache.clear();
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public void close() throws IOException {
- for (FileSystem fs: fileSystems.values())
- fs.close();
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public ClassLoader getClassLoader(Location location) {
- nullCheck(location);
- Iterable<? extends Path> path = getLocation(location);
- if (path == null)
- return null;
- ListBuffer<URL> lb = new ListBuffer<>();
- for (Path p: path) {
- try {
- lb.append(p.toUri().toURL());
- } catch (MalformedURLException e) {
- throw new AssertionError(e);
- }
- }
-
- return getClassLoader(lb.toArray(new URL[lb.size()]));
- }
-
- // <editor-fold defaultstate="collapsed" desc="Location handling">
-
- @DefinedBy(Api.COMPILER)
- public boolean hasLocation(Location location) {
- return (getLocation(location) != null);
- }
-
- public Iterable<? extends Path> getLocation(Location location) {
- nullCheck(location);
- lazyInitSearchPaths();
- PathsForLocation path = pathsForLocation.get(location);
- if (path == null && !pathsForLocation.containsKey(location)) {
- setDefaultForLocation(location);
- path = pathsForLocation.get(location);
- }
- return path;
- }
-
- private Path getOutputLocation(Location location) {
- Iterable<? extends Path> paths = getLocation(location);
- return (paths == null ? null : paths.iterator().next());
- }
-
- public void setLocation(Location location, Iterable<? extends Path> searchPath)
- throws IOException
- {
- nullCheck(location);
- lazyInitSearchPaths();
- if (searchPath == null) {
- setDefaultForLocation(location);
- } else {
- if (location.isOutputLocation())
- checkOutputPath(searchPath);
- PathsForLocation pl = new PathsForLocation();
- for (Path p: searchPath)
- pl.add(p); // TODO -Xlint:path warn if path not found
- pathsForLocation.put(location, pl);
- }
- }
-
- private void checkOutputPath(Iterable<? extends Path> searchPath) throws IOException {
- Iterator<? extends Path> pathIter = searchPath.iterator();
- if (!pathIter.hasNext())
- throw new IllegalArgumentException("empty path for directory");
- Path path = pathIter.next();
- if (pathIter.hasNext())
- throw new IllegalArgumentException("path too long for directory");
- if (!isDirectory(path))
- throw new IOException(path + ": not a directory");
- }
-
- private void setDefaultForLocation(Location locn) {
- Collection<Path> files = null;
- if (locn instanceof StandardLocation) {
- switch ((StandardLocation) locn) {
- case CLASS_PATH:
- files = locations.userClassPath();
- break;
- case PLATFORM_CLASS_PATH:
- files = locations.bootClassPath();
- break;
- case SOURCE_PATH:
- files = locations.sourcePath();
- break;
- case CLASS_OUTPUT: {
- String arg = options.get(D);
- files = (arg == null ? null : Collections.singleton(Paths.get(arg)));
- break;
- }
- case SOURCE_OUTPUT: {
- String arg = options.get(S);
- files = (arg == null ? null : Collections.singleton(Paths.get(arg)));
- break;
- }
- }
- }
-
- PathsForLocation pl = new PathsForLocation();
- if (files != null) {
- for (Path f: files)
- pl.add(f);
- }
- if (!pl.isEmpty())
- pathsForLocation.put(locn, pl);
- }
-
- private void lazyInitSearchPaths() {
- if (!inited) {
- setDefaultForLocation(PLATFORM_CLASS_PATH);
- setDefaultForLocation(CLASS_PATH);
- setDefaultForLocation(SOURCE_PATH);
- inited = true;
- }
- }
- // where
- private boolean inited = false;
-
- private Map<Location, PathsForLocation> pathsForLocation;
-
- private static class PathsForLocation extends LinkedHashSet<Path> {
- private static final long serialVersionUID = 6788510222394486733L;
- }
-
- // </editor-fold>
-
- // <editor-fold defaultstate="collapsed" desc="FileObject handling">
-
- @Override
- public Path getPath(FileObject fo) {
- nullCheck(fo);
- if (!(fo instanceof PathFileObject))
- throw new IllegalArgumentException();
- return ((PathFileObject) fo).getPath();
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public boolean isSameFile(FileObject a, FileObject b) {
- nullCheck(a);
- nullCheck(b);
- if (!(a instanceof PathFileObject))
- throw new IllegalArgumentException("Not supported: " + a);
- if (!(b instanceof PathFileObject))
- throw new IllegalArgumentException("Not supported: " + b);
- return ((PathFileObject) a).isSameFile((PathFileObject) b);
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public Iterable<JavaFileObject> list(Location location,
- String packageName, Set<Kind> kinds, boolean recurse)
- throws IOException {
- // validatePackageName(packageName);
- nullCheck(packageName);
- nullCheck(kinds);
-
- Iterable<? extends Path> paths = getLocation(location);
- if (paths == null)
- return List.nil();
- ListBuffer<JavaFileObject> results = new ListBuffer<>();
-
- for (Path path : paths)
- list(path, packageName, kinds, recurse, results);
-
- return results.toList();
- }
-
- private void list(Path path, String packageName, final Set<Kind> kinds,
- boolean recurse, final ListBuffer<JavaFileObject> results)
- throws IOException {
- if (!Files.exists(path))
- return;
-
- final Path pathDir;
- if (isDirectory(path))
- pathDir = path;
- else {
- FileSystem fs = getFileSystem(path);
- if (fs == null)
- return;
- pathDir = fs.getRootDirectories().iterator().next();
- }
- String sep = path.getFileSystem().getSeparator();
- Path packageDir = packageName.isEmpty() ? pathDir
- : pathDir.resolve(packageName.replace(".", sep));
- if (!Files.exists(packageDir))
- return;
-
-/* Alternate impl of list, superceded by use of Files.walkFileTree */
-// Deque<Path> queue = new LinkedList<Path>();
-// queue.add(packageDir);
-//
-// Path dir;
-// while ((dir = queue.poll()) != null) {
-// DirectoryStream<Path> ds = dir.newDirectoryStream();
-// try {
-// for (Path p: ds) {
-// String name = p.getFileName().toString();
-// if (isDirectory(p)) {
-// if (recurse && SourceVersion.isIdentifier(name)) {
-// queue.add(p);
-// }
-// } else {
-// if (kinds.contains(getKind(name))) {
-// JavaFileObject fe =
-// PathFileObject.createDirectoryPathFileObject(this, p, pathDir);
-// results.append(fe);
-// }
-// }
-// }
-// } finally {
-// ds.close();
-// }
-// }
- int maxDepth = (recurse ? Integer.MAX_VALUE : 1);
- Set<FileVisitOption> opts = EnumSet.of(FOLLOW_LINKS);
- Files.walkFileTree(packageDir, opts, maxDepth,
- new SimpleFileVisitor<Path>() {
- @Override
- public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
- Path name = dir.getFileName();
- if (name == null || SourceVersion.isIdentifier(name.toString()))
- return FileVisitResult.CONTINUE;
- else
- return FileVisitResult.SKIP_SUBTREE;
- }
-
- @Override
- public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
- if (attrs.isRegularFile() && kinds.contains(getKind(file.getFileName().toString()))) {
- // WORKAROUND for .jimage files
- if (!file.isAbsolute())
- file = pathDir.resolve(file);
- JavaFileObject fe =
- PathFileObject.createDirectoryPathFileObject(
- JavacPathFileManager.this, file, pathDir);
- results.append(fe);
- }
- return FileVisitResult.CONTINUE;
- }
- });
- }
-
- @Override
- public Iterable<? extends JavaFileObject> getJavaFileObjectsFromPaths(
- Iterable<? extends Path> paths) {
- ArrayList<PathFileObject> result;
- if (paths instanceof Collection<?>)
- result = new ArrayList<>(((Collection<?>)paths).size());
- else
- result = new ArrayList<>();
- for (Path p: paths)
- result.add(PathFileObject.createSimplePathFileObject(this, nullCheck(p)));
- return result;
- }
-
- @Override
- public Iterable<? extends JavaFileObject> getJavaFileObjects(Path... paths) {
- return getJavaFileObjectsFromPaths(Arrays.asList(nullCheck(paths)));
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public JavaFileObject getJavaFileForInput(Location location,
- String className, Kind kind) throws IOException {
- return getFileForInput(location, getRelativePath(className, kind));
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public FileObject getFileForInput(Location location,
- String packageName, String relativeName) throws IOException {
- return getFileForInput(location, getRelativePath(packageName, relativeName));
- }
-
- private JavaFileObject getFileForInput(Location location, String relativePath)
- throws IOException {
- for (Path p: getLocation(location)) {
- if (isDirectory(p)) {
- Path f = resolve(p, relativePath);
- if (Files.exists(f))
- return PathFileObject.createDirectoryPathFileObject(this, f, p);
- } else {
- FileSystem fs = getFileSystem(p);
- if (fs != null) {
- Path file = getPath(fs, relativePath);
- if (Files.exists(file))
- return PathFileObject.createJarPathFileObject(this, file);
- }
- }
- }
- return null;
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public JavaFileObject getJavaFileForOutput(Location location,
- String className, Kind kind, FileObject sibling) throws IOException {
- return getFileForOutput(location, getRelativePath(className, kind), sibling);
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public FileObject getFileForOutput(Location location, String packageName,
- String relativeName, FileObject sibling)
- throws IOException {
- return getFileForOutput(location, getRelativePath(packageName, relativeName), sibling);
- }
-
- private JavaFileObject getFileForOutput(Location location,
- String relativePath, FileObject sibling) {
- Path dir = getOutputLocation(location);
- if (dir == null) {
- if (location == CLASS_OUTPUT) {
- Path siblingDir = null;
- if (sibling != null && sibling instanceof PathFileObject) {
- siblingDir = ((PathFileObject) sibling).getPath().getParent();
- }
- return PathFileObject.createSiblingPathFileObject(this,
- siblingDir.resolve(getBaseName(relativePath)),
- relativePath);
- } else if (location == SOURCE_OUTPUT) {
- dir = getOutputLocation(CLASS_OUTPUT);
- }
- }
-
- Path file;
- if (dir != null) {
- file = resolve(dir, relativePath);
- return PathFileObject.createDirectoryPathFileObject(this, file, dir);
- } else {
- file = getPath(getDefaultFileSystem(), relativePath);
- return PathFileObject.createSimplePathFileObject(this, file);
- }
-
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public String inferBinaryName(Location location, JavaFileObject fo) {
- nullCheck(fo);
- // Need to match the path semantics of list(location, ...)
- Iterable<? extends Path> paths = getLocation(location);
- if (paths == null) {
- return null;
- }
-
- if (!(fo instanceof PathFileObject))
- throw new IllegalArgumentException(fo.getClass().getName());
-
- return ((PathFileObject) fo).inferBinaryName(paths);
- }
-
- private FileSystem getFileSystem(Path p) throws IOException {
- FileSystem fs = fileSystems.get(p);
- if (fs == null) {
- fs = FileSystems.newFileSystem(p, null);
- fileSystems.put(p, fs);
- }
- return fs;
- }
-
- private Map<Path,FileSystem> fileSystems;
-
- // </editor-fold>
-
- // <editor-fold defaultstate="collapsed" desc="Utility methods">
-
- private static String getRelativePath(String className, Kind kind) {
- return className.replace(".", "/") + kind.extension;
- }
-
- private static String getRelativePath(String packageName, String relativeName) {
- return packageName.isEmpty()
- ? relativeName : packageName.replace(".", "/") + "/" + relativeName;
- }
-
- private static String getBaseName(String relativePath) {
- int lastSep = relativePath.lastIndexOf("/");
- return relativePath.substring(lastSep + 1); // safe if "/" not found
- }
-
- private static boolean isDirectory(Path path) throws IOException {
- BasicFileAttributes attrs = Files.readAttributes(path, BasicFileAttributes.class);
- return attrs.isDirectory();
- }
-
- private static Path getPath(FileSystem fs, String relativePath) {
- return fs.getPath(relativePath.replace("/", fs.getSeparator()));
- }
-
- private static Path resolve(Path base, String relativePath) {
- FileSystem fs = base.getFileSystem();
- Path rp = fs.getPath(relativePath.replace("/", fs.getSeparator()));
- return base.resolve(rp);
- }
-
- // </editor-fold>
-
-}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/nio/PathFileManager.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,126 +0,0 @@
-/*
- * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.tools.javac.nio;
-
-import java.io.IOException;
-import java.nio.file.FileSystem;
-import java.nio.file.FileSystems;
-import java.nio.file.Path;
-import javax.tools.FileObject;
-import javax.tools.JavaFileManager;
-import javax.tools.JavaFileObject;
-
-/**
- * File manager based on {@link java.nio.file.Path}.
- *
- * Eventually, this should be moved to javax.tools.
- * Also, JavaCompiler might reasonably provide a method getPathFileManager,
- * similar to {@link javax.tools.JavaCompiler#getStandardFileManager
- * getStandardFileManager}. However, would need to be handled carefully
- * as another forward reference from langtools to jdk.
- *
- * <p><b>This is NOT part of any supported API.
- * If you write code that depends on this, you do so at your own risk.
- * This code and its internal interfaces are subject to change or
- * deletion without notice.</b>
- */
-public interface PathFileManager extends JavaFileManager {
- /**
- * Get the default file system used to create paths. If no value has been
- * set, the default file system is {@link FileSystems#getDefault}.
- */
- FileSystem getDefaultFileSystem();
-
- /**
- * Set the default file system used to create paths.
- * @param fs the default file system used to create any new paths.
- */
- void setDefaultFileSystem(FileSystem fs);
-
- /**
- * Get file objects representing the given files.
- *
- * @param paths a list of paths
- * @return a list of file objects
- * @throws IllegalArgumentException if the list of paths includes
- * a directory
- */
- Iterable<? extends JavaFileObject> getJavaFileObjectsFromPaths(
- Iterable<? extends Path> paths);
-
- /**
- * Get file objects representing the given paths.
- * Convenience method equivalent to:
- *
- * <pre>
- * getJavaFileObjectsFromPaths({@linkplain java.util.Arrays#asList Arrays.asList}(paths))
- * </pre>
- *
- * @param paths an array of paths
- * @return a list of file objects
- * @throws IllegalArgumentException if the array of files includes
- * a directory
- * @throws NullPointerException if the given array contains null
- * elements
- */
- Iterable<? extends JavaFileObject> getJavaFileObjects(Path... paths);
-
- /**
- * Return the Path for a file object that has been obtained from this
- * file manager.
- *
- * @param fo A file object that has been obtained from this file manager.
- * @return The underlying Path object.
- * @throws IllegalArgumentException is the file object was not obtained from
- * from this file manager.
- */
- Path getPath(FileObject fo);
-
- /**
- * Get the search path associated with the given location.
- *
- * @param location a location
- * @return a list of paths or {@code null} if this location has no
- * associated search path
- * @see #setLocation
- */
- Iterable<? extends Path> getLocation(Location location);
-
- /**
- * Associate the given search path with the given location. Any
- * previous value will be discarded.
- *
- * @param location a location
- * @param searchPath a list of files, if {@code null} use the default
- * search path for this location
- * @see #getLocation
- * @throws IllegalArgumentException if location is an output
- * location and searchpath does not contain exactly one element
- * @throws IOException if location is an output location and searchpath
- * does not represent an existing directory
- */
- void setLocation(Location location, Iterable<? extends Path> searchPath) throws IOException;
-}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/nio/PathFileObject.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,331 +0,0 @@
-/*
- * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.tools.javac.nio;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Reader;
-import java.io.Writer;
-import java.net.URI;
-import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
-import java.nio.charset.CharsetDecoder;
-import java.nio.file.Files;
-import java.nio.file.LinkOption;
-import java.nio.file.Path;
-import java.util.Objects;
-import javax.lang.model.element.Modifier;
-import javax.lang.model.element.NestingKind;
-import javax.tools.JavaFileObject;
-
-import com.sun.tools.javac.util.BaseFileManager;
-import com.sun.tools.javac.util.DefinedBy;
-import com.sun.tools.javac.util.DefinedBy.Api;
-
-
-/**
- * Implementation of JavaFileObject using java.nio.file API.
- *
- * <p>PathFileObjects are, for the most part, straightforward wrappers around
- * Path objects. The primary complexity is the support for "inferBinaryName".
- * This is left as an abstract method, implemented by each of a number of
- * different factory methods, which compute the binary name based on
- * information available at the time the file object is created.
- *
- * <p><b>This is NOT part of any supported API.
- * If you write code that depends on this, you do so at your own risk.
- * This code and its internal interfaces are subject to change or
- * deletion without notice.</b>
- */
-public abstract class PathFileObject implements JavaFileObject {
- private final BaseFileManager fileManager;
- private final Path path;
-
- /**
- * Create a PathFileObject within a directory, such that the binary name
- * can be inferred from the relationship to the parent directory.
- */
- static PathFileObject createDirectoryPathFileObject(BaseFileManager fileManager,
- final Path path, final Path dir) {
- return new PathFileObject(fileManager, path) {
- @Override
- public String inferBinaryName(Iterable<? extends Path> paths) {
- return toBinaryName(dir.relativize(path));
- }
- };
- }
-
- /**
- * Create a PathFileObject in a file system such as a jar file, such that
- * the binary name can be inferred from its position within the filesystem.
- */
- public static PathFileObject createJarPathFileObject(BaseFileManager fileManager,
- final Path path) {
- return new PathFileObject(fileManager, path) {
- @Override
- public String inferBinaryName(Iterable<? extends Path> paths) {
- return toBinaryName(path);
- }
- };
- }
-
- /**
- * Create a PathFileObject in a modular file system, such as jrt:, such that
- * the binary name can be inferred from its position within the filesystem.
- */
- public static PathFileObject createJRTPathFileObject(BaseFileManager fileManager,
- final Path path) {
- return new PathFileObject(fileManager, path) {
- @Override
- public String inferBinaryName(Iterable<? extends Path> paths) {
- // use subpath to ignore the leading component containing the module name
- return toBinaryName(path.subpath(1, path.getNameCount()));
- }
- };
- }
-
- /**
- * Create a PathFileObject whose binary name can be inferred from the
- * relative path to a sibling.
- */
- static PathFileObject createSiblingPathFileObject(BaseFileManager fileManager,
- final Path path, final String relativePath) {
- return new PathFileObject(fileManager, path) {
- @Override
- public String inferBinaryName(Iterable<? extends Path> paths) {
- return toBinaryName(relativePath, "/");
- }
- };
- }
-
- /**
- * Create a PathFileObject whose binary name might be inferred from its
- * position on a search path.
- */
- static PathFileObject createSimplePathFileObject(BaseFileManager fileManager,
- final Path path) {
- return new PathFileObject(fileManager, path) {
- @Override
- public String inferBinaryName(Iterable<? extends Path> paths) {
- Path absPath = path.toAbsolutePath();
- for (Path p: paths) {
- Path ap = p.toAbsolutePath();
- if (absPath.startsWith(ap)) {
- try {
- Path rp = ap.relativize(absPath);
- if (rp != null) // maybe null if absPath same as ap
- return toBinaryName(rp);
- } catch (IllegalArgumentException e) {
- // ignore this p if cannot relativize path to p
- }
- }
- }
- return null;
- }
- };
- }
-
- protected PathFileObject(BaseFileManager fileManager, Path path) {
- this.fileManager = Objects.requireNonNull(fileManager);
- this.path = Objects.requireNonNull(path);
- }
-
- public abstract String inferBinaryName(Iterable<? extends Path> paths);
-
- /**
- * Return the Path for this object.
- * @return the Path for this object.
- */
- public Path getPath() {
- return path;
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public Kind getKind() {
- return BaseFileManager.getKind(path.getFileName().toString());
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public boolean isNameCompatible(String simpleName, Kind kind) {
- Objects.requireNonNull(simpleName);
- // null check
- if (kind == Kind.OTHER && getKind() != kind) {
- return false;
- }
- String sn = simpleName + kind.extension;
- String pn = path.getFileName().toString();
- if (pn.equals(sn)) {
- return true;
- }
- if (pn.equalsIgnoreCase(sn)) {
- try {
- // allow for Windows
- return path.toRealPath(LinkOption.NOFOLLOW_LINKS).getFileName().toString().equals(sn);
- } catch (IOException e) {
- }
- }
- return false;
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public NestingKind getNestingKind() {
- return null;
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public Modifier getAccessLevel() {
- return null;
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public URI toUri() {
- return path.toUri();
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public String getName() {
- return path.toString();
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public InputStream openInputStream() throws IOException {
- return Files.newInputStream(path);
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public OutputStream openOutputStream() throws IOException {
- fileManager.flushCache(this);
- ensureParentDirectoriesExist();
- return Files.newOutputStream(path);
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public Reader openReader(boolean ignoreEncodingErrors) throws IOException {
- CharsetDecoder decoder = fileManager.getDecoder(fileManager.getEncodingName(), ignoreEncodingErrors);
- return new InputStreamReader(openInputStream(), decoder);
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
- CharBuffer cb = fileManager.getCachedContent(this);
- if (cb == null) {
- try (InputStream in = openInputStream()) {
- ByteBuffer bb = fileManager.makeByteBuffer(in);
- JavaFileObject prev = fileManager.log.useSource(this);
- try {
- cb = fileManager.decode(bb, ignoreEncodingErrors);
- } finally {
- fileManager.log.useSource(prev);
- }
- fileManager.recycleByteBuffer(bb);
- if (!ignoreEncodingErrors) {
- fileManager.cache(this, cb);
- }
- }
- }
- return cb;
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public Writer openWriter() throws IOException {
- fileManager.flushCache(this);
- ensureParentDirectoriesExist();
- return new OutputStreamWriter(Files.newOutputStream(path), fileManager.getEncodingName());
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public long getLastModified() {
- try {
- return Files.getLastModifiedTime(path).toMillis();
- } catch (IOException e) {
- return -1;
- }
- }
-
- @Override @DefinedBy(Api.COMPILER)
- public boolean delete() {
- try {
- Files.delete(path);
- return true;
- } catch (IOException e) {
- return false;
- }
- }
-
- public boolean isSameFile(PathFileObject other) {
- try {
- return Files.isSameFile(path, other.path);
- } catch (IOException e) {
- return false;
- }
- }
-
- @Override
- public boolean equals(Object other) {
- return (other instanceof PathFileObject && path.equals(((PathFileObject) other).path));
- }
-
- @Override
- public int hashCode() {
- return path.hashCode();
- }
-
- @Override
- public String toString() {
- return getClass().getSimpleName() + "[" + path + "]";
- }
-
- private void ensureParentDirectoriesExist() throws IOException {
- Path parent = path.getParent();
- if (parent != null)
- Files.createDirectories(parent);
- }
-
- private long size() {
- try {
- return Files.size(path);
- } catch (IOException e) {
- return -1;
- }
- }
-
- protected static String toBinaryName(Path relativePath) {
- return toBinaryName(relativePath.toString(),
- relativePath.getFileSystem().getSeparator());
- }
-
- protected static String toBinaryName(String relativePath, String sep) {
- return removeExtension(relativePath).replace(sep, ".");
- }
-
- protected static String removeExtension(String fileName) {
- int lastDot = fileName.lastIndexOf(".");
- return (lastDot == -1 ? fileName : fileName.substring(0, lastDot));
- }
-}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/DocCommentParser.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/DocCommentParser.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -797,7 +797,7 @@
loop:
while (isIdentifierStart(ch)) {
int namePos = bp;
- Name name = readIdentifier();
+ Name name = readAttributeName();
skipWhitespace();
List<DCTree> value = null;
ValueKind vkind = ValueKind.EMPTY;
@@ -905,6 +905,14 @@
return names.fromChars(buf, start, bp - start);
}
+ protected Name readAttributeName() {
+ int start = bp;
+ nextChar();
+ while (bp < buflen && (Character.isUnicodeIdentifierPart(ch) || ch == '-'))
+ nextChar();
+ return names.fromChars(buf, start, bp - start);
+ }
+
protected Name readTagName() {
int start = bp;
nextChar();
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties Tue Apr 14 12:10:00 2015 -0700
@@ -2010,6 +2010,16 @@
compiler.misc.diamond.non.generic=\
cannot use ''<>'' with non-generic class {0}
+# 0: list of type, 1: message segment
+compiler.misc.diamond.invalid.arg=\
+ type argument {0} inferred for {1} is not allowed in this context\n\
+ inferred argument is not expressible in the Signature attribute
+
+# 0: list of type, 1: message segment
+compiler.misc.diamond.invalid.args=\
+ type arguments {0} inferred for {1} are not allowed in this context\n\
+ inferred arguments are not expressible in the Signature attribute
+
# 0: unused
compiler.misc.diamond.and.explicit.params=\
cannot use ''<>'' with explicit type parameters for constructor
@@ -2271,10 +2281,6 @@
compiler.misc.varargs.clash.with=\
{0} in {1} overrides {2} in {3}
-# 0: unused
-compiler.misc.diamond.and.anon.class=\
- cannot use ''<>'' with anonymous inner classes
-
# 0: symbol kind, 1: symbol, 2: symbol, 3: message segment
compiler.misc.inapplicable.method=\
{0} {1}.{2} is not applicable\n\
@@ -2284,6 +2290,11 @@
# Diagnostics for language feature changes
########################################
# 0: string
+compiler.misc.diamond.and.anon.class.not.supported.in.source=\
+ cannot use ''<>'' with anonymous inner classes in -source {0}\n\
+ (use -source 9 or higher to enable ''<>'' with anonymous inner classes)
+
+# 0: string
compiler.err.unsupported.binary.lit=\
binary literals are not supported in -source {0}\n\
(use -source 7 or higher to enable binary literals)
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -34,8 +34,6 @@
import javax.tools.JavaFileObject;
import com.sun.source.tree.*;
-import com.sun.source.tree.LambdaExpressionTree.BodyKind;
-import com.sun.source.tree.MemberReferenceTree.ReferenceMode;
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.code.Scope.*;
import com.sun.tools.javac.code.Symbol.*;
@@ -2502,12 +2500,6 @@
public JCTree annotationType;
public List<JCExpression> args;
-
- // Attribute.Compound if tag is ANNOTATION
- // Attribute.TypeCompound if tag is TYPE_ANNOTATION
- //
- // NOTE: This field is slated for removal in the future. Do
- // not use it for anything new.
public Attribute.Compound attribute;
protected JCAnnotation(Tag tag, JCTree annotationType, List<JCExpression> args) {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -190,6 +190,18 @@
}
}
+ /** Return true if the given tree represents a type elided anonymous class instance creation. */
+ public static boolean isAnonymousDiamond(JCTree tree) {
+ switch(tree.getTag()) {
+ case NEWCLASS: {
+ JCNewClass nc = (JCNewClass)tree;
+ return nc.def != null && isDiamond(nc.clazz);
+ }
+ case ANNOTATED_TYPE: return isAnonymousDiamond(((JCAnnotatedType)tree).underlyingType);
+ default: return false;
+ }
+ }
+
public static boolean isEnumInit(JCTree tree) {
switch (tree.getTag()) {
case VARDEF:
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/BaseFileManager.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,443 +0,0 @@
-/*
- * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.tools.javac.util;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStreamWriter;
-import java.lang.ref.SoftReference;
-import java.lang.reflect.Constructor;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
-import java.nio.charset.Charset;
-import java.nio.charset.CharsetDecoder;
-import java.nio.charset.CoderResult;
-import java.nio.charset.CodingErrorAction;
-import java.nio.charset.IllegalCharsetNameException;
-import java.nio.charset.UnsupportedCharsetException;
-import java.nio.file.Path;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-
-import javax.tools.JavaFileManager;
-import javax.tools.JavaFileObject;
-import javax.tools.JavaFileObject.Kind;
-
-import com.sun.tools.javac.code.Lint;
-import com.sun.tools.javac.code.Source;
-import com.sun.tools.javac.file.FSInfo;
-import com.sun.tools.javac.file.Locations;
-import com.sun.tools.javac.main.Option;
-import com.sun.tools.javac.main.OptionHelper;
-import com.sun.tools.javac.main.OptionHelper.GrumpyHelper;
-import com.sun.tools.javac.util.DefinedBy.Api;
-import com.sun.tools.javac.util.JCDiagnostic.SimpleDiagnosticPosition;
-
-/**
- * Utility methods for building a filemanager.
- * There are no references here to file-system specific objects such as
- * java.io.File or java.nio.file.Path.
- */
-public abstract class BaseFileManager implements JavaFileManager {
- protected BaseFileManager(Charset charset) {
- this.charset = charset;
- byteBufferCache = new ByteBufferCache();
- locations = createLocations();
- }
-
- /**
- * Set the context for JavacPathFileManager.
- * @param context the context containing items to be associated with the file manager
- */
- public void setContext(Context context) {
- log = Log.instance(context);
- options = Options.instance(context);
- classLoaderClass = options.get("procloader");
- locations.update(log, Lint.instance(context), FSInfo.instance(context));
- }
-
- protected Locations createLocations() {
- return new Locations();
- }
-
- /**
- * The log to be used for error reporting.
- */
- public Log log;
-
- /**
- * User provided charset (through javax.tools).
- */
- protected Charset charset;
-
- protected Options options;
-
- protected String classLoaderClass;
-
- protected Locations locations;
-
- /**
- * A flag for clients to use to indicate that this file manager should
- * be closed when it is no longer required.
- */
- public boolean autoClose;
-
- protected Source getSource() {
- String sourceName = options.get(Option.SOURCE);
- Source source = null;
- if (sourceName != null)
- source = Source.lookup(sourceName);
- return (source != null ? source : Source.DEFAULT);
- }
-
- protected ClassLoader getClassLoader(URL[] urls) {
- ClassLoader thisClassLoader = getClass().getClassLoader();
-
- // Allow the following to specify a closeable classloader
- // other than URLClassLoader.
-
- // 1: Allow client to specify the class to use via hidden option
- if (classLoaderClass != null) {
- try {
- Class<? extends ClassLoader> loader =
- Class.forName(classLoaderClass).asSubclass(ClassLoader.class);
- Class<?>[] constrArgTypes = { URL[].class, ClassLoader.class };
- Constructor<? extends ClassLoader> constr = loader.getConstructor(constrArgTypes);
- return constr.newInstance(urls, thisClassLoader);
- } catch (ReflectiveOperationException t) {
- // ignore errors loading user-provided class loader, fall through
- }
- }
- return new URLClassLoader(urls, thisClassLoader);
- }
-
- public boolean isDefaultBootClassPath() {
- return locations.isDefaultBootClassPath();
- }
-
- // <editor-fold defaultstate="collapsed" desc="Option handling">
- @Override @DefinedBy(Api.COMPILER)
- public boolean handleOption(String current, Iterator<String> remaining) {
- OptionHelper helper = new GrumpyHelper(log) {
- @Override
- public String get(Option option) {
- return options.get(option.getText());
- }
-
- @Override
- public void put(String name, String value) {
- options.put(name, value);
- }
-
- @Override
- public void remove(String name) {
- options.remove(name);
- }
-
- @Override
- public boolean handleFileManagerOption(Option option, String value) {
- return handleOption(option, value);
- }
- };
-
- for (Option o: javacFileManagerOptions) {
- if (o.matches(current)) {
- if (o.hasArg()) {
- if (remaining.hasNext()) {
- if (!o.process(helper, current, remaining.next()))
- return true;
- }
- } else {
- if (!o.process(helper, current))
- return true;
- }
- // operand missing, or process returned true
- throw new IllegalArgumentException(current);
- }
- }
-
- return false;
- }
- // where
- private static final Set<Option> javacFileManagerOptions =
- Option.getJavacFileManagerOptions();
-
- @Override @DefinedBy(Api.COMPILER)
- public int isSupportedOption(String option) {
- for (Option o : javacFileManagerOptions) {
- if (o.matches(option))
- return o.hasArg() ? 1 : 0;
- }
- return -1;
- }
-
- /**
- * Common back end for OptionHelper handleFileManagerOption.
- * @param option the option whose value to be set
- * @param value the value for the option
- * @return true if successful, and false otherwise
- */
- public boolean handleOption(Option option, String value) {
- return locations.handleOption(option, value);
- }
-
- /**
- * Call handleOption for collection of options and corresponding values.
- * @param map a collection of options and corresponding values
- * @return true if all the calls are successful
- */
- public boolean handleOptions(Map<Option, String> map) {
- boolean ok = true;
- for (Map.Entry<Option, String> e: map.entrySet())
- ok = ok & handleOption(e.getKey(), e.getValue());
- return ok;
- }
-
- // </editor-fold>
-
- // <editor-fold defaultstate="collapsed" desc="Encoding">
- private String defaultEncodingName;
- private String getDefaultEncodingName() {
- if (defaultEncodingName == null) {
- defaultEncodingName =
- new OutputStreamWriter(new ByteArrayOutputStream()).getEncoding();
- }
- return defaultEncodingName;
- }
-
- public String getEncodingName() {
- String encName = options.get(Option.ENCODING);
- if (encName == null)
- return getDefaultEncodingName();
- else
- return encName;
- }
-
- @SuppressWarnings("cast")
- public CharBuffer decode(ByteBuffer inbuf, boolean ignoreEncodingErrors) {
- String encodingName = getEncodingName();
- CharsetDecoder decoder;
- try {
- decoder = getDecoder(encodingName, ignoreEncodingErrors);
- } catch (IllegalCharsetNameException | UnsupportedCharsetException e) {
- log.error("unsupported.encoding", encodingName);
- return (CharBuffer)CharBuffer.allocate(1).flip();
- }
-
- // slightly overestimate the buffer size to avoid reallocation.
- float factor =
- decoder.averageCharsPerByte() * 0.8f +
- decoder.maxCharsPerByte() * 0.2f;
- CharBuffer dest = CharBuffer.
- allocate(10 + (int)(inbuf.remaining()*factor));
-
- while (true) {
- CoderResult result = decoder.decode(inbuf, dest, true);
- dest.flip();
-
- if (result.isUnderflow()) { // done reading
- // make sure there is at least one extra character
- if (dest.limit() == dest.capacity()) {
- dest = CharBuffer.allocate(dest.capacity()+1).put(dest);
- dest.flip();
- }
- return dest;
- } else if (result.isOverflow()) { // buffer too small; expand
- int newCapacity =
- 10 + dest.capacity() +
- (int)(inbuf.remaining()*decoder.maxCharsPerByte());
- dest = CharBuffer.allocate(newCapacity).put(dest);
- } else if (result.isMalformed() || result.isUnmappable()) {
- // bad character in input
-
- log.error(new SimpleDiagnosticPosition(dest.limit()),
- "illegal.char.for.encoding",
- charset == null ? encodingName : charset.name());
-
- // skip past the coding error
- inbuf.position(inbuf.position() + result.length());
-
- // undo the flip() to prepare the output buffer
- // for more translation
- dest.position(dest.limit());
- dest.limit(dest.capacity());
- dest.put((char)0xfffd); // backward compatible
- } else {
- throw new AssertionError(result);
- }
- }
- // unreached
- }
-
- public CharsetDecoder getDecoder(String encodingName, boolean ignoreEncodingErrors) {
- Charset cs = (this.charset == null)
- ? Charset.forName(encodingName)
- : this.charset;
- CharsetDecoder decoder = cs.newDecoder();
-
- CodingErrorAction action;
- if (ignoreEncodingErrors)
- action = CodingErrorAction.REPLACE;
- else
- action = CodingErrorAction.REPORT;
-
- return decoder
- .onMalformedInput(action)
- .onUnmappableCharacter(action);
- }
- // </editor-fold>
-
- // <editor-fold defaultstate="collapsed" desc="ByteBuffers">
- /**
- * Make a byte buffer from an input stream.
- * @param in the stream
- * @return a byte buffer containing the contents of the stream
- * @throws IOException if an error occurred while reading the stream
- */
- @SuppressWarnings("cast")
- public ByteBuffer makeByteBuffer(InputStream in)
- throws IOException {
- int limit = in.available();
- if (limit < 1024) limit = 1024;
- ByteBuffer result = byteBufferCache.get(limit);
- int position = 0;
- while (in.available() != 0) {
- if (position >= limit)
- // expand buffer
- result = ByteBuffer.
- allocate(limit <<= 1).
- put((ByteBuffer)result.flip());
- int count = in.read(result.array(),
- position,
- limit - position);
- if (count < 0) break;
- result.position(position += count);
- }
- return (ByteBuffer)result.flip();
- }
-
- public void recycleByteBuffer(ByteBuffer bb) {
- byteBufferCache.put(bb);
- }
-
- /**
- * A single-element cache of direct byte buffers.
- */
- @SuppressWarnings("cast")
- private static class ByteBufferCache {
- private ByteBuffer cached;
- ByteBuffer get(int capacity) {
- if (capacity < 20480) capacity = 20480;
- ByteBuffer result =
- (cached != null && cached.capacity() >= capacity)
- ? (ByteBuffer)cached.clear()
- : ByteBuffer.allocate(capacity + capacity>>1);
- cached = null;
- return result;
- }
- void put(ByteBuffer x) {
- cached = x;
- }
- }
-
- private final ByteBufferCache byteBufferCache;
- // </editor-fold>
-
- // <editor-fold defaultstate="collapsed" desc="Content cache">
- public CharBuffer getCachedContent(JavaFileObject file) {
- ContentCacheEntry e = contentCache.get(file);
- if (e == null)
- return null;
-
- if (!e.isValid(file)) {
- contentCache.remove(file);
- return null;
- }
-
- return e.getValue();
- }
-
- public void cache(JavaFileObject file, CharBuffer cb) {
- contentCache.put(file, new ContentCacheEntry(file, cb));
- }
-
- public void flushCache(JavaFileObject file) {
- contentCache.remove(file);
- }
-
- protected final Map<JavaFileObject, ContentCacheEntry> contentCache = new HashMap<>();
-
- protected static class ContentCacheEntry {
- final long timestamp;
- final SoftReference<CharBuffer> ref;
-
- ContentCacheEntry(JavaFileObject file, CharBuffer cb) {
- this.timestamp = file.getLastModified();
- this.ref = new SoftReference<>(cb);
- }
-
- boolean isValid(JavaFileObject file) {
- return timestamp == file.getLastModified();
- }
-
- CharBuffer getValue() {
- return ref.get();
- }
- }
- // </editor-fold>
-
- public static Kind getKind(Path path) {
- return getKind(path.getFileName().toString());
- }
-
- public static Kind getKind(String name) {
- if (name.endsWith(Kind.CLASS.extension))
- return Kind.CLASS;
- else if (name.endsWith(Kind.SOURCE.extension))
- return Kind.SOURCE;
- else if (name.endsWith(Kind.HTML.extension))
- return Kind.HTML;
- else
- return Kind.OTHER;
- }
-
- protected static <T> T nullCheck(T o) {
- return Objects.requireNonNull(o);
- }
-
- protected static <T> Collection<T> nullCheck(Collection<T> it) {
- for (T t : it)
- Objects.requireNonNull(t);
- return it;
- }
-}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -234,6 +234,8 @@
}
private boolean unique(TypeVar typevar) {
+ typevar = (TypeVar)typevar.stripMetadataIfNeeded();
+
int found = 0;
for (Type t : whereClauses.get(WhereClauseKind.TYPEVAR).keySet()) {
if (t.toString().equals(typevar.toString())) {
@@ -542,6 +544,7 @@
@Override
public Void visitTypeVar(TypeVar t, Void ignored) {
+ t = (TypeVar)t.stripMetadataIfNeeded();
if (indexOf(t, WhereClauseKind.TYPEVAR) == -1) {
//access the bound type and skip error types
Type bound = t.bound;
--- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFileFactory.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFileFactory.java Tue Apr 14 12:10:00 2015 -0700
@@ -56,17 +56,10 @@
DocFileFactory f = factories.get(configuration);
if (f == null) {
JavaFileManager fm = configuration.getFileManager();
- if (fm instanceof StandardJavaFileManager)
+ if (fm instanceof StandardJavaFileManager) {
f = new StandardDocFileFactory(configuration);
- else {
- try {
- Class<?> pathFileManagerClass =
- Class.forName("com.sun.tools.javac.nio.PathFileManager");
- if (pathFileManagerClass.isAssignableFrom(fm.getClass()))
- f = new PathDocFileFactory(configuration);
- } catch (Throwable t) {
- throw new IllegalStateException(t);
- }
+ } else {
+ throw new IllegalStateException();
}
factories.put(configuration, f);
}
--- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/util/PathDocFileFactory.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,320 +0,0 @@
-/*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.sun.tools.doclets.internal.toolkit.util;
-
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
-import java.io.Writer;
-import java.nio.file.DirectoryStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.tools.DocumentationTool;
-import javax.tools.FileObject;
-import javax.tools.JavaFileManager.Location;
-import javax.tools.JavaFileObject;
-import javax.tools.StandardLocation;
-
-import com.sun.tools.doclets.internal.toolkit.Configuration;
-import com.sun.tools.javac.nio.PathFileManager;
-
-
-/**
- * Implementation of DocFileFactory using a {@link PathFileManager}.
- *
- * <p><b>This is NOT part of any supported API.
- * If you write code that depends on this, you do so at your own risk.
- * This code and its internal interfaces are subject to change or
- * deletion without notice.</b>
- *
- * @since 1.8
- */
-class PathDocFileFactory extends DocFileFactory {
- private final PathFileManager fileManager;
- private final Path destDir;
-
- public PathDocFileFactory(Configuration configuration) {
- super(configuration);
- fileManager = (PathFileManager) configuration.getFileManager();
-
- if (!configuration.destDirName.isEmpty()
- || !fileManager.hasLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT)) {
- try {
- String dirName = configuration.destDirName.isEmpty() ? "." : configuration.destDirName;
- Path dir = fileManager.getDefaultFileSystem().getPath(dirName);
- fileManager.setLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(dir));
- } catch (IOException e) {
- throw new DocletAbortException(e);
- }
- }
-
- destDir = fileManager.getLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT).iterator().next();
- }
-
- public DocFile createFileForDirectory(String file) {
- return new StandardDocFile(fileManager.getDefaultFileSystem().getPath(file));
- }
-
- public DocFile createFileForInput(String file) {
- return new StandardDocFile(fileManager.getDefaultFileSystem().getPath(file));
- }
-
- public DocFile createFileForOutput(DocPath path) {
- return new StandardDocFile(DocumentationTool.Location.DOCUMENTATION_OUTPUT, path);
- }
-
- @Override
- Iterable<DocFile> list(Location location, DocPath path) {
- if (location != StandardLocation.SOURCE_PATH)
- throw new IllegalArgumentException();
-
- Set<DocFile> files = new LinkedHashSet<>();
- if (fileManager.hasLocation(location)) {
- for (Path f: fileManager.getLocation(location)) {
- if (Files.isDirectory(f)) {
- f = f.resolve(path.getPath());
- if (Files.exists(f))
- files.add(new StandardDocFile(f));
- }
- }
- }
- return files;
- }
-
- class StandardDocFile extends DocFile {
- private Path file;
-
- /** Create a StandardDocFile for a given file. */
- private StandardDocFile(Path file) {
- super(configuration);
- this.file = file;
- }
-
- /** Create a StandardDocFile for a given location and relative path. */
- private StandardDocFile(Location location, DocPath path) {
- super(configuration, location, path);
- this.file = destDir.resolve(path.getPath());
- }
-
- /** Open an input stream for the file. */
- public InputStream openInputStream() throws IOException {
- JavaFileObject fo = getJavaFileObjectForInput(file);
- return new BufferedInputStream(fo.openInputStream());
- }
-
- /**
- * Open an output stream for the file.
- * The file must have been created with a location of
- * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path.
- */
- public OutputStream openOutputStream() throws IOException, UnsupportedEncodingException {
- if (location != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
- throw new IllegalStateException();
-
- OutputStream out = getFileObjectForOutput(path).openOutputStream();
- return new BufferedOutputStream(out);
- }
-
- /**
- * Open an writer for the file, using the encoding (if any) given in the
- * doclet configuration.
- * The file must have been created with a location of
- * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path.
- */
- public Writer openWriter() throws IOException, UnsupportedEncodingException {
- if (location != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
- throw new IllegalStateException();
-
- OutputStream out = getFileObjectForOutput(path).openOutputStream();
- if (configuration.docencoding == null) {
- return new BufferedWriter(new OutputStreamWriter(out));
- } else {
- return new BufferedWriter(new OutputStreamWriter(out, configuration.docencoding));
- }
- }
-
- /** Return true if the file can be read. */
- public boolean canRead() {
- return Files.isReadable(file);
- }
-
- /** Return true if the file can be written. */
- public boolean canWrite() {
- return Files.isWritable(file);
- }
-
- /** Return true if the file exists. */
- public boolean exists() {
- return Files.exists(file);
- }
-
- /** Return the base name (last component) of the file name. */
- public String getName() {
- return file.getFileName().toString();
- }
-
- /** Return the file system path for this file. */
- public String getPath() {
- return file.toString();
- }
-
- /** Return true is file has an absolute path name. */
- public boolean isAbsolute() {
- return file.isAbsolute();
- }
-
- /** Return true is file identifies a directory. */
- public boolean isDirectory() {
- return Files.isDirectory(file);
- }
-
- /** Return true is file identifies a file. */
- public boolean isFile() {
- return Files.isRegularFile(file);
- }
-
- /** Return true if this file is the same as another. */
- public boolean isSameFile(DocFile other) {
- if (!(other instanceof StandardDocFile))
- return false;
-
- try {
- return Files.isSameFile(file, ((StandardDocFile) other).file);
- } catch (IOException e) {
- return false;
- }
- }
-
- /** If the file is a directory, list its contents. */
- public Iterable<DocFile> list() throws IOException {
- List<DocFile> files = new ArrayList<>();
- try (DirectoryStream<Path> ds = Files.newDirectoryStream(file)) {
- for (Path f: ds) {
- files.add(new StandardDocFile(f));
- }
- }
- return files;
- }
-
- /** Create the file as a directory, including any parent directories. */
- public boolean mkdirs() {
- try {
- Files.createDirectories(file);
- return true;
- } catch (IOException e) {
- return false;
- }
- }
-
- /**
- * Derive a new file by resolving a relative path against this file.
- * The new file will inherit the configuration and location of this file
- * If this file has a path set, the new file will have a corresponding
- * new path.
- */
- public DocFile resolve(DocPath p) {
- return resolve(p.getPath());
- }
-
- /**
- * Derive a new file by resolving a relative path against this file.
- * The new file will inherit the configuration and location of this file
- * If this file has a path set, the new file will have a corresponding
- * new path.
- */
- public DocFile resolve(String p) {
- if (location == null && path == null) {
- return new StandardDocFile(file.resolve(p));
- } else {
- return new StandardDocFile(location, path.resolve(p));
- }
- }
-
- /**
- * Resolve a relative file against the given output location.
- * @param locn Currently, only
- * {@link DocumentationTool.Location.DOCUMENTATION_OUTPUT} is supported.
- */
- public DocFile resolveAgainst(Location locn) {
- if (locn != DocumentationTool.Location.DOCUMENTATION_OUTPUT)
- throw new IllegalArgumentException();
- return new StandardDocFile(destDir.resolve(file));
- }
-
- /** Return a string to identify the contents of this object,
- * for debugging purposes.
- */
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("PathDocFile[");
- if (location != null)
- sb.append("locn:").append(location).append(",");
- if (path != null)
- sb.append("path:").append(path.getPath()).append(",");
- sb.append("file:").append(file);
- sb.append("]");
- return sb.toString();
- }
-
- private JavaFileObject getJavaFileObjectForInput(Path file) {
- return fileManager.getJavaFileObjects(file).iterator().next();
- }
-
- private FileObject getFileObjectForOutput(DocPath path) throws IOException {
- // break the path into a package-part and the rest, by finding
- // the position of the last '/' before an invalid character for a
- // package name, such as the "." before an extension or the "-"
- // in filenames like package-summary.html, doc-files or src-html.
- String p = path.getPath();
- int lastSep = -1;
- for (int i = 0; i < p.length(); i++) {
- char ch = p.charAt(i);
- if (ch == '/') {
- lastSep = i;
- } else if (i == lastSep + 1 && !Character.isJavaIdentifierStart(ch)
- || !Character.isJavaIdentifierPart(ch)) {
- break;
- }
- }
- String pkg = (lastSep == -1) ? "" : p.substring(0, lastSep);
- String rest = p.substring(lastSep + 1);
- return fileManager.getFileForOutput(location, pkg, rest, null);
- }
- }
-
-}
--- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/Start.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/Start.java Tue Apr 14 12:10:00 2015 -0700
@@ -42,7 +42,7 @@
import com.sun.tools.javac.file.JavacFileManager;
import com.sun.tools.javac.main.CommandLine;
import com.sun.tools.javac.main.Option;
-import com.sun.tools.javac.util.BaseFileManager;
+import com.sun.tools.javac.file.BaseFileManager;
import com.sun.tools.javac.util.ClientCodeException;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.List;
--- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/api/JavadocTool.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/api/JavadocTool.java Tue Apr 14 12:10:00 2015 -0700
@@ -46,7 +46,7 @@
import com.sun.tools.javac.api.ClientCodeWrapper;
import com.sun.tools.javac.file.JavacFileManager;
-import com.sun.tools.javac.util.BaseFileManager;
+import com.sun.tools.javac.file.BaseFileManager;
import com.sun.tools.javac.util.ClientCodeException;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.DefinedBy;
--- a/langtools/test/tools/javac/MethodParameters/LambdaTest.out Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/MethodParameters/LambdaTest.out Tue Apr 14 12:10:00 2015 -0700
@@ -2,6 +2,6 @@
LambdaTest.<init>()
LambdaTest.foo(i)
LambdaTest.lambda$static$1(x1/*synthetic*/)/*synthetic*/
-LambdaTest.lambda$null$0(final cap$0/*synthetic*/, x2/*synthetic*/)/*synthetic*/
+LambdaTest.lambda$null$0(final x1/*synthetic*/, x2/*synthetic*/)/*synthetic*/
static interface LambdaTest$I -- inner
LambdaTest$I.m(x)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T7040592/CoerceNullToMoreSpecificTypeTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7040592
+ * @summary Test that the assertion in State.forceStackTop does not fail at compile time.
+ */
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import org.w3c.dom.Element;
+
+public class CoerceNullToMoreSpecificTypeTest {
+ abstract class NodeImpl {
+ }
+
+ NodeImpl ownerNode;
+
+ public Element getElement() {
+ return (Element) (isOwned() ? ownerNode : null);
+ }
+
+ boolean isOwned() {
+ return true;
+ }
+
+ static void processArrays(boolean expectNulls, Object [] nulla, Object [][] nullaa) {
+ if (expectNulls) {
+ if (nulla != null || nullaa != null) {
+ throw new AssertionError("Null actual, but not null formal");
+ }
+ } else {
+ if (nulla.length != 123 || nullaa.length != 321)
+ throw new AssertionError("Wrong arrays received");
+ }
+ }
+
+ public static void main(String[] args) {
+ ArrayList<Class<?>> typeList = new ArrayList<>();
+ Field rf = null;
+ typeList.add((rf != null) ? rf.getType() : null);
+ processArrays(true, null, null);
+ processArrays(false, new Object[123], new Object[321][]);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T7040592/T7040592.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7040592
+ * @summary Verify that null can be assigned freely to array types without a checkcast
+ */
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.nio.file.Paths;
+
+public class T7040592 {
+
+ private static final String assertionErrorMsg =
+ "null should be assignable to array type without a checkcast";
+
+ public static void main(String[] args) {
+ new T7040592().run();
+ }
+
+ void run() {
+ check("-c", Paths.get(System.getProperty("test.classes"),
+ "T7040592_01.class").toString());
+ }
+
+ void check(String... params) {
+ StringWriter s;
+ String out;
+ try (PrintWriter pw = new PrintWriter(s = new StringWriter())) {
+ com.sun.tools.javap.Main.run(params, pw);
+ out = s.toString();
+ }
+ if (out.contains("checkcast")) {
+ throw new AssertionError(assertionErrorMsg);
+ }
+ }
+
+}
+
+class T7040592_01 {
+ static void handleArrays(Object [] a, Object [][] b, Object [][][] c) {
+ }
+ public static void main(String[] args) {
+ Object a[];
+ Object o = (a = null)[0];
+ Object b[][];
+ o = (b = null)[0][0];
+ Object c[][][];
+ o = (c = null)[0][0][0];
+ handleArrays(null, null, null);
+ }
+}
--- a/langtools/test/tools/javac/annotations/typeAnnotations/api/AnnotatedArrayOrder.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/api/AnnotatedArrayOrder.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
/*
* @test
+ * @bug 8031744
* @summary Checks the annotation types targeting array types
*/
@@ -34,7 +35,6 @@
import java.util.Map;
import java.util.HashMap;
import java.lang.annotation.*;
-import javax.tools.JavaFileManager;
import javax.tools.JavaFileObject;
import com.sun.source.tree.*;
import com.sun.source.util.JavacTask;
--- a/langtools/test/tools/javac/annotations/typeAnnotations/newlocations/BasicTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/newlocations/BasicTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 6843077 8006775
+ * @bug 6843077 8006775 8031744
* @summary random tests for new locations
* @author Matt Papi
* @compile BasicTest.java
@@ -41,12 +41,16 @@
@interface C {}
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
@interface D {}
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+@interface E {}
+@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
+@interface F {}
/**
* Tests basic JSR 308 parser functionality. We don't really care about what
* the parse tree looks like, just that these annotations can be parsed.
*/
-class BasicTest<T extends @A Object> extends @B LinkedList<T> implements @C List<T> {
+class BasicTest<@D T extends @A Object> extends @B LinkedList<@E T> implements @C List<@F T> {
void test() {
--- a/langtools/test/tools/javac/classfiles/attributes/innerclasses/InnerClassesInAnonymousClassTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/classfiles/attributes/innerclasses/InnerClassesInAnonymousClassTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8042251
+ * @bug 8042251 8062373
* @summary Testing InnerClasses_attribute of inner classes in anonymous class.
* @library /tools/lib /tools/javac/lib ../lib
* @build InnerClassesTestBase TestResult TestBase InMemoryFileManager ToolBox
@@ -73,6 +73,6 @@
public void getAdditionalFlags(Map<String, Set<String>> class2Flags, ClassType type, Modifier... flags) {
super.getAdditionalFlags(class2Flags, type, flags);
class2Flags.put("Anonymous", getFlags(currentClassType, Arrays.asList(flags)));
- class2Flags.put("1", new HashSet<>());
+ class2Flags.put("1", new HashSet<>() {});
}
}
--- a/langtools/test/tools/javac/diags/examples/CantAccessInnerClsConstr.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/diags/examples/CantAccessInnerClsConstr.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -21,9 +21,8 @@
* questions.
*/
-// key: compiler.err.prob.found.req
// key: compiler.misc.cant.access.inner.cls.constr
-// key: compiler.misc.invalid.mref
+// key: compiler.err.invalid.mref
class CantAccessInnerClsConstructor {
--- a/langtools/test/tools/javac/diags/examples/DiamondAndAnonClass.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/diags/examples/DiamondAndAnonClass.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2015 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -21,8 +21,10 @@
* questions.
*/
-// key: compiler.misc.diamond.and.anon.class
+// key: compiler.misc.diamond.and.anon.class.not.supported.in.source
// key: compiler.err.cant.apply.diamond.1
+// key: compiler.warn.source.no.bootclasspath
+// options: -source 8
import java.util.*;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/DiamondAndNonDenotableTypes.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.misc.diamond
+// key: compiler.err.cant.apply.diamond.1
+// key: compiler.misc.diamond.invalid.arg
+// key: compiler.misc.diamond.invalid.args
+
+import java.util.*;
+
+class DiamondAndNonDenotableType<T> {
+ DiamondAndNonDenotableType(T t) {}
+}
+
+class DiamondAndNonDenotableTypes<T, S> {
+ DiamondAndNonDenotableTypes(T t, S s) {}
+ void m() {
+ List<?> wl = null;
+ new DiamondAndNonDenotableTypes<>(wl, wl) {};
+ new DiamondAndNonDenotableType<>(wl) {};
+ };
+}
--- a/langtools/test/tools/javac/doctree/AttrTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/doctree/AttrTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 7021614
+ * @bug 7021614 8076026
* @summary extend com.sun.source API to support parsing javadoc comments
* @build DocCommentTester
* @run main DocCommentTester AttrTest.java
@@ -55,6 +55,30 @@
*/
/**
+ * <a name-test=hyphened>foo</a>
+ */
+ void hyphened_attr() { }
+/*
+DocComment[DOC_COMMENT, pos:1
+ firstSentence: 3
+ StartElement[START_ELEMENT, pos:1
+ name:a
+ attributes: 1
+ Attribute[ATTRIBUTE, pos:4
+ name: name-test
+ vkind: UNQUOTED
+ value: 1
+ Text[TEXT, pos:14, hyphened]
+ ]
+ ]
+ Text[TEXT, pos:23, foo]
+ EndElement[END_ELEMENT, pos:26, a]
+ body: empty
+ block tags: empty
+]
+*/
+
+ /**
* <a name="double_quoted">foo</a>
*/
void double_quoted_attr() { }
--- a/langtools/test/tools/javac/failover/CheckAttributedTree.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/failover/CheckAttributedTree.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 6970584 8006694
+ * @bug 6970584 8006694 8062373
* @summary assorted position errors in compiler syntax trees
* temporarily workaround combo tests are causing time out in several platforms
* @library ../lib
@@ -290,7 +290,7 @@
}
public void finished(TaskEvent e) { }
});
-
+ int i = 0;
try {
Iterable<? extends CompilationUnitTree> trees = task.parse();
// JavaCompiler c = JavaCompiler.instance(((JavacTaskImpl) task).getContext());
@@ -308,7 +308,7 @@
if (def.hasTag(CLASSDEF) &&
analyzedElems.contains(((JCTree.JCClassDecl)def).sym)) {
//System.err.println("Adding pair..." + cu.sourcefile + " " + ((JCTree.JCClassDecl) def).name);
- res.add(new Pair<>(cu, def));
+ res.add((i++ % 2) == 0 ? new Pair<>(cu, def) {} : new Pair<>(cu, def));
}
}
}
--- a/langtools/test/tools/javac/generics/diamond/6939780/T6939780.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/6939780/T6939780.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,11 +1,12 @@
/*
* @test /nodynamiccopyright/
- * @bug 6939780 7020044 8009459 8021338 8064365
+ * @bug 6939780 7020044 8009459 8021338 8064365 8062373
*
- * @summary add a warning to detect diamond sites
+ * @summary add a warning to detect diamond sites (including anonymous class instance creation at source >= 9)
* @author mcimadamore
* @compile/ref=T6939780_7.out -Xlint:-options -source 7 T6939780.java -XDrawDiagnostics -XDfind=diamond
- * @compile/ref=T6939780_8.out T6939780.java -XDrawDiagnostics -XDfind=diamond
+ * @compile/ref=T6939780_8.out -Xlint:-options -source 8 T6939780.java -XDrawDiagnostics -XDfind=diamond
+ * @compile/ref=T6939780_9.out -Xlint:-options -source 9 T6939780.java -XDrawDiagnostics -XDfind=diamond
*
*/
--- a/langtools/test/tools/javac/generics/diamond/6939780/T6939780_7.out Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/6939780/T6939780_7.out Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
-T6939780.java:21:28: compiler.warn.diamond.redundant.args
-T6939780.java:22:28: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
-T6939780.java:30:19: compiler.warn.diamond.redundant.args
-T6939780.java:31:19: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
+T6939780.java:22:28: compiler.warn.diamond.redundant.args
+T6939780.java:23:28: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
+T6939780.java:31:19: compiler.warn.diamond.redundant.args
+T6939780.java:32:19: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
4 warnings
--- a/langtools/test/tools/javac/generics/diamond/6939780/T6939780_8.out Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/6939780/T6939780_8.out Tue Apr 14 12:10:00 2015 -0700
@@ -1,7 +1,7 @@
-T6939780.java:20:33: compiler.warn.diamond.redundant.args
-T6939780.java:21:28: compiler.warn.diamond.redundant.args
-T6939780.java:22:28: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
-T6939780.java:29:19: compiler.warn.diamond.redundant.args
+T6939780.java:21:33: compiler.warn.diamond.redundant.args
+T6939780.java:22:28: compiler.warn.diamond.redundant.args
+T6939780.java:23:28: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
T6939780.java:30:19: compiler.warn.diamond.redundant.args
-T6939780.java:31:19: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
+T6939780.java:31:19: compiler.warn.diamond.redundant.args
+T6939780.java:32:19: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
6 warnings
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/6939780/T6939780_9.out Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,13 @@
+T6939780.java:21:33: compiler.warn.diamond.redundant.args
+T6939780.java:22:28: compiler.warn.diamond.redundant.args
+T6939780.java:23:28: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
+T6939780.java:24:33: compiler.warn.diamond.redundant.args
+T6939780.java:25:28: compiler.warn.diamond.redundant.args
+T6939780.java:26:28: compiler.warn.diamond.redundant.args
+T6939780.java:30:19: compiler.warn.diamond.redundant.args
+T6939780.java:31:19: compiler.warn.diamond.redundant.args
+T6939780.java:32:19: compiler.warn.diamond.redundant.args.1: T6939780.Foo<java.lang.Integer>, T6939780.Foo<java.lang.Number>
+T6939780.java:33:19: compiler.warn.diamond.redundant.args
+T6939780.java:34:19: compiler.warn.diamond.redundant.args
+T6939780.java:35:19: compiler.warn.diamond.redundant.args
+12 warnings
--- a/langtools/test/tools/javac/generics/diamond/6996914/T6996914a.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/6996914/T6996914a.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 6996914 7020044
+ * @bug 6996914 7020044 8062373
* @summary Diamond inference: problem when accessing protected constructor
* @run main T6996914a
*/
@@ -53,6 +53,17 @@
}
}
+ enum DiamondKind {
+ STANDARD("new Foo<>();"),
+ ANON("new Foo<>() {};");
+
+ String expr;
+
+ DiamondKind(String expr) {
+ this.expr = expr;
+ }
+ }
+
enum ConstructorKind {
PACKAGE(""),
PROTECTED("protected"),
@@ -93,14 +104,14 @@
final static String sourceStub =
"#I\n" +
"class Test {\n" +
- " Foo<String> fs = new Foo<>();\n" +
+ " Foo<String> fs = #D\n" +
"}\n";
String source;
- public ClientClass(PackageKind pk) {
+ public ClientClass(PackageKind pk, DiamondKind dk) {
super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
- source = sourceStub.replace("#I", pk.importDecl);
+ source = sourceStub.replace("#I", pk.importDecl).replace("#D", dk.expr);
}
@Override
@@ -112,20 +123,22 @@
public static void main(String... args) throws Exception {
for (PackageKind pk : PackageKind.values()) {
for (ConstructorKind ck : ConstructorKind.values()) {
- compileAndCheck(pk, ck);
+ for (DiamondKind dk : DiamondKind.values()) {
+ compileAndCheck(pk, ck, dk);
+ }
}
}
}
- static void compileAndCheck(PackageKind pk, ConstructorKind ck) throws Exception {
+ static void compileAndCheck(PackageKind pk, ConstructorKind ck, DiamondKind dk) throws Exception {
FooClass foo = new FooClass(pk, ck);
- ClientClass client = new ClientClass(pk);
+ ClientClass client = new ClientClass(pk, dk);
final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
ErrorListener el = new ErrorListener();
JavacTask ct = (JavacTask)tool.getTask(null, null, el,
null, null, Arrays.asList(foo, client));
ct.analyze();
- if (el.errors > 0 == check(pk, ck)) {
+ if (el.errors > 0 == check(pk, ck, dk)) {
String msg = el.errors > 0 ?
"Error compiling files" :
"No error when compiling files";
@@ -133,9 +146,10 @@
}
}
- static boolean check(PackageKind pk, ConstructorKind ck) {
+ static boolean check(PackageKind pk, ConstructorKind ck, DiamondKind dk) {
switch (pk) {
- case A: return ck == ConstructorKind.PUBLIC;
+ case A: return ck == ConstructorKind.PUBLIC ||
+ (ck == ConstructorKind.PROTECTED && dk == DiamondKind.ANON);
case DEFAULT: return ck != ConstructorKind.PRIVATE;
default: throw new AssertionError("Unknown package kind");
}
--- a/langtools/test/tools/javac/generics/diamond/6996914/T6996914b.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/6996914/T6996914b.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 6996914 7020044
+ * @bug 6996914 7020044 8062373
* @summary Diamond inference: problem when accessing protected constructor
* @compile T6996914b.java
*/
@@ -35,4 +35,5 @@
class Test {
Super<String,Integer> ssi1 = new Super<>(1, "", 2);
+ Super<String,Integer> ssi2 = new Super<>(1, "", 2) {};
}
--- a/langtools/test/tools/javac/generics/diamond/8065986/T8065986b.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/8065986/T8065986b.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,6 +1,6 @@
/*
* @test /nodynamiccopyright/
- * @bug 8065986
+ * @bug 8065986 8062373
*
* @summary Compiler fails to NullPointerException when calling super with Object<>()
* @compile/fail/ref=T8065986b.out T8065986b.java -XDrawDiagnostics
@@ -29,5 +29,12 @@
this(cond ? o1 : o2);
}
+ T8065986b(int x) {
+ this(new Object<>() {});
+ }
+
+ T8065986b(int x, int y) {
+ this(new ArrayList<>() {});
+ }
static void m() { }
}
--- a/langtools/test/tools/javac/generics/diamond/8065986/T8065986b.out Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/8065986/T8065986b.out Tue Apr 14 12:10:00 2015 -0700
@@ -1,6 +1,8 @@
T8065986b.java:13:24: compiler.err.cant.apply.diamond.1: java.lang.Object, (compiler.misc.diamond.non.generic: java.lang.Object)
-T8065986b.java:17:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, java.util.ArrayList<java.lang.Object>,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: java.util.ArrayList), (compiler.misc.infer.no.conforming.instance.exists: E, java.util.ArrayList<E>, boolean)))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch))}
-T8065986b.java:21:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, @435,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf: boolean))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch))}
-T8065986b.java:25:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, @516,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf: boolean))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch))}
-T8065986b.java:29:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, @603,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.type.in.conditional: (compiler.misc.inconvertible.types: java.lang.Object, boolean)))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch))}
-5 errors
+T8065986b.java:17:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, java.util.ArrayList<java.lang.Object>,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: java.util.ArrayList), (compiler.misc.infer.no.conforming.instance.exists: E, java.util.ArrayList<E>, boolean)))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: java.util.ArrayList), (compiler.misc.infer.no.conforming.instance.exists: E, java.util.ArrayList<E>, int)))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int,int), (compiler.misc.arg.length.mismatch))}
+T8065986b.java:21:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, @443,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf: boolean))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf: int))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int,int), (compiler.misc.arg.length.mismatch))}
+T8065986b.java:25:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, @524,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf: boolean))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf: int))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int,int), (compiler.misc.arg.length.mismatch))}
+T8065986b.java:29:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, @611,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.type.in.conditional: (compiler.misc.inconvertible.types: java.lang.Object, boolean)))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.type.in.conditional: (compiler.misc.inconvertible.types: java.lang.Object, int)))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int,int), (compiler.misc.arg.length.mismatch))}
+T8065986b.java:33:24: compiler.err.cant.apply.diamond.1: java.lang.Object, (compiler.misc.diamond.non.generic: java.lang.Object)
+T8065986b.java:37:9: compiler.err.cant.apply.symbols: kindname.constructor, T8065986b, java.util.ArrayList<java.lang.Object>,{(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: java.util.ArrayList), (compiler.misc.infer.no.conforming.instance.exists: E, java.util.ArrayList<E>, boolean)))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,boolean,boolean), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(boolean,java.lang.Object,java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: java.util.ArrayList), (compiler.misc.infer.no.conforming.instance.exists: E, java.util.ArrayList<E>, int)))),(compiler.misc.inapplicable.method: kindname.constructor, T8065986b, T8065986b(int,int), (compiler.misc.arg.length.mismatch))}
+7 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/MultipleInferenceHooksTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8062373
+ * @summary Test that <>(){} works fine without verify error when there are multiple post inference hooks.
+ */
+
+import java.util.Collections;
+import java.util.IdentityHashMap;
+import java.util.Set;
+
+public class MultipleInferenceHooksTest {
+ public static void main(String[] args) {
+ Set<String> result = Collections.newSetFromMap(new IdentityHashMap<>() {});
+ }
+}
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg01.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg01.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,6 +1,6 @@
/*
* @test /nodynamiccopyright/
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
*
* @summary Check that diamond fails when inference violates declared bounds
* (basic test with nested class, generic/non-generic constructors)
@@ -25,5 +25,16 @@
Neg01<? extends String> n6 = new Neg01<>("", "");
Neg01<?> n7 = new Neg01<>("", "");
Foo<? super String> n8 = new Neg01<>("", "");
+
+ Neg01<String> n9 = new Neg01<>("", ""){};
+ Neg01<? extends String> n10 = new Neg01<>("", ""){};
+ Neg01<?> n11 = new Neg01<>("", ""){};
+ Neg01<? super String> n12 = new Neg01<>("", ""){};
+
+ Neg01<String> n13 = new Neg01<>(""){};
+ Neg01<? extends String> n14 = new Neg01<>(""){};
+ Neg01<?> n15 = new Neg01<>(""){};
+ Neg01<? super String> n16 = new Neg01<>(""){};
+
}
}
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg01.out Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg01.out Tue Apr 14 12:10:00 2015 -0700
@@ -12,4 +12,18 @@
Neg01.java:26:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
Neg01.java:27:9: compiler.err.cant.resolve.location: kindname.class, Foo, , , (compiler.misc.location: kindname.class, Neg01<X>, null)
Neg01.java:27:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
-14 errors
+Neg01.java:29:15: compiler.err.not.within.bounds: java.lang.String, X
+Neg01.java:29:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:30:15: compiler.err.not.within.bounds: ? extends java.lang.String, X
+Neg01.java:30:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:31:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:32:15: compiler.err.not.within.bounds: ? super java.lang.String, X
+Neg01.java:32:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:34:15: compiler.err.not.within.bounds: java.lang.String, X
+Neg01.java:34:29: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:35:15: compiler.err.not.within.bounds: ? extends java.lang.String, X
+Neg01.java:35:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:36:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:37:15: compiler.err.not.within.bounds: ? super java.lang.String, X
+Neg01.java:37:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+28 errors
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg02.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg02.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,6 +1,6 @@
/*
* @test /nodynamiccopyright/
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
*
* @summary Check that diamond fails when inference violates declared bounds
* (test with nested class, qualified/simple type expressions)
@@ -26,6 +26,16 @@
Foo<? extends String> f6 = new Foo<>("", "");
Foo<?> f7 = new Foo<>("", "");
Foo<? super String> f8 = new Foo<>("", "");
+
+ Foo<String> f9 = new Foo<>(""){};
+ Foo<? extends String> f10 = new Foo<>(""){};
+ Foo<?> f11 = new Foo<>(""){};
+ Foo<? super String> f12 = new Foo<>(""){};
+
+ Foo<String> f13 = new Foo<>("", ""){};
+ Foo<? extends String> f14 = new Foo<>("", ""){};
+ Foo<?> f15 = new Foo<>("", ""){};
+ Foo<? super String> f16 = new Foo<>("", ""){};
}
void testQualified() {
@@ -38,5 +48,15 @@
Foo<? extends String> f6 = new Neg02.Foo<>("", "");
Foo<?> f7 = new Neg02.Foo<>("", "");
Foo<? super String> f8 = new Neg02.Foo<>("", "");
+
+ Foo<String> f9 = new Neg02.Foo<>(""){};
+ Foo<? extends String> f10 = new Neg02.Foo<>(""){};
+ Foo<?> f11 = new Neg02.Foo<>(""){};
+ Foo<? super String> f12 = new Neg02.Foo<>(""){};
+
+ Foo<String> f13 = new Neg02.Foo<>("", ""){};
+ Foo<? extends String> f14 = new Neg02.Foo<>("", ""){};
+ Foo<?> f15 = new Neg02.Foo<>("", ""){};
+ Foo<? super String> f16 = new Neg02.Foo<>("", ""){};
}
}
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg02.out Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg02.out Tue Apr 14 12:10:00 2015 -0700
@@ -12,18 +12,46 @@
Neg02.java:27:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
Neg02.java:28:13: compiler.err.not.within.bounds: ? super java.lang.String, X
Neg02.java:28:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:32:13: compiler.err.not.within.bounds: java.lang.String, X
-Neg02.java:32:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:33:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
-Neg02.java:33:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:34:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:35:13: compiler.err.not.within.bounds: ? super java.lang.String, X
-Neg02.java:35:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:37:13: compiler.err.not.within.bounds: java.lang.String, X
-Neg02.java:37:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:38:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
-Neg02.java:38:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:39:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:40:13: compiler.err.not.within.bounds: ? super java.lang.String, X
-Neg02.java:40:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-28 errors
+Neg02.java:30:13: compiler.err.not.within.bounds: java.lang.String, X
+Neg02.java:30:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:31:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
+Neg02.java:31:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:32:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:33:13: compiler.err.not.within.bounds: ? super java.lang.String, X
+Neg02.java:33:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:35:13: compiler.err.not.within.bounds: java.lang.String, X
+Neg02.java:35:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:36:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
+Neg02.java:36:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:37:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:38:13: compiler.err.not.within.bounds: ? super java.lang.String, X
+Neg02.java:38:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:42:13: compiler.err.not.within.bounds: java.lang.String, X
+Neg02.java:42:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:43:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
+Neg02.java:43:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:44:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:45:13: compiler.err.not.within.bounds: ? super java.lang.String, X
+Neg02.java:45:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:47:13: compiler.err.not.within.bounds: java.lang.String, X
+Neg02.java:47:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:48:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
+Neg02.java:48:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:49:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:50:13: compiler.err.not.within.bounds: ? super java.lang.String, X
+Neg02.java:50:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:52:13: compiler.err.not.within.bounds: java.lang.String, X
+Neg02.java:52:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:53:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
+Neg02.java:53:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:54:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:55:13: compiler.err.not.within.bounds: ? super java.lang.String, X
+Neg02.java:55:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:57:13: compiler.err.not.within.bounds: java.lang.String, X
+Neg02.java:57:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:58:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
+Neg02.java:58:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:59:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:60:13: compiler.err.not.within.bounds: ? super java.lang.String, X
+Neg02.java:60:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+56 errors
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg03.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg03.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,6 +1,6 @@
/*
* @test /nodynamiccopyright/
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
*
* @summary Check that diamond fails when inference violates declared bounds
* (test with inner class, qualified/simple type expressions)
@@ -26,6 +26,16 @@
Foo<? extends String> f6 = new Foo<>("", "");
Foo<?> f7 = new Foo<>("", "");
Foo<? super String> f8 = new Foo<>("", "");
+
+ Foo<String> f9 = new Foo<>(""){};
+ Foo<? extends String> f10 = new Foo<>(""){};
+ Foo<?> f11 = new Foo<>(""){};
+ Foo<? super String> f12 = new Foo<>(""){};
+
+ Foo<String> f13 = new Foo<>("", ""){};
+ Foo<? extends String> f14 = new Foo<>("", ""){};
+ Foo<?> f15 = new Foo<>("", ""){};
+ Foo<? super String> f16 = new Foo<>("", ""){};
}
void testQualified_1() {
@@ -38,6 +48,16 @@
Foo<? extends String> f6 = new Neg03<U>.Foo<>("", "");
Foo<?> f7 = new Neg03<U>.Foo<>("", "");
Foo<? super String> f8 = new Neg03<U>.Foo<>("", "");
+
+ Foo<String> f9 = new Neg03<U>.Foo<>(""){};
+ Foo<? extends String> f10 = new Neg03<U>.Foo<>(""){};
+ Foo<?> f11 = new Neg03<U>.Foo<>(""){};
+ Foo<? super String> f12 = new Neg03<U>.Foo<>(""){};
+
+ Foo<String> f13 = new Neg03<U>.Foo<>("", ""){};
+ Foo<? extends String> f14 = new Neg03<U>.Foo<>("", ""){};
+ Foo<?> f15 = new Neg03<U>.Foo<>("", ""){};
+ Foo<? super String> f16 = new Neg03<U>.Foo<>("", ""){};
}
void testQualified_2(Neg03<U> n) {
@@ -50,5 +70,15 @@
Foo<? extends String> f6 = n.new Foo<>("", "");
Foo<?> f7 = n.new Foo<>("", "");
Foo<? super String> f8 = n.new Foo<>("", "");
+
+ Foo<String> f9 = n.new Foo<>(""){};
+ Foo<? extends String> f10 = n.new Foo<>(""){};
+ Foo<?> f11 = n.new Foo<>(""){};
+ Foo<? super String> f12 = n.new Foo<>(""){};
+
+ Foo<String> f13 = n.new Foo<>("", ""){};
+ Foo<? extends String> f14 = n.new Foo<>("", ""){};
+ Foo<?> f15 = n.new Foo<>("", ""){};
+ Foo<? super String> f16 = n.new Foo<>("", ""){};
}
}
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg03.out Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg03.out Tue Apr 14 12:10:00 2015 -0700
@@ -12,32 +12,74 @@
Neg03.java:27:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
Neg03.java:28:13: compiler.err.not.within.bounds: ? super java.lang.String, V
Neg03.java:28:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:32:13: compiler.err.not.within.bounds: java.lang.String, V
-Neg03.java:32:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:33:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
-Neg03.java:33:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:34:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:35:13: compiler.err.not.within.bounds: ? super java.lang.String, V
-Neg03.java:35:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:37:13: compiler.err.not.within.bounds: java.lang.String, V
-Neg03.java:37:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:38:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
-Neg03.java:38:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:39:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:40:13: compiler.err.not.within.bounds: ? super java.lang.String, V
-Neg03.java:40:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:44:13: compiler.err.not.within.bounds: java.lang.String, V
-Neg03.java:44:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:45:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
-Neg03.java:45:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:46:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:47:13: compiler.err.not.within.bounds: ? super java.lang.String, V
-Neg03.java:47:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:49:13: compiler.err.not.within.bounds: java.lang.String, V
-Neg03.java:49:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:50:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
-Neg03.java:50:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:51:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:52:13: compiler.err.not.within.bounds: ? super java.lang.String, V
-Neg03.java:52:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-42 errors
+Neg03.java:30:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:30:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:31:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:31:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:32:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:33:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg03.java:33:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:35:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:35:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:36:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:36:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:37:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:38:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg03.java:38:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:42:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:42:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:43:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:43:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:44:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:45:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg03.java:45:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:47:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:47:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:48:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:48:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:49:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:50:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg03.java:50:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:52:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:52:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:53:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:53:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:54:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:55:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg03.java:55:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:57:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:57:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:58:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:58:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:59:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:60:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg03.java:60:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:64:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:64:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:65:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:65:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:66:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:67:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg03.java:67:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:69:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:69:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:70:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:70:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:71:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:72:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg03.java:72:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:74:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:74:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:75:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:75:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:76:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:77:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg03.java:77:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:79:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:79:29: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:80:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:80:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:81:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:82:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg03.java:82:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+84 errors
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg04.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg04.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,6 +1,6 @@
/*
* @test /nodynamiccopyright/
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
*
* @summary Check that diamond fails when inference violates declared bounds
* (test with local class, qualified/simple type expressions)
@@ -25,5 +25,15 @@
Foo<? extends String> n6 = new Foo<>("", "");
Foo<?> n7 = new Foo<>("", "");
Foo<? super String> n8 = new Foo<>("", "");
+
+ Foo<String> n9 = new Foo<>(""){};
+ Foo<? extends String> n10 = new Foo<>(""){};
+ Foo<?> n11 = new Foo<>(""){};
+ Foo<? super String> n12 = new Foo<>(""){};
+
+ Foo<String> n13 = new Foo<>("", ""){};
+ Foo<? extends String> n14 = new Foo<>("", ""){};
+ Foo<?> n15 = new Foo<>("", ""){};
+ Foo<? super String> n16 = new Foo<>("", ""){};
}
}
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg04.out Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg04.out Tue Apr 14 12:10:00 2015 -0700
@@ -12,4 +12,18 @@
Neg04.java:26:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
Neg04.java:27:13: compiler.err.not.within.bounds: ? super java.lang.String, V
Neg04.java:27:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
-14 errors
+Neg04.java:29:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg04.java:29:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:30:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg04.java:30:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:31:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:32:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg04.java:32:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:34:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg04.java:34:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:35:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg04.java:35:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:36:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:37:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg04.java:37:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+28 errors
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg05.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg05.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,6 +1,6 @@
/*
* @test /nodynamiccopyright/
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
*
* @summary Check that usage of rare types doesn't cause spurious diamond diagnostics
* @author mcimadamore
@@ -25,6 +25,16 @@
Neg05<?>.Foo<? extends String> f6 = new Neg05.Foo<>("", "");
Neg05<?>.Foo<?> f7 = new Neg05.Foo<>("", "");
Neg05<?>.Foo<? super String> f8 = new Neg05.Foo<>("", "");
+
+ Neg05<?>.Foo<String> f9 = new Neg05.Foo<>(""){};
+ Neg05<?>.Foo<? extends String> f10 = new Neg05.Foo<>(""){};
+ Neg05<?>.Foo<?> f11 = new Neg05.Foo<>(""){};
+ Neg05<?>.Foo<? super String> f12 = new Neg05.Foo<>(""){};
+
+ Neg05<?>.Foo<String> f13 = new Neg05.Foo<>("", ""){};
+ Neg05<?>.Foo<? extends String> f14 = new Neg05.Foo<>("", ""){};
+ Neg05<?>.Foo<?> f15 = new Neg05.Foo<>("", ""){};
+ Neg05<?>.Foo<? super String> f16 = new Neg05.Foo<>("", ""){};
}
void testRare_2(Neg05 n) {
@@ -37,5 +47,15 @@
Neg05<?>.Foo<? extends String> f6 = n.new Foo<>("", "");
Neg05<?>.Foo<?> f7 = n.new Foo<>("", "");
Neg05<?>.Foo<? super String> f8 = n.new Foo<>("", "");
+
+ Neg05<?>.Foo<String> f9 = n.new Foo<>(""){};
+ Neg05<?>.Foo<? extends String> f10 = n.new Foo<>(""){};
+ Neg05<?>.Foo<?> f11 = n.new Foo<>(""){};
+ Neg05<?>.Foo<? super String> f12 = n.new Foo<>(""){};
+
+ Neg05<?>.Foo<String> f13 = n.new Foo<>("", ""){};
+ Neg05<?>.Foo<? extends String> f14 = n.new Foo<>("", ""){};
+ Neg05<?>.Foo<?> f15 = n.new Foo<>("", ""){};
+ Neg05<?>.Foo<? super String> f16 = n.new Foo<>("", ""){};
}
}
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg05.out Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg05.out Tue Apr 14 12:10:00 2015 -0700
@@ -6,20 +6,52 @@
Neg05.java:25:58: compiler.err.improperly.formed.type.inner.raw.param
Neg05.java:26:43: compiler.err.improperly.formed.type.inner.raw.param
Neg05.java:27:56: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:31:37: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:31:44: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<java.lang.String>))
-Neg05.java:32:47: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:32:54: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<? extends java.lang.String>))
-Neg05.java:33:32: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:33:39: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<?>))
-Neg05.java:34:45: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:34:52: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<? super java.lang.String>))
-Neg05.java:36:37: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:36:44: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<java.lang.String>))
-Neg05.java:37:47: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:37:54: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<? extends java.lang.String>))
-Neg05.java:38:32: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:38:39: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<?>))
-Neg05.java:39:45: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:39:52: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<? super java.lang.String>))
-24 errors
+Neg05.java:29:48: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:29:35: compiler.err.cant.apply.symbol: kindname.constructor, , V, java.lang.String, kindname.class, compiler.misc.anonymous.class: <any>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, V))
+Neg05.java:30:59: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:30:46: compiler.err.cant.apply.symbol: kindname.constructor, , V, java.lang.String, kindname.class, compiler.misc.anonymous.class: <any>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, V))
+Neg05.java:31:44: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:31:31: compiler.err.cant.apply.symbol: kindname.constructor, , V, java.lang.String, kindname.class, compiler.misc.anonymous.class: <any>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, V))
+Neg05.java:32:57: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:32:44: compiler.err.cant.apply.symbol: kindname.constructor, , V, java.lang.String, kindname.class, compiler.misc.anonymous.class: <any>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, V))
+Neg05.java:34:49: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:34:36: compiler.err.cant.apply.symbol: kindname.constructor, , V,Z, java.lang.String,java.lang.String, kindname.class, compiler.misc.anonymous.class: <any>, (compiler.misc.infer.no.conforming.assignment.exists: Z, (compiler.misc.inconvertible.types: java.lang.String, V))
+Neg05.java:35:59: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:35:46: compiler.err.cant.apply.symbol: kindname.constructor, , V,Z, java.lang.String,java.lang.String, kindname.class, compiler.misc.anonymous.class: <any>, (compiler.misc.infer.no.conforming.assignment.exists: Z, (compiler.misc.inconvertible.types: java.lang.String, V))
+Neg05.java:36:44: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:36:31: compiler.err.cant.apply.symbol: kindname.constructor, , V,Z, java.lang.String,java.lang.String, kindname.class, compiler.misc.anonymous.class: <any>, (compiler.misc.infer.no.conforming.assignment.exists: Z, (compiler.misc.inconvertible.types: java.lang.String, V))
+Neg05.java:37:57: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:37:44: compiler.err.cant.apply.symbol: kindname.constructor, , V,Z, java.lang.String,java.lang.String, kindname.class, compiler.misc.anonymous.class: <any>, (compiler.misc.infer.no.conforming.assignment.exists: Z, (compiler.misc.inconvertible.types: java.lang.String, V))
+Neg05.java:41:37: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:41:44: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<java.lang.String>))
+Neg05.java:42:47: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:42:54: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<? extends java.lang.String>))
+Neg05.java:43:32: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:43:39: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<?>))
+Neg05.java:44:45: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:44:52: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<? super java.lang.String>))
+Neg05.java:46:37: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:46:44: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<java.lang.String>))
+Neg05.java:47:47: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:47:54: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<? extends java.lang.String>))
+Neg05.java:48:32: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:48:39: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<?>))
+Neg05.java:49:45: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:49:52: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<? super java.lang.String>))
+Neg05.java:51:37: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:51:44: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<java.lang.String>))
+Neg05.java:52:48: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:52:55: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<? extends java.lang.String>))
+Neg05.java:53:33: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:53:40: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<?>))
+Neg05.java:54:46: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:54:53: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V, Neg05.Foo<V>, Neg05<?>.Foo<? super java.lang.String>))
+Neg05.java:56:38: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:56:45: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<java.lang.String>))
+Neg05.java:57:48: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:57:55: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<? extends java.lang.String>))
+Neg05.java:58:33: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:58:40: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<?>))
+Neg05.java:59:46: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:59:53: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg05.Foo), (compiler.misc.infer.no.conforming.instance.exists: V,Z, Neg05.Foo<V>, Neg05<?>.Foo<? super java.lang.String>))
+56 errors
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg06.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg06.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,6 +1,6 @@
/*
* @test /nodynamiccopyright/
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
*
* @summary Check that diamond works where LHS is supertype of RHS (nilary constructor)
* @author mcimadamore
@@ -9,9 +9,13 @@
*/
class Neg06 {
+ interface ISuperFoo<X> {}
+ interface IFoo<X extends Number> extends ISuperFoo<X> {}
static class CSuperFoo<X> {}
static class CFoo<X extends Number> extends CSuperFoo<X> {}
+ ISuperFoo<String> isf = new IFoo<>() {};
CSuperFoo<String> csf1 = new CFoo<>();
+ CSuperFoo<String> csf2 = new CFoo<>() {};
}
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg06.out Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg06.out Tue Apr 14 12:10:00 2015 -0700
@@ -1,2 +1,6 @@
-Neg06.java:16:37: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.String, java.lang.Number))
-1 error
+Neg06.java:18:36: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.IFoo), (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.String, java.lang.Number))
+Neg06.java:18:28: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.anonymous.class: java.lang.Object, Neg06.ISuperFoo<java.lang.String>)
+Neg06.java:19:37: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.String, java.lang.Number))
+Neg06.java:20:37: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.incompatible.eq.upper.bounds: X, java.lang.String, java.lang.Number))
+Neg06.java:20:29: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.anonymous.class: <any>, Neg06.CSuperFoo<java.lang.String>)
+5 errors
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg07.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg07.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,6 +1,6 @@
/*
* @test /nodynamiccopyright/
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
*
* @summary Check that diamond works where LHS is supertype of RHS (1-ary constructor)
* @author mcimadamore
@@ -15,4 +15,5 @@
}
SuperFoo<String> sf1 = new Foo<>("");
+ SuperFoo<String> sf2 = new Foo<>("") {};
}
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg07.out Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg07.out Tue Apr 14 12:10:00 2015 -0700
@@ -1,2 +1,3 @@
Neg07.java:17:27: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg07.Foo), (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.String, java.lang.Number)
-1 error
+Neg07.java:18:27: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg07.Foo), (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.String, java.lang.Number)
+2 errors
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg09.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg09.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,10 +1,10 @@
/*
* @test /nodynamiccopyright/
- * @bug 7020044
+ * @bug 7020044 8062373
*
- * @summary Check that diamond is not allowed with anonymous inner class expressions
+ * @summary Check that diamond is not allowed with anonymous inner class expressions at source < 9
* @author Maurizio Cimadamore
- * @compile/fail/ref=Neg09.out Neg09.java -XDrawDiagnostics
+ * @compile/fail/ref=Neg09.out Neg09.java -source 8 -XDrawDiagnostics
*
*/
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg09.out Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg09.out Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,7 @@
-Neg09.java:17:34: compiler.err.cant.apply.diamond.1: Neg09.Member<X>, (compiler.misc.diamond.and.anon.class: Neg09.Member<X>)
-Neg09.java:18:34: compiler.err.cant.apply.diamond.1: Neg09.Nested<X>, (compiler.misc.diamond.and.anon.class: Neg09.Nested<X>)
-Neg09.java:22:39: compiler.err.cant.apply.diamond.1: Neg09.Member<X>, (compiler.misc.diamond.and.anon.class: Neg09.Member<X>)
-Neg09.java:23:40: compiler.err.cant.apply.diamond.1: Neg09.Nested<X>, (compiler.misc.diamond.and.anon.class: Neg09.Nested<X>)
+- compiler.warn.source.no.bootclasspath: 1.8
+Neg09.java:17:34: compiler.err.cant.apply.diamond.1: Neg09.Member<X>, (compiler.misc.diamond.and.anon.class.not.supported.in.source: 1.8)
+Neg09.java:18:34: compiler.err.cant.apply.diamond.1: Neg09.Nested<X>, (compiler.misc.diamond.and.anon.class.not.supported.in.source: 1.8)
+Neg09.java:22:39: compiler.err.cant.apply.diamond.1: Neg09.Member<X>, (compiler.misc.diamond.and.anon.class.not.supported.in.source: 1.8)
+Neg09.java:23:40: compiler.err.cant.apply.diamond.1: Neg09.Nested<X>, (compiler.misc.diamond.and.anon.class.not.supported.in.source: 1.8)
4 errors
+1 warning
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg12.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,33 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8062373
+ *
+ * @summary Test diamond + anonymous classes with non-denotable types
+ * @author mcimadamore
+ * @compile/fail/ref=Neg12.out Neg12.java -XDrawDiagnostics
+ *
+ */
+
+ class Neg12 {
+ static class Foo<X> {
+ Foo(X x) { }
+ }
+
+ static class DoubleFoo<X,Y> {
+ DoubleFoo(X x,Y y) { }
+ }
+
+ static class TripleFoo<X,Y,Z> {
+ TripleFoo(X x,Y y,Z z) { }
+ }
+
+ Foo<? extends Integer> fi = new Foo<>(1);
+ Foo<?> fw = new Foo<>(fi) {}; // Error.
+ Foo<?> fw1 = new Foo<>(fi); // OK.
+ Foo<? extends Double> fd = new Foo<>(3.0);
+ DoubleFoo<?,?> dw = new DoubleFoo<>(fi,fd) {}; // Error.
+ DoubleFoo<?,?> dw1 = new DoubleFoo<>(fi,fd); // OK.
+ Foo<String> fs = new Foo<>("one");
+ TripleFoo<?,?,?> tw = new TripleFoo<>(fi,fd,fs) {}; // Error.
+ TripleFoo<?,?,?> tw1 = new TripleFoo<>(fi,fd,fs); // OK.
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg12.out Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,4 @@
+Neg12.java:25:24: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg12.Foo), (compiler.misc.diamond.invalid.arg: Neg12.Foo<compiler.misc.type.captureof: 1, ? extends java.lang.Integer>, (compiler.misc.diamond: Neg12.Foo))
+Neg12.java:28:38: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg12.DoubleFoo), (compiler.misc.diamond.invalid.args: Neg12.Foo<compiler.misc.type.captureof: 1, ? extends java.lang.Integer>,Neg12.Foo<compiler.misc.type.captureof: 2, ? extends java.lang.Double>, (compiler.misc.diamond: Neg12.DoubleFoo))
+Neg12.java:31:40: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg12.TripleFoo), (compiler.misc.diamond.invalid.args: Neg12.Foo<compiler.misc.type.captureof: 1, ? extends java.lang.Integer>,Neg12.Foo<compiler.misc.type.captureof: 2, ? extends java.lang.Double>, (compiler.misc.diamond: Neg12.TripleFoo))
+3 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg13.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,49 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8062373
+ *
+ * @summary Test diamond + anonymous classes with abstract super type
+ * @author sadayapalam
+ * @compile/fail/ref=Neg13.out Neg13.java -XDrawDiagnostics
+ *
+ */
+class Neg13 {
+
+ static abstract class A<T> {
+ abstract void foo();
+ }
+
+ static void foo(A<String> as) {}
+
+ public static void main(String[] args) {
+
+ // Method invocation context - good <>(){}
+ foo(new A<>() {
+ public void foo() {}
+ });
+
+ // Assignment context - good <>(){}
+ A<?> aq = new A<>() {
+ public void foo() {}
+ };
+
+ // When the anonymous type subtypes an abstract class but is missing definitions for
+ // abstract methods, expect no overload resolution error, but an attribution error
+ // while attributing anonymous class body.
+
+
+ // Method invocation context - bad <>(){}
+ foo(new A<>() {
+ });
+
+ // Assignment invocation context - bad <>(){}
+ aq = new A<>() {
+ };
+
+ // Method invocation context - bad <>()
+ foo(new A<>());
+
+ // Assignment invocation context - bad <>()
+ aq = new A<>();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg13.out Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,5 @@
+Neg13.java:36:23: compiler.err.does.not.override.abstract: compiler.misc.anonymous.class: Neg13$3, foo(), Neg13.A
+Neg13.java:40:24: compiler.err.does.not.override.abstract: compiler.misc.anonymous.class: Neg13$4, foo(), Neg13.A
+Neg13.java:44:13: compiler.err.abstract.cant.be.instantiated: Neg13.A
+Neg13.java:47:14: compiler.err.abstract.cant.be.instantiated: Neg13.A
+4 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg14.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,49 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8062373
+ *
+ * @summary Test diamond + anonymous classes with super type being an interface.
+ * @author sadayapalam
+ * @compile/fail/ref=Neg14.out Neg14.java -XDrawDiagnostics
+ *
+ */
+class Neg14 {
+
+ static interface A<T> {
+ void foo();
+ }
+
+ static void foo(A<String> as) {}
+
+ public static void main(String[] args) {
+
+ // Method invocation context - good <>(){}
+ foo(new A<>() {
+ public void foo() {}
+ });
+
+ // Assignment context - good <>(){}
+ A<?> aq = new A<>() {
+ public void foo() {}
+ };
+
+ // When the anonymous type subtypes an interface but is missing definitions for
+ // abstract methods, expect no overload resolution error, but an attribution error
+ // while attributing anonymous class body.
+
+
+ // Method invocation context - bad <>(){}
+ foo(new A<>() {
+ });
+
+ // Assignment invocation context - bad <>(){}
+ aq = new A<>() {
+ };
+
+ // Method invocation context - bad <>()
+ foo(new A<>());
+
+ // Assignment invocation context - bad <>()
+ aq = new A<>();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg14.out Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,5 @@
+Neg14.java:36:23: compiler.err.does.not.override.abstract: compiler.misc.anonymous.class: Neg14$3, foo(), Neg14.A
+Neg14.java:40:24: compiler.err.does.not.override.abstract: compiler.misc.anonymous.class: Neg14$4, foo(), Neg14.A
+Neg14.java:44:13: compiler.err.abstract.cant.be.instantiated: Neg14.A
+Neg14.java:47:14: compiler.err.abstract.cant.be.instantiated: Neg14.A
+4 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg15.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,66 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8062373
+ *
+ * @summary Test that javac complains when a <> inferred class contains a public method that does override a supertype method.
+ * @author sadayapalam
+ * @compile/fail/ref=Neg15.out Neg15.java -XDrawDiagnostics
+ *
+ */
+
+class Neg15 {
+
+ interface Predicate<T> {
+ default boolean test(T t) {
+ System.out.println("Default method");
+ return false;
+ }
+ }
+
+
+ static void someMethod(Predicate<? extends Number> p) {
+ if (!p.test(null))
+ throw new Error("Blew it");
+ }
+
+ public static void main(String[] args) {
+
+ someMethod(new Predicate<Integer>() {
+ public boolean test(Integer n) {
+ System.out.println("Override");
+ return true;
+ }
+ boolean test(Integer n, int i) {
+ System.out.println("Override");
+ return true;
+ }
+ protected boolean test(Integer n, int i, int j) {
+ System.out.println("Override");
+ return true;
+ }
+ private boolean test(Integer n, int i, long j) {
+ System.out.println("Override");
+ return true;
+ }
+ });
+
+ someMethod(new Predicate<>() {
+ public boolean test(Integer n) { // bad.
+ System.out.println("Override");
+ return true;
+ }
+ boolean test(Integer n, int i) { // bad, package access.
+ System.out.println("Override");
+ return true;
+ }
+ protected boolean test(Integer n, int i, int j) { // bad, protected access.
+ System.out.println("Override");
+ return true;
+ }
+ private boolean test(Integer n, int i, long j) { // OK, private method.
+ System.out.println("Override");
+ return true;
+ }
+ });
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg15.out Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,4 @@
+Neg15.java:48:28: compiler.err.method.does.not.override.superclass
+Neg15.java:52:21: compiler.err.method.does.not.override.superclass
+Neg15.java:56:31: compiler.err.method.does.not.override.superclass
+3 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg16.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,36 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8062373
+ * @summary Test that javac does not recommend a diamond site that would result in error.
+ * @compile/ref=Neg16.out -Xlint:-options Neg16.java -XDrawDiagnostics -XDfind=diamond
+ */
+
+class Neg16 {
+
+ interface Predicate<T> {
+ default boolean test(T t) {
+ System.out.println("Default method");
+ return false;
+ }
+ }
+
+ static void someMethod(Predicate<? extends Number> p) {
+ if (!p.test(null))
+ throw new Error("Blew it");
+ }
+
+ public static void main(String[] args) {
+ someMethod(new Predicate<Integer>() { // cannot convert to diamond
+ public boolean test(Integer n) {
+ System.out.println("Override");
+ return true;
+ }
+ });
+ someMethod(new Predicate<Number>() { // can convert to diamond.
+ public boolean test(Number n) {
+ System.out.println("Override");
+ return true;
+ }
+ });
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg16.out Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,2 @@
+Neg16.java:29:33: compiler.warn.diamond.redundant.args
+1 warning
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg17.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,21 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8062373
+ * @summary Test that the anonymous class constructor appears to returns a Foo<T>, when it actually returns a Anon$1. (status as of now - may change in future)
+ * @compile/fail/ref=Neg17.out Neg17.java -XDrawDiagnostics
+ */
+
+import java.util.Collections;
+
+abstract class Neg17<T> {
+
+ abstract void m();
+
+ public static void main(String[] args) {
+ Collections.singletonList(new Neg17<>() { void m() {} }).get(0).m(); // good.
+ Collections.singletonList(new Neg17<>() {
+ void m() {}
+ private void n() {}
+ }).get(0).n(); // bad unknown method n()
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg17.out Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,2 @@
+Neg17.java:19:21: compiler.err.cant.resolve.location.args: kindname.method, n, , , (compiler.misc.location: kindname.class, Neg17<java.lang.Object>, null)
+1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg18.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8062373
+ * @summary Test that inaccessible vararg element type triggers an error during diamond inferred anonymous class instance creation.
+ * @compile/fail/ref=Neg18.out Neg18.java -XDrawDiagnostics
+ */
+
+import java.util.Collections;
+import pkg.Neg18_01;
+
+class Neg18 {
+
+ public static void main(String[] args) {
+ new Neg18_01<>() {};
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg18.out Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,3 @@
+Neg18.java:14:21: compiler.err.prob.found.req: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: pkg.Neg18_01), (compiler.misc.inaccessible.varargs.type: pkg.Neg18_01.PkgPrivate, kindname.class, Neg18))
+Neg18.java:14:26: compiler.err.not.def.public.cant.access: pkg.Neg18_01.PkgPrivate, pkg.Neg18_01
+2 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg19.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,21 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8062373
+ * @summary Test that when inaccessible types constitute the inferred types of <> the compiler complains.
+ * @compile/fail/ref=Neg19.out Neg19.java -XDrawDiagnostics
+ */
+
+
+
+class Neg19 {
+ public static void main(String[] args) {
+ new Neg19_01<Neg19>().foo(new Neg19_01<>()); // OK.
+ new Neg19_01<Neg19>().foo(new Neg19_01<>() {}); // ERROR.
+ }
+}
+
+class Neg19_01<T> {
+ private class Private {}
+ Neg19_01() {}
+ void foo(Neg19_01<Private> p) {}
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg19.out Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,2 @@
+Neg19.java:13:34: compiler.err.report.access: Neg19_01.Private, private, Neg19_01
+1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/pkg/Neg18_01.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package pkg;
+
+public class Neg18_01<T> {
+ static class PkgPrivate {}
+ public Neg18_01 (PkgPrivate ... pp) {}
+}
--- a/langtools/test/tools/javac/generics/diamond/pos/Pos01.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/pos/Pos01.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
*
* @summary basic test for diamond (generic/non-generic constructors)
* @author mcimadamore
@@ -48,7 +48,17 @@
Pos01<? extends Integer> p6 = new Pos01<>(1, "");
Pos01<?> p7 = new Pos01<>(1, "");
Pos01<? super Integer> p8 = new Pos01<>(1, "");
- }
+
+ Pos01<Integer> p9 = new Pos01<>(1){};
+ Pos01<? extends Integer> p10 = new Pos01<>(1){};
+ Pos01<?> p11 = new Pos01<>(1){};
+ Pos01<? super Integer> p12 = new Pos01<>(1){};
+
+ Pos01<Integer> p13 = new Pos01<>(1, ""){};
+ Pos01<? extends Integer> p14= new Pos01<>(1, ""){};
+ Pos01<?> p15 = new Pos01<>(1, ""){};
+ Pos01<? super Integer> p16 = new Pos01<>(1, ""){};
+ }
public static void main(String[] args) {
Pos01<String> p1 = new Pos01<>("");
--- a/langtools/test/tools/javac/generics/diamond/pos/Pos02.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/pos/Pos02.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
*
* @summary basic test for diamond (simple/qualified type-expressions)
* @author mcimadamore
@@ -48,6 +48,16 @@
Foo<? extends Integer> f6 = new Foo<>(1, "");
Foo<?> f7 = new Foo<>(1, "");
Foo<? super Integer> f8 = new Foo<>(1, "");
+
+ Foo<Integer> f9 = new Foo<>(1){};
+ Foo<? extends Integer> f10 = new Foo<>(1){};
+ Foo<?> f11 = new Foo<>(1){};
+ Foo<? super Integer> f12 = new Foo<>(1){};
+
+ Foo<Integer> f13 = new Foo<>(1, ""){};
+ Foo<? extends Integer> f14 = new Foo<>(1, ""){};
+ Foo<?> f15 = new Foo<>(1, ""){};
+ Foo<? super Integer> f16 = new Foo<>(1, ""){};
}
void testQualified() {
@@ -60,6 +70,16 @@
Foo<? extends Integer> f6 = new Pos02.Foo<>(1, "");
Foo<?> f7 = new Pos02.Foo<>(1, "");
Foo<? super Integer> f8 = new Pos02.Foo<>(1, "");
+
+ Foo<Integer> f9 = new Pos02.Foo<>(1){};
+ Foo<? extends Integer> f10 = new Pos02.Foo<>(1){};
+ Foo<?> f11 = new Pos02.Foo<>(1){};
+ Foo<? super Integer> f12 = new Pos02.Foo<>(1){};
+
+ Foo<Integer> f13 = new Pos02.Foo<>(1, ""){};
+ Foo<? extends Integer> f14 = new Pos02.Foo<>(1, ""){};
+ Foo<?> f15 = new Pos02.Foo<>(1, ""){};
+ Foo<? super Integer> f16 = new Pos02.Foo<>(1, ""){};
}
public static void main(String[] args) {
--- a/langtools/test/tools/javac/generics/diamond/pos/Pos03.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/pos/Pos03.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
*
* @summary basic test for diamond (simple/qualified type-expressions, member inner)
* @author mcimadamore
@@ -49,6 +49,16 @@
Foo<? extends Integer> f6 = new Foo<>(1, "");
Foo<?> f7 = new Foo<>(1, "");
Foo<? super Integer> f8 = new Foo<>(1, "");
+
+ Foo<Integer> f9 = new Foo<>(1){};
+ Foo<? extends Integer> f10 = new Foo<>(1){};
+ Foo<?> f11 = new Foo<>(1){};
+ Foo<? super Integer> f12 = new Foo<>(1){};
+
+ Foo<Integer> f13 = new Foo<>(1, ""){};
+ Foo<? extends Integer> f14 = new Foo<>(1, ""){};
+ Foo<?> f15 = new Foo<>(1, ""){};
+ Foo<? super Integer> f16 = new Foo<>(1, ""){};
}
void testQualified_1() {
@@ -61,6 +71,16 @@
Foo<? extends Integer> f6 = new Pos03<U>.Foo<>(1, "");
Foo<?> f7 = new Pos03<U>.Foo<>(1, "");
Foo<? super Integer> f8 = new Pos03<U>.Foo<>(1, "");
+
+ Foo<Integer> f9 = new Pos03<U>.Foo<>(1){};
+ Foo<? extends Integer> f10 = new Pos03<U>.Foo<>(1){};
+ Foo<?> f11 = new Pos03<U>.Foo<>(1){};
+ Foo<? super Integer> f12 = new Pos03<U>.Foo<>(1){};
+
+ Foo<Integer> f13 = new Pos03<U>.Foo<>(1, ""){};
+ Foo<? extends Integer> f14 = new Pos03<U>.Foo<>(1, ""){};
+ Foo<?> f15 = new Pos03<U>.Foo<>(1, ""){};
+ Foo<? super Integer> f16 = new Pos03<U>.Foo<>(1, ""){};
}
void testQualified_2(Pos03<U> p) {
@@ -73,6 +93,16 @@
Foo<? extends Integer> f6 = p.new Foo<>(1, "");
Foo<?> f7 = p.new Foo<>(1, "");
Foo<? super Integer> f8 = p.new Foo<>(1, "");
+
+ Foo<Integer> f9 = p.new Foo<>(1){};
+ Foo<? extends Integer> f10 = p.new Foo<>(1){};
+ Foo<?> f11 = p.new Foo<>(1){};
+ Foo<? super Integer> f12 = p.new Foo<>(1){};
+
+ Foo<Integer> f13 = p.new Foo<>(1, ""){};
+ Foo<? extends Integer> f14 = p.new Foo<>(1, ""){};
+ Foo<?> f15 = p.new Foo<>(1, ""){};
+ Foo<? super Integer> f16 = p.new Foo<>(1, ""){};
}
public static void main(String[] args) {
--- a/langtools/test/tools/javac/generics/diamond/pos/Pos04.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/pos/Pos04.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
*
* @summary basic test for diamond (simple/qualified type-expressions, local class)
* @author mcimadamore
@@ -48,6 +48,16 @@
Foo<? extends Integer> p6 = new Foo<>(1, "");
Foo<?> p7 = new Foo<>(1, "");
Foo<? super Integer> p8 = new Foo<>(1, "");
+
+ Foo<Integer> p9 = new Foo<>(1){};
+ Foo<? extends Integer> p10 = new Foo<>(1){};
+ Foo<?> p11 = new Foo<>(1){};
+ Foo<? super Integer> p12 = new Foo<>(1){};
+
+ Foo<Integer> p13 = new Foo<>(1, ""){};
+ Foo<? extends Integer> p14 = new Foo<>(1, ""){};
+ Foo<?> p15 = new Foo<>(1, ""){};
+ Foo<? super Integer> p16 = new Foo<>(1, ""){};
}
public static void main(String[] args) {
--- a/langtools/test/tools/javac/generics/diamond/pos/Pos05.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/generics/diamond/pos/Pos05.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,11 +23,10 @@
/*
* @test
- * @bug 6939620 7020044
+ * @bug 6939620 7020044 8062373
*
* @summary Check that 'complex' inference sometimes works in method context
* @author mcimadamore
- * @compile Pos05.java
*
*/
@@ -41,5 +40,11 @@
void test() {
m(new Foo<>(1));
+ m(new Foo<>(1) {});
}
+
+ public static void main(String [] args) {
+ new Pos05().test();
+ }
+
}
--- a/langtools/test/tools/javac/generics/inference/5073060/GenericsAndPackages.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/generics/inference/5073060/GenericsAndPackages.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/**
* @test
- * @bug 5073060
+ * @bug 5073060 8075610
* @summary Package private members not found for intersection types
* @author Bruce Eckel
* see http://www.artima.com/forums/flat.jsp?forum=106&thread=136204
@@ -33,7 +33,7 @@
package code;
interface HasColor {
- java.awt.Color getColor();
+ String getColor();
}
class Dimension {
@@ -44,6 +44,6 @@
T item;
ColoredDimension(T item) { this.item = item; }
T getItem() { return item; }
- java.awt.Color f() { return item.getColor(); }
+ String f() { return item.getColor(); }
int getX() { return item.x; }
}
--- a/langtools/test/tools/javac/generics/inference/8055963/T8055963.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/generics/inference/8055963/T8055963.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,11 +25,10 @@
/**
* @test
- * @bug 8055963
+ * @bug 8055963 8062373
* @summary Inference failure with nested invocation
- * @compile T8055963.java
*/
-class T8055963 {
+public class T8055963 {
static class C<T> {}
@@ -38,4 +37,8 @@
void test() {
C<String> cs = choose(new C<String>(), new C<>());
}
+
+ public static void main(String [] args) {
+ new T8055963().test();
+ }
}
--- a/langtools/test/tools/javac/lambda/8066974/T8066974.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/lambda/8066974/T8066974.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,6 +1,6 @@
/*
* @test /nodynamiccopyright/
- * @bug 8066974
+ * @bug 8066974 8062373
* @summary Compiler doesn't infer method's generic type information in lambda body
* @compile/fail/ref=T8066974.out -XDrawDiagnostics T8066974.java
*/
@@ -34,11 +34,13 @@
map(p->p.m(rt));
map(mapper(rt));
map(new ThrowingMapper<>(rt));
+ map(new ThrowingMapper<>(rt) {});
}
void testChecked(CheckedThrowing ct) {
map(p->p.m(ct));
map(mapper(ct));
map(new ThrowingMapper<>(ct));
+ map(new ThrowingMapper<>(ct) {});
}
}
--- a/langtools/test/tools/javac/lambda/8066974/T8066974.out Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/lambda/8066974/T8066974.out Tue Apr 14 12:10:00 2015 -0700
@@ -1,4 +1,5 @@
-T8066974.java:40:19: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
T8066974.java:41:19: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
-T8066974.java:42:13: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
-3 errors
+T8066974.java:42:19: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
+T8066974.java:43:13: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
+T8066974.java:44:13: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
+4 errors
--- a/langtools/test/tools/javac/lambda/LocalVariableTable.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/lambda/LocalVariableTable.java Tue Apr 14 12:10:00 2015 -0700
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8025998 8026749
+ * @bug 8025998 8026749 8054220 8058227
* @summary Missing LV table in lambda bodies
* @compile -g LocalVariableTable.java
* @run main LocalVariableTable
@@ -183,7 +183,7 @@
Run1 r = (a) -> { int x = a; };
}
- @Expect({ "a", "x" })
+ @Expect({ "a", "x", "v" })
static class Lambda_Args1_Local1_Captured1 {
void m() {
int v = 0;
@@ -191,7 +191,7 @@
}
}
- @Expect({ "a1", "a2", "x1", "x2", "this" })
+ @Expect({ "a1", "a2", "x1", "x2", "this", "v1", "v2" })
static class Lambda_Args2_Local2_Captured2_this {
int v;
void m() {
@@ -204,7 +204,7 @@
}
}
- @Expect({ "e" })
+ @Expect({ "e", "c" })
static class Lambda_Try_Catch {
private static Runnable asUncheckedRunnable(Closeable c) {
return () -> {
--- a/langtools/test/tools/javac/lambda/MethodReference23.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/lambda/MethodReference23.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,6 +1,6 @@
/*
* @test /nodynamiccopyright/
- * @bug 8003280
+ * @bug 8003280 8075184
* @summary Add lambda tests
* check that pair of bound/non-bound constructor references is flagged as ambiguous
* @author Maurizio Cimadamore
--- a/langtools/test/tools/javac/lambda/MethodReference23.out Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/lambda/MethodReference23.out Tue Apr 14 12:10:00 2015 -0700
@@ -1,6 +1,6 @@
-MethodReference23.java:52:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, MethodReference23, MethodReference23))
-MethodReference23.java:53:15: compiler.err.cant.apply.symbol: kindname.method, call11, MethodReference23.SAM11, @1140, kindname.class, MethodReference23, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, MethodReference23, MethodReference23)))
-MethodReference23.java:57:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, , MethodReference23))
-MethodReference23.java:58:15: compiler.err.cant.apply.symbol: kindname.method, call12, MethodReference23.SAM12, @1282, kindname.class, MethodReference23, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, , MethodReference23)))
+MethodReference23.java:52:19: compiler.err.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, MethodReference23, MethodReference23)
+MethodReference23.java:53:16: compiler.err.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, MethodReference23, MethodReference23)
+MethodReference23.java:57:19: compiler.err.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, , MethodReference23)
+MethodReference23.java:58:16: compiler.err.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, , MethodReference23)
MethodReference23.java:72:9: compiler.err.ref.ambiguous: call3, kindname.method, call3(MethodReference23.SAM21), MethodReference23, kindname.method, call3(MethodReference23.SAM22), MethodReference23
5 errors
--- a/langtools/test/tools/javac/lambda/TargetType46.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/lambda/TargetType46.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,6 +1,6 @@
/*
* @test /nodynamiccopyright/
- * @bug 8003280
+ * @bug 8003280 8062373
* @summary Add lambda tests
* compiler doesn't report accessibility problem due to inaccessible target
* @compile/fail/ref=TargetType46.out -XDrawDiagnostics TargetType46.java
@@ -22,6 +22,7 @@
outer.m(()->{}); //access error
outer.m(this::g); //access error
outer.m(new ArrayList<>()); //ok
+ outer.m(new ArrayList<>() {}); // access error
outer.m(Collections.emptyList()); //ok
}
--- a/langtools/test/tools/javac/lambda/TargetType46.out Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/lambda/TargetType46.out Tue Apr 14 12:10:00 2015 -0700
@@ -1,3 +1,4 @@
TargetType46.java:22:17: compiler.err.report.access: TargetType46Outer.PI, private, TargetType46Outer
TargetType46.java:23:17: compiler.err.report.access: TargetType46Outer.PI, private, TargetType46Outer
-2 errors
+TargetType46.java:25:16: compiler.err.report.access: TargetType46Outer.PI, private, TargetType46Outer
+3 errors
--- a/langtools/test/tools/javac/lambda/TargetType68.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/lambda/TargetType68.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,9 +23,9 @@
/*
* @test
- * @bug 8010303
+ * @bug 8010303 8062373
* @summary Graph inference: missing incorporation step causes spurious inference error
- * @compile TargetType68.java
+ * @compile/fail/ref=TargetType68.out -XDrawDiagnostics TargetType68.java
*/
import java.util.*;
@@ -58,6 +58,6 @@
List<XYChart.Data<Number, Number>> data_2 = new ArrayList<>();
numberChart.getData().setAll(
Arrays.asList(new XYChart.Series<>("Data", FXCollections.observableList(data_1)),
- new XYChart.Series<>("Data", FXCollections.observableList(data_2))));
+ new XYChart.Series<>("Data", FXCollections.observableList(data_2)) {}));
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/TargetType68.out Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,3 @@
+TargetType68.java:61:32: compiler.err.cant.inherit.from.final: TargetType68.XYChart.Series
+TargetType68.java:61:39: compiler.err.cant.inherit.from.final: TargetType68.XYChart.Series
+2 errors
--- a/langtools/test/tools/javac/lambda/TargetType69.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/lambda/TargetType69.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8010303
+ * @bug 8010303 8062373
* @summary Graph inference: missing incorporation step causes spurious inference error
* @compile TargetType69.java
*/
@@ -47,5 +47,6 @@
void test(Function<Integer, Integer> classifier, Function<Integer, Map<Integer, List<Integer>>> coll) {
exerciseMapTabulation(coll, new GroupedMapAssertion<>(classifier));
+ exerciseMapTabulation(coll, new GroupedMapAssertion<>(classifier) {});
}
}
--- a/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceNullCheckTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/lambda/methodReferenceExecution/MethodReferenceNullCheckTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,12 +25,11 @@
/**
* @test
- * @bug 8024696
+ * @bug 8024696 8075752
* @summary Missing null check in bound method reference capture
*/
-import com.sun.tools.javac.util.Assert;
-import java.util.function.*;
+import java.util.function.Supplier;
public class MethodReferenceNullCheckTest {
public static void main(String[] args) {
@@ -41,7 +40,8 @@
} catch (NullPointerException npe) {
npeFired = true;
} finally {
- Assert.check(npeFired, "NPE should have been thrown");
+ if (!npeFired)
+ throw new AssertionError("NPE should have been thrown");
}
}
}
--- a/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/javac/FDTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/lambdaShapes/org/openjdk/tests/javac/FDTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -108,9 +108,10 @@
public static List<Pair<TestKind, Hierarchy>> generateCases() {
ArrayList<Pair<TestKind,Hierarchy>> list = new ArrayList<>();
HierarchyGenerator hg = new HierarchyGenerator();
+ int i = 0;
for (TestKind tk : TestKind.values()) {
for (Hierarchy hs : tk.getHierarchy(hg)) {
- list.add(new Pair<>(tk, hs));
+ list.add((i++ % 2) == 0 ? new Pair<>(tk, hs) {} : new Pair<>(tk, hs));
}
}
return list;
--- a/langtools/test/tools/javac/lib/DPrinter.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/lib/DPrinter.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -477,7 +477,7 @@
out.print(label);
out.println(": " +
info(sym.getClass(),
- String.format("0x%x--%s", sym.kind, Kinds.kindName(sym)),
+ String.format("0x%x--%s", sym.kind.ordinal(), Kinds.kindName(sym)),
sym.getKind())
+ " " + sym.name
+ " " + hashString(sym));
--- a/langtools/test/tools/javac/processing/model/type/BasicAnnoTests.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/processing/model/type/BasicAnnoTests.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,21 +23,27 @@
/*
* @test
- * @bug 8013852
+ * @bug 8013852 8031744
* @summary Annotations on types
* @library /tools/javac/lib
- * @ignore 8057688 type annotations in type argument position are lost
- * @ignore 8031744 Annotations on many Language Model elements are not returned
* @build JavacTestingAbstractProcessor DPrinter BasicAnnoTests
* @compile/process -processor BasicAnnoTests -proc:only BasicAnnoTests.java
*/
import java.io.PrintWriter;
+import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
+import java.lang.annotation.Repeatable;
import java.lang.annotation.Target;
+import java.util.ArrayList;
+
+import java.util.HashSet;
+import java.util.List;
import java.util.Map;
+import java.util.NavigableMap;
import java.util.Set;
+import java.util.TreeMap;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment;
@@ -48,15 +54,23 @@
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.ArrayType;
+import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.ExecutableType;
+import javax.lang.model.type.IntersectionType;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.type.TypeVariable;
import javax.lang.model.type.WildcardType;
+import javax.lang.model.util.Types;
import javax.tools.Diagnostic.Kind;
+import com.sun.tools.javac.code.Attribute;
import com.sun.tools.javac.code.Symbol;
-import com.sun.tools.javac.code.Type;
import com.sun.tools.javac.processing.JavacProcessingEnvironment;
+import com.sun.tools.javac.util.Name;
+
+import static com.sun.tools.javac.code.Attribute.Array;
+import static com.sun.tools.javac.code.Attribute.Constant;
+import static com.sun.tools.javac.code.Attribute.Compound;
/**
* The test scans this file looking for test cases annotated with @Test.
@@ -77,7 +91,7 @@
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
TestElementScanner s = new TestElementScanner();
for (Element e: roundEnv.getRootElements()) {
- s.scan(e);
+ s.scan(e, null);
}
return true;
}
@@ -95,17 +109,17 @@
*/
class TestElementScanner extends ElementScanner<Void,Void> {
public Void scan(Element elem, Void ignore) {
+ List<AnnotationMirror> tests = new ArrayList<>();
AnnotationMirror test = getAnnotation(elem, Test.class.getName().replace('$', '.'));
if (test != null) {
+ tests.add(test);
+ }
+ tests.addAll(getAnnotations(elem, Tests.class.getName().replace('$', '.')));
+
+ if (tests.size() > 0) {
out.println("Test: " + elem + " " + test);
- TestTypeScanner s = new TestTypeScanner(elem, test);
- s.scan(elem.asType(), null);
- if (getPosn(test) >= s.count)
- error(elem, "position " + getPosn(test) + " not found");
- if (!s.found) {
- dprinter.printSymbol("element", (Symbol) elem);
- dprinter.printType("type", (Type) elem.asType());
- }
+ TestTypeScanner s = new TestTypeScanner(elem, tests, types);
+ s.test(elem.asType());
out.println();
}
return super.scan(elem, ignore);
@@ -118,45 +132,110 @@
*/
class TestTypeScanner extends TypeScanner<Void, Void> {
Element elem;
- AnnotationMirror test;
+ NavigableMap<Integer, AnnotationMirror> toBeFound;
int count = 0;
- boolean found = false;
+ Set<TypeMirror> seen = new HashSet<>();
+
+ TestTypeScanner(Element elem, List<AnnotationMirror> tests, Types types) {
+ super(types);
+ this.elem = elem;
- TestTypeScanner(Element elem, AnnotationMirror test) {
- this.elem = elem;
- this.test = test;
+ NavigableMap<Integer, AnnotationMirror> testByPos = new TreeMap<>();
+ for (AnnotationMirror test : tests) {
+ for (int pos : getPosn(test)) {
+ testByPos.put(pos, test);
+ }
+ }
+ this.toBeFound = testByPos;
+ }
+
+ public void test(TypeMirror t) {
+ scan(t, null);
}
@Override
Void scan(TypeMirror t, Void ignore) {
if (t == null)
return DEFAULT_VALUE;
- if (verbose)
- out.println("scan " + count + ": " + t);
- if (count == getPosn(test)) {
- String annoType = getAnnoType(test);
- AnnotationMirror anno = getAnnotation(t, annoType);
- if (anno == null) {
- error(elem, "annotation not found on " + count + ": " + t);
- } else {
- String v = getValue(anno, "value").toString();
- if (v.equals(getExpect(test))) {
- out.println("found " + anno + " as expected");
- found = true;
+
+ if (!seen.contains(t)) {
+ try {
+ seen.add(t);
+ if (verbose)
+ out.println("scan " + count + ": " + t);
+ if (toBeFound.size() > 0) {
+ if (toBeFound.firstKey().equals(count)) {
+ AnnotationMirror test = toBeFound.pollFirstEntry().getValue();
+ String annoType = getAnnoType(test);
+ AnnotationMirror anno = getAnnotation(t, annoType);
+ if (anno == null) {
+ error(elem, "annotation not found on " + count + ": " + t);
+ } else {
+ String v = getValue(anno, "value").toString();
+ if (v.equals(getExpect(test))) {
+ out.println("found " + anno + " as expected");
+ } else {
+ error(elem, "Unexpected value: " + v + ", expected: " + getExpect(test));
+ }
+ }
+ } else if (count > toBeFound.firstKey()) {
+ rescue();
+ } else {
+ List<? extends AnnotationMirror> annos = t.getAnnotationMirrors();
+ if (annos.size() > 0) {
+ for (AnnotationMirror a : annos)
+ error(elem, "annotation " + a + " found on " + count + ": " + t);
+ }
+ }
} else {
- error(elem, "Unexpected value: " + v + ", expected: " + getExpect(test));
+ List<? extends AnnotationMirror> annos = t.getAnnotationMirrors();
+ if (annos.size() > 0) {
+ for (AnnotationMirror a : annos)
+ error(elem, "annotation " + a + " found on " + count + ": " + t);
+ }
}
+ count++;
+ return super.scan(t, ignore);
+
+ } finally {
+ seen.remove(t);
}
}
- count++;
- return super.scan(t, ignore);
+
+ return DEFAULT_VALUE;
+
+ }
+
+ private void rescue() {
+ while (toBeFound.size() > 0 && toBeFound.firstKey() >= count)
+ toBeFound.pollFirstEntry();
}
}
- /** Get the position value from an @Test annotation mirror. */
- static int getPosn(AnnotationMirror test) {
+ /** Get the position value from an element annotated with a @Test annotation mirror. */
+ static int[] getPosn(Element elem) {
+ return elem.getAnnotation(Test.class).posn();
+ }
+
+ /** Get the position value from a @Test annotation mirror. */
+ static Integer[] getPosn(AnnotationMirror test) {
AnnotationValue v = getValue(test, "posn");
- return (Integer) v.getValue();
+ Object value = v.getValue();
+ Integer i = 0;
+ if (value instanceof Constant) {
+ i = (Integer)((Constant)value).getValue();
+ Integer[] res = new Integer[1];
+ res[0] = i;
+ return res;
+ } else if (value instanceof List) {
+ List<Constant> l = (List<Constant>)value;
+ Integer[] res = new Integer[l.size()];
+ for (int c = 0; c < l.size(); c++) {
+ res[c] = (Integer)l.get(c).getValue();
+ }
+ return res;
+ }
+ return null;
}
/** Get the expect value from an @Test annotation mirror. */
@@ -185,6 +264,25 @@
return null;
}
+ static List<AnnotationMirror> getAnnotations(Element e, String name) {
+ Name valueName = ((Symbol)e).getSimpleName().table.names.value;
+ List<AnnotationMirror> res = new ArrayList<>();
+
+ for (AnnotationMirror m : e.getAnnotationMirrors()) {
+ TypeElement te = (TypeElement) m.getAnnotationType().asElement();
+ if (te.getQualifiedName().contentEquals(name)) {
+ Compound theAnno = (Compound)m;
+ Array valueArray = (Array)theAnno.member(valueName);
+ for (Attribute a : valueArray.getValue()) {
+ AnnotationMirror theMirror = (AnnotationMirror) a;
+
+ res.add(theMirror);
+ }
+ }
+ }
+ return res;
+ }
+
/**
* Get a specific value from an annotation mirror.
*/
@@ -203,6 +301,13 @@
* one sufficient for our needs.
*/
static class TypeScanner<R, P> extends SimpleTypeVisitor<R, P> {
+ private Types types;
+
+ public TypeScanner(Types types) {
+ super();
+ this.types = types;
+ }
+
@Override
public R visitArray(ArrayType t, P p) {
scan(t.getComponentType(), p);
@@ -211,17 +316,34 @@
@Override
public R visitExecutable(ExecutableType t, P p) {
+ //out.println(" type parameters: " + t.getTypeVariables());
+ scan(t.getTypeVariables(), p);
+ //out.println(" return: " + t.getReturnType());
+ scan(t.getReturnType(), p);
+ //out.println(" receiver: " + t.getReceiverTypes());
scan(t.getReceiverType());
//out.println(" params: " + t.getParameterTypes());
scan(t.getParameterTypes(), p);
- //out.println(" return: " + t.getReturnType());
- scan(t.getReturnType(), p);
//out.println(" throws: " + t.getThrownTypes());
scan(t.getThrownTypes(), p);
return super.visitExecutable(t, p);
}
@Override
+ public R visitDeclared(DeclaredType t, P p) {
+ scan(t.getTypeArguments(), p);
+ // don't scan enclosing
+ scan(types.directSupertypes(t), p);
+ return super.visitDeclared(t, p);
+ }
+
+ @Override
+ public R visitIntersection(IntersectionType t, P p) {
+ scan(t.getBounds(), p);
+ return super.visitIntersection(t, p);
+ }
+
+ @Override
public R visitTypeVariable(TypeVariable t, P p) {
scan(t.getLowerBound(), p);
scan(t.getUpperBound(), p);
@@ -254,36 +376,194 @@
}
/** Annotation to identify test cases. */
+ @Repeatable(Tests.class)
@interface Test {
/** Where to look for the annotation, expressed as a scan index. */
- int posn();
+ int[] posn();
/** The annotation to look for. */
Class<? extends Annotation> annoType();
/** The string representation of the annotation's value. */
String expect();
}
+ @interface Tests {
+ Test[] value();
+ }
+
/** Type annotation to use in test cases. */
@Target(ElementType.TYPE_USE)
public @interface TA {
int value();
}
+ @Target(ElementType.TYPE_USE)
+ public @interface TB {
+ int value();
+ }
+
+ // Test cases
+
+ // TODO: add more cases for arrays
+ // all annotated
+ // all but one annotated
+ // vary position of one not annotated
+ // only one annotated
+ // vary position of one annotated
+ // the three above with the corner case of the ambiguos decl + type anno added
@Test(posn=0, annoType=TA.class, expect="1")
public @TA(1) int f1;
+ @Test(posn=0, annoType=TA.class, expect="11")
+ @TA(11) public int f11;
+
+ @Test(posn=1, annoType=TA.class, expect="111")
+ @TA(111) public int [] f111;
+
+ @Test(posn=1, annoType=TA.class, expect="1120")
+ @Test(posn=0, annoType=TB.class, expect="1121")
+ @TA(1120) public int @TB(1121) [] f112;
+
+ @Test(posn=0, annoType=TB.class, expect="11211")
+ @Test(posn=1, annoType=TA.class, expect="11200")
+ public @TA(11200) int @TB(11211) [] f112b;
+
+ @Test(posn=1, annoType=TB.class, expect="1131")
+ @Test(posn=2, annoType=TA.class, expect="1130")
+ @TA(1130) public int [] @TB(1131) [] f113;
+
+ @Test(posn=5, annoType=TA.class, expect="12")
+ public @TA(12) int [] [] [] [] [] f12;
+
+ @Test(posn=6, annoType=TA.class, expect="13")
+ public @TA(13) int [] [] [] [] [] [] f13;
+
+ @Test(posn=7, annoType=TA.class, expect="14")
+ @TA(14) public int [] [] [] [] [] [] [] f14;
+
+ @Test(posn=6, annoType=TA.class, expect="150")
+ @Test(posn=7, annoType=TB.class, expect="151")
+ @TB(151) public int [] [] [] [] [] [] @TA(150) [] f15;
+
+ @Test(posn=0, annoType=TB.class, expect="1511")
+ @Test(posn=3, annoType=TA.class, expect="1512")
+ @Test(posn=6, annoType=TA.class, expect="150")
+ @Test(posn=7, annoType=TB.class, expect="151")
+ @TB(151) public int @TB(1511) [] [] [] @TA(1512) [] [] [] @TA(150) [] f15b;
+
+ @Test(posn=0, annoType=TB.class, expect="1521")
+ @Test(posn=3, annoType=TA.class, expect="1522")
+ @Test(posn=6, annoType=TA.class, expect="152")
+ public int @TB(1521) [] [] [] @TA(1522) [] [] [] @TA(152) [] f15c;
+
+ @Test(posn=5, annoType=TA.class, expect="160")
+ @Test(posn=6, annoType=TB.class, expect="161")
+ public int [] [] [] [] [] @TA(160) [] @TB(161) [] f16;
+
@Test(posn=0, annoType=TA.class, expect="2")
public int @TA(2) [] f2;
+ @Test(posn=0, annoType=TB.class, expect="33")
@Test(posn=1, annoType=TA.class, expect="3")
- public @TA(3) int [] f3;
+ public @TA(3) int @TB(33) [] f3;
- @Test(posn=1, annoType=TA.class, expect="4")
+ @Test(posn=2, annoType=TA.class, expect="4")
public int m1(@TA(4) float a) throws Exception { return 0; }
- @Test(posn=2, annoType=TA.class, expect="5")
+ @Test(posn=1, annoType=TA.class, expect="5")
public @TA(5) int m2(float a) throws Exception { return 0; }
@Test(posn=3, annoType=TA.class, expect="6")
public int m3(float a) throws @TA(6) Exception { return 0; }
+
+ // Also tests that a decl anno on a typevar doesn't show up on the Type
+ @Test(posn=7, annoType=TA.class, expect="8")
+ public <@TA(7) M> M m4(@TA(8) float a) throws Exception { return null; }
+
+ // Also tests that a decl anno on a typevar doesn't show up on the Type
+ @Test(posn=4, annoType=TA.class, expect="10")
+ public class Inner1<@TA(9) S> extends @TA(10) Object implements Cloneable {}
+
+ // Also tests that a decl anno on a typevar doesn't show up on the Type
+ @Test(posn=5, annoType=TA.class, expect="12")
+ public class Inner2<@TA(11) S> extends Object implements @TA(12) Cloneable {}
+
+ @Test(posn={3,6}, annoType=TA.class, expect="13")
+ public <M extends @TA(13) Object> M m5(float a) { return null; }
+
+ @Test(posn=3, annoType=TA.class, expect="14")
+ public class Inner3<QQQ extends @TA(14) Map> {}
+
+ @Test(posn=4, annoType=TA.class, expect="15")
+ public class Inner4<T extends @TA(15) Object & Cloneable & Serializable> {}
+
+ @Test(posn=5, annoType=TA.class, expect="16")
+ public class Inner5<T extends Object & @TA(16) Cloneable & Serializable> {}
+
+ @Test(posn=7, annoType=TA.class, expect="17")
+ public class Inner6<T extends Object & Cloneable & @TA(17) Serializable> {}
+
+ // Test annotated bounds
+
+ @Test(posn=1, annoType=TA.class, expect="18")
+ public Set<@TA(18) ? extends Object> f4;
+
+ @Test(posn=2, annoType=TA.class, expect="19")
+ public Set<? extends @TA(19) Object> f5;
+
+ @Test(posn=3, annoType=TA.class, expect="20")
+ public Set<? extends Set<@TA(20) ? extends Object>> f6;
+
+ @Test(posn=4, annoType=TA.class, expect="21")
+ public Set<? extends Set<? extends @TA(21) Object>> f7;
+
+ @Test(posn=1, annoType=TA.class, expect="22")
+ public Set<@TA(22) ?> f8;
+
+ @Test(posn=1, annoType=TA.class, expect="23")
+ public Set<@TA(23) ? super Object> f9;
+
+ // Test type use annotations on uses of type variables
+ @Test(posn=5, annoType = TA.class, expect = "25")
+ @Test(posn=5, annoType = TB.class, expect = "26")
+ <T> void m6(@TA(25) @TB(26) T t) { }
+
+ class Inner7<T> {
+ @Test(posn=0, annoType = TA.class, expect = "30")
+ @Test(posn=0, annoType = TB.class, expect = "31")
+ @TA(30) @TB(31) T f;
+ }
+
+ // Test type use annotations on uses of type variables
+ @Test(posn=5, annoType = TB.class, expect = "41")
+ <@TA(40) T> void m7(@TB(41) T t) { }
+
+ class Inner8<@TA(50) T> {
+ @Test(posn=0, annoType = TB.class, expect = "51")
+ @TB(51) T f;
+ }
+
+ // Test type use annotations on uses of Class types
+ @Test(posn=5, annoType = TA.class, expect = "60")
+ @Test(posn=5, annoType = TB.class, expect = "61")
+ <T> void m60(@TA(60) @TB(61) String t) { }
+
+ class Inner70<T> {
+ @Test(posn=0, annoType = TA.class, expect = "70")
+ @Test(posn=0, annoType = TB.class, expect = "71")
+ @TA(70) @TB(71) String f;
+ }
+
+ // Test type use annotations on uses of type variables
+ @Test(posn=5, annoType = TB.class, expect = "81")
+ <@TA(80) T> void m80(@TB(81) String t) { }
+
+ class Inner90<@TA(90) T> {
+ @Test(posn=0, annoType = TB.class, expect = "91")
+ @TB(91) String f;
+ }
+
+ // Recursive bound
+ @Test(posn=4, annoType = TB.class, expect = "100")
+ class Inner100<T extends Inner100<@TB(100) T>> {
+ }
}
--- a/langtools/test/tools/javac/scope/DupUnsharedTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/scope/DupUnsharedTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -68,7 +68,7 @@
}
void runScopeContentTest() throws Exception {
- Set<Symbol> expected = Collections.newSetFromMap(new IdentityHashMap<>());
+ Set<Symbol> expected = Collections.newSetFromMap(new IdentityHashMap<>() {});
Set<Symbol> notExpected = Collections.newSetFromMap(new IdentityHashMap<>());
WriteableScope s1 = WriteableScope.create(symtab.rootPackage);
ClassSymbol acceptSym = symtab.arrayClass;
@@ -105,7 +105,7 @@
}
Set<Symbol> toSet(Iterable<Symbol> it) {
- Set<Symbol> result = Collections.newSetFromMap(new IdentityHashMap<>());
+ Set<Symbol> result = Collections.newSetFromMap(new IdentityHashMap<>() {});
for (Symbol sym : it) {
result.add(sym);
--- a/langtools/test/tools/javac/warnings/6747671/T6747671.out Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javac/warnings/6747671/T6747671.out Tue Apr 14 12:10:00 2015 -0700
@@ -7,6 +7,6 @@
T6747671.java:32:9: compiler.warn.raw.class.use: T6747671.A, T6747671<E>.A<X>
T6747671.java:32:20: compiler.warn.raw.class.use: T6747671.A, T6747671<E>.A<X>
T6747671.java:33:16: compiler.warn.raw.class.use: T6747671.A.Z, T6747671<E>.A<X>.Z<Y>
-T6747671.java:36:9: compiler.warn.raw.class.use: @T6747671.TA T6747671.B, T6747671.B<X>
+T6747671.java:36:9: compiler.warn.raw.class.use: T6747671.B, T6747671.B<X>
T6747671.java:36:27: compiler.warn.raw.class.use: T6747671.B, T6747671.B<X>
11 warnings
--- a/langtools/test/tools/javadoc/api/basic/GetTask_FileManagerTest.java Mon Apr 13 17:03:11 2015 -0700
+++ b/langtools/test/tools/javadoc/api/basic/GetTask_FileManagerTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -45,8 +45,6 @@
import javax.tools.ToolProvider;
import com.sun.tools.javac.file.JavacFileManager;
-import com.sun.tools.javac.nio.JavacPathFileManager;
-import com.sun.tools.javac.nio.PathFileManager;
import com.sun.tools.javac.util.Context;
/**
@@ -59,7 +57,7 @@
/**
* Verify that an alternate file manager can be specified:
- * in this case, a PathFileManager.
+ * in this case, a TestFileManager.
*/
@Test
public void testFileManager() throws Exception {
--- a/make/Help.gmk Mon Apr 13 17:03:11 2015 -0700
+++ b/make/Help.gmk Tue Apr 14 12:10:00 2015 -0700
@@ -88,28 +88,15 @@
$(info $(_) # make test TEST="jdk_lang jdk_net")
$(info )
$(if $(all_confs), $(info Available configurations in $(build_dir):) $(foreach var,$(all_confs),$(info * $(var))),\
- $(info No configurations were found in $(build_dir).) $(info Run 'bash configure' to create a configuration))
+ $(info No configurations were found in $(build_dir).) $(info Run 'bash configure' to create a configuration.))
# We need a dummy rule otherwise make will complain
@true
-print-targets:
- $(if $(any_spec_file), ,\
- @echo "Note: More targets will be available when at least one configuration exists." 1>&2\
- )
- @echo $(ALL_TARGETS)
-
-print-modules:
- $(if $(any_spec_file), \
- @$(MAKE) -s -f $(topdir)/make/Main.gmk -I $(topdir)/make/common SPEC=$(any_spec_file) print-modules \
- , \
- @echo print-modules can currently only be run when at least one configuration exists \
- )
-
print-configurations:
$(foreach var, $(all_confs), $(info $(var)))
# We need a dummy rule otherwise make will complain
@true
-ALL_GLOBAL_TARGETS := help print-modules print-targets print-configurations
+ALL_GLOBAL_TARGETS := help print-configurations
.PHONY: $(ALL_GLOBAL_TARGETS)
--- a/make/Init.gmk Mon Apr 13 17:03:11 2015 -0700
+++ b/make/Init.gmk Tue Apr 14 12:10:00 2015 -0700
@@ -37,84 +37,102 @@
# serially, regardless of -j.
.NOTPARALLEL:
-# If included from the top-level Makefile then topdir is set, but not when
-# recursively calling ourself with a spec.
-ifeq ($(topdir),)
- topdir := $(strip $(patsubst %/make/, %, $(dir $(lastword $(MAKEFILE_LIST)))))
-endif
-
-# Our helper functions. Will include $(SPEC) if $(HAS_SPEC) is true.
-include $(topdir)/make/InitSupport.gmk
-
-# Here are "global" targets, i.e. targets that can be executed without having a configuration.
-# This will define ALL_GLOBAL_TARGETS.
-include $(topdir)/make/Help.gmk
-
-# Extract main targets from Main.gmk.
-ifneq ($(any_spec_file), )
- ifeq ($(wildcard $(dir $(any_spec_file))/make-support/module-deps.gmk),)
- # If make-support does not exist, we need to build the genmodules java tool first.
- $(info Creating data for first make execution in new configuration...)
- ignore_output := $(shell $(MAKE) -r -R -f $(topdir)/make/Main.gmk \
- -I $(topdir)/make/common SPEC=$(any_spec_file) NO_RECIPES=true FRC)
- $(info Done)
- endif
- ALL_MAIN_TARGETS := $(shell $(MAKE) -r -R -f $(topdir)/make/Main.gmk \
- -I $(topdir)/make/common SPEC=$(any_spec_file) NO_RECIPES=true print-targets)
-else
- # Without at least a single valid configuration, we cannot extract any real
- # targets. To provide a helpful error message about the missing configuration
- # later on, accept whatever targets the user has provided for now.
- ALL_MAIN_TARGETS := $(if $(MAKECMDGOALS), $(MAKECMDGOALS), default)
-endif
-
-# Targets provided by this file.
-ALL_INIT_TARGETS := reconfigure
-
-ALL_TARGETS := $(sort $(ALL_GLOBAL_TARGETS) $(ALL_MAIN_TARGETS) $(ALL_INIT_TARGETS))
-
-ifneq ($(findstring qp, $(MAKEFLAGS)),)
+ifeq ($(HAS_SPEC),)
##############################################################################
- # When called with -qp, assume an external part (e.g. bash completion) is trying
- # to understand our targets. Just list our targets and do no more checking.
+ # This is the default mode. We have not been recursively called with a SPEC.
##############################################################################
- $(ALL_TARGETS):
-
- .PHONY: $(ALL_TARGETS)
-
-else ifeq ($(HAS_SPEC),)
-
- ##############################################################################
- # This is the normal case, we have been called from the command line by the
- # user and we need to call ourself back with a proper SPEC.
- ##############################################################################
+ # Include our helper functions.
+ include $(topdir)/make/InitSupport.gmk
- $(eval $(call CheckControlVariables))
- $(eval $(call CheckDeprecatedEnvironment))
- $(eval $(call CheckInvalidMakeFlags))
-
- $(eval $(call ParseConfCheckOption))
+ # Here are "global" targets, i.e. targets that can be executed without having
+ # a configuration. This will define ALL_GLOBAL_TARGETS.
+ include $(topdir)/make/Help.gmk
- # Check that the LOG given is valid, and set LOG_LEVEL, LOG_NOFILE and MAKE_LOG_FLAGS.
- $(eval $(call ParseLogLevel))
-
- ifneq ($(findstring $(LOG_LEVEL),info debug trace),)
- $(info Running make as '$(strip $(MAKE) $(MFLAGS) $(COMMAND_LINE_VARIABLES) $(MAKECMDGOALS))')
- endif
+ # Targets provided by Init.gmk.
+ ALL_INIT_TARGETS := print-modules print-targets reconfigure
# CALLED_TARGETS is the list of targets that the user provided,
# or "default" if unspecified.
CALLED_TARGETS := $(if $(MAKECMDGOALS), $(MAKECMDGOALS), default)
- CALLED_SPEC_TARGETS := $(filter $(ALL_MAIN_TARGETS) $(ALL_INIT_TARGETS), $(CALLED_TARGETS))
- ifneq ($(CALLED_SPEC_TARGETS),)
- # We have at least one non-global target, which need a SPEC
+
+ # Extract non-global targets that require a spec file.
+ CALLED_SPEC_TARGETS := $(filter-out $(ALL_GLOBAL_TARGETS), $(CALLED_TARGETS))
+
+ # If we have only global targets, or if we are called with -qp (assuming an
+ # external part, e.g. bash completion, is trying to understand our targets),
+ # we will skip SPEC location and the sanity checks.
+ ifeq ($(CALLED_SPEC_TARGETS), )
+ ONLY_GLOBAL_TARGETS := true
+ endif
+ ifneq ($(findstring qp, $(MAKEFLAGS)),)
+ ONLY_GLOBAL_TARGETS := true
+ endif
+
+ ifeq ($(ONLY_GLOBAL_TARGETS), true)
+ ############################################################################
+ # We have only global targets, or are called with -pq.
+ ############################################################################
+
+ ifeq ($(wildcard $(SPEC)), )
+ # If we have no SPEC provided, we will just make a "best effort" target list.
+ # First try to grab any available pre-existing main-targets.gmk.
+ main_targets_file := $(firstword $(wildcard $(build_dir)/*/make-support/main-targets.gmk))
+ ifneq ($(main_targets_file), )
+ # Extract the SPEC that corresponds to this main-targets.gmk file.
+ SPEC := $(patsubst %/make-support/main-targets.gmk, %/spec.gmk, $(main_targets_file))
+ else
+ # None found, pick an arbitrary SPEC for which to generate a file
+ SPEC := $(firstword $(all_spec_files))
+ endif
+ endif
+
+ ifneq ($(wildcard $(SPEC)), )
+ $(eval $(call DefineMainTargets, LAZY, $(SPEC)))
+ else
+ # If we have no configurations we can not provide any main targets.
+ ALL_MAIN_TARGETS :=
+ endif
+
+ ALL_TARGETS := $(sort $(ALL_GLOBAL_TARGETS) $(ALL_MAIN_TARGETS) $(ALL_INIT_TARGETS))
+
+ # Just list all our targets.
+ $(ALL_TARGETS):
+
+ .PHONY: $(ALL_TARGETS)
+
+ else
+ ############################################################################
+ # This is the normal case, we have been called from the command line by the
+ # user and we need to call ourself back with a proper SPEC.
+ # We have at least one non-global target, so we need to find a spec file.
+ ############################################################################
+
+ # Basic checks on environment and command line.
+ $(eval $(call CheckControlVariables))
+ $(eval $(call CheckDeprecatedEnvironment))
+ $(eval $(call CheckInvalidMakeFlags))
+
+ # Check that CONF_CHECK is valid.
+ $(eval $(call ParseConfCheckOption))
+
+ # Check that the LOG given is valid, and set LOG_LEVEL, LOG_NOFILE and MAKE_LOG_FLAGS.
+ $(eval $(call ParseLogLevel))
+
+ # After this SPECS contain 1..N spec files (otherwise ParseConfAndSpec fails).
$(eval $(call ParseConfAndSpec))
- # Now SPECS contain 1..N spec files (otherwise ParseConfAndSpec fails)
+ # Extract main targets from Main.gmk using the spec(s) provided. In theory,
+ # with multiple specs, we should find the intersection of targets provided
+ # by all specs, but we approximate this by an arbitrary spec from the list.
+ # This will setup ALL_MAIN_TARGETS.
+ $(eval $(call DefineMainTargets, FORCE, $(firstword $(SPECS))))
+
+ # Separate called targets depending on type.
INIT_TARGETS := $(filter $(ALL_INIT_TARGETS), $(CALLED_SPEC_TARGETS))
- SEQUENTIAL_TARGETS := $(filter dist-clean clean%, $(CALLED_SPEC_TARGETS))
- PARALLEL_TARGETS := $(filter-out $(INIT_TARGETS) $(SEQUENTIAL_TARGETS), $(CALLED_SPEC_TARGETS))
+ MAIN_TARGETS := $(filter $(ALL_MAIN_TARGETS), $(CALLED_SPEC_TARGETS))
+ SEQUENTIAL_TARGETS := $(filter dist-clean clean%, $(MAIN_TARGETS))
+ PARALLEL_TARGETS := $(filter-out $(SEQUENTIAL_TARGETS), $(MAIN_TARGETS))
# The spec files depend on the autoconf source code. This check makes sure
# the configuration is up to date after changes to configure.
@@ -126,30 +144,41 @@
else ifeq ($(CONF_CHECK), auto)
@echo "Note: The configuration is not up to date for '$(lastword $(subst /, , $(dir $@)))'."
@( cd $(topdir) && \
- $(MAKE) $(MFLAGS) $(MAKE_LOG_FLAGS) -f $(topdir)/make/Init.gmk SPEC=$@ HAS_SPEC=true \
+ $(MAKE) $(MFLAGS) $(MAKE_LOG_FLAGS) -r -R -f $(topdir)/make/Init.gmk \
+ SPEC=$@ HAS_SPEC=true ACTUAL_TOPDIR=$(topdir) \
reconfigure )
else ifeq ($(CONF_CHECK), ignore)
# Do nothing
endif
- # Unless reconfigure is explicitely called, let all targets depend on the spec files to be up to date.
- ifeq ($(findstring reconfigure, $(CALLED_SPEC_TARGETS)), )
- $(CALLED_SPEC_TARGETS): $(SPECS)
+ # Unless reconfigure is explicitely called, let all main targets depend on
+ # the spec files to be up to date.
+ ifeq ($(findstring reconfigure, $(INIT_TARGETS)), )
+ $(MAIN_TARGETS): $(SPECS)
endif
- # The recipe will be run once for every target specified, but we only want to execute the
- # recipe a single time, hence the TARGET_DONE with a dummy command if true.
- $(ALL_MAIN_TARGETS) $(ALL_INIT_TARGETS):
+ make-info:
+ ifneq ($(findstring $(LOG_LEVEL),info debug trace),)
+ $(info Running make as '$(strip $(MAKE) $(MFLAGS) \
+ $(COMMAND_LINE_VARIABLES) $(MAKECMDGOALS))')
+ endif
+
+ # Now the init and main targets will be called, once for each SPEC. The
+ # recipe will be run once for every target specified, but we only want to
+ # execute the recipe a single time, hence the TARGET_DONE with a dummy
+ # command if true.
+ $(ALL_INIT_TARGETS) $(ALL_MAIN_TARGETS): make-info
@$(if $(TARGET_DONE), \
true \
, \
$(foreach spec, $(SPECS), \
( cd $(topdir) && \
- $(MAKE) $(MFLAGS) $(MAKE_LOG_FLAGS) -j 1 -f $(topdir)/make/Init.gmk \
- SPEC=$(spec) HAS_SPEC=true \
+ $(MAKE) $(MFLAGS) $(MAKE_LOG_FLAGS) -r -R -j 1 -f $(topdir)/make/Init.gmk \
+ SPEC=$(spec) HAS_SPEC=true ACTUAL_TOPDIR=$(topdir) \
USER_MAKE_VARS="$(USER_MAKE_VARS)" MAKE_LOG_FLAGS=$(MAKE_LOG_FLAGS) \
LOG_LEVEL=$(LOG_LEVEL) LOG_NOFILE=$(LOG_NOFILE) \
- INIT_TARGETS="$(INIT_TARGETS)" SEQUENTIAL_TARGETS="$(SEQUENTIAL_TARGETS)" \
+ INIT_TARGETS="$(INIT_TARGETS)" \
+ SEQUENTIAL_TARGETS="$(SEQUENTIAL_TARGETS)" \
PARALLEL_TARGETS="$(PARALLEL_TARGETS)" \
main ) && \
) true \
@@ -158,7 +187,7 @@
.PHONY: $(ALL_MAIN_TARGETS) $(ALL_INIT_TARGETS)
- endif # has $(CALLED_SPEC_TARGETS)
+ endif # $(ONLY_GLOBAL_TARGETS)!=true
else # HAS_SPEC=true
@@ -168,6 +197,14 @@
# file.
##############################################################################
+ include $(SPEC)
+
+ # Our helper functions.
+ include $(TOPDIR)/make/InitSupport.gmk
+
+ # Verify that the spec file we included seems okay.
+ $(eval $(call CheckSpecSanity))
+
ifeq ($(LOG_NOFILE), true)
# Disable log wrapper if LOG=[level,]nofile was given
override BUILD_LOG_WRAPPER :=
@@ -177,7 +214,19 @@
OUTPUT_SYNC_FLAG := -O$(OUTPUT_SYNC)
endif
- $(eval $(call CheckSpecSanity))
+ ##############################################################################
+ # Init targets
+ ##############################################################################
+
+ print-modules:
+ ( cd $(TOPDIR) && \
+ $(MAKE) $(MAKE_ARGS) -j 1 -f make/Main.gmk $(USER_MAKE_VARS) \
+ NO_RECIPES=true print-modules )
+
+ print-targets:
+ ( cd $(TOPDIR) && \
+ $(MAKE) $(MAKE_ARGS) -j 1 -f make/Main.gmk $(USER_MAKE_VARS) \
+ NO_RECIPES=true print-targets )
reconfigure:
ifneq ($(CONFIGURE_COMMAND_LINE), )
@@ -188,42 +237,43 @@
( cd $(OUTPUT_ROOT) && PATH="$(ORIGINAL_PATH)" \
$(BASH) $(TOPDIR)/configure $(CONFIGURE_COMMAND_LINE) )
- main-init:
- $(call RotateLogFiles)
- $(BUILD_LOG_WRAPPER) $(PRINTF) "Building target(s) '$(strip \
- $(INIT_TARGETS) $(SEQUENTIAL_TARGETS) $(PARALLEL_TARGETS) \
- )' in configuration '$(CONF_NAME)'\n"
+ ##############################################################################
+ # The main target, for delegating into Main.gmk
+ ##############################################################################
+ MAIN_TARGETS := $(SEQUENTIAL_TARGETS) $(PARALLEL_TARGETS)
+ TARGET_DESCRIPTION := target$(if $(word 2, $(MAIN_TARGETS)),s) \
+ '$(strip $(MAIN_TARGETS))' in configuration '$(CONF_NAME)'
# MAKEOVERRIDES is automatically set and propagated by Make to sub-Make calls.
# We need to clear it of the init-specific variables. The user-specified
# variables are explicitely propagated using $(USER_MAKE_VARS).
main: MAKEOVERRIDES :=
- main: $(INIT_TARGETS) main-init
- ifneq ($(SEQUENTIAL_TARGETS), )
- # Don't touch build output dir since we might be cleaning. That means
- # no log wrapper.
- ( cd $(TOPDIR) && \
- $(MAKE) $(MAKE_ARGS) -j 1 -f make/Main.gmk $(USER_MAKE_VARS) \
- $(SEQUENTIAL_TARGETS) \
- )
+ main: $(INIT_TARGETS)
+ ifneq ($(SEQUENTIAL_TARGETS)$(PARALLEL_TARGETS), )
+ $(call RotateLogFiles)
+ $(BUILD_LOG_WRAPPER) $(PRINTF) "Building $(TARGET_DESCRIPTION)\n"
+ ifneq ($(SEQUENTIAL_TARGETS), )
+ # Don't touch build output dir since we might be cleaning. That
+ # means no log wrapper.
+ ( cd $(TOPDIR) && \
+ $(MAKE) $(MAKE_ARGS) -j 1 -f make/Main.gmk $(USER_MAKE_VARS) \
+ $(SEQUENTIAL_TARGETS) )
+ endif
+ ifneq ($(PARALLEL_TARGETS), )
+ $(call StartGlobalTimer)
+ $(call PrepareSmartJavac)
+ ( cd $(TOPDIR) && \
+ $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) $(OUTPUT_SYNC_FLAG) \
+ -j $(JOBS) -f make/Main.gmk $(USER_MAKE_VARS) \
+ $(PARALLEL_TARGETS) )
+ $(call CleanupSmartJavac)
+ $(call StopGlobalTimer)
+ $(call ReportBuildTimes)
+ endif
+ $(BUILD_LOG_WRAPPER) $(PRINTF) "Finished building $(TARGET_DESCRIPTION)\n"
endif
- ifneq ($(PARALLEL_TARGETS), )
- $(call StartGlobalTimer)
- $(call PrepareSmartJavac)
- ( cd $(TOPDIR) && \
- $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) $(OUTPUT_SYNC_FLAG) \
- -j $(JOBS) -f make/Main.gmk $(USER_MAKE_VARS) \
- $(PARALLEL_TARGETS) \
- )
- $(call CleanupSmartJavac)
- $(call StopGlobalTimer)
- $(call ReportBuildTimes)
- endif
- $(BUILD_LOG_WRAPPER) $(PRINTF) "Finished building target(s) '$(strip \
- $(INIT_TARGETS) $(SEQUENTIAL_TARGETS) $(PARALLEL_TARGETS) \
- )' in configuration '$(CONF_NAME)'\n"
- .PHONY: reconfigure main-init main
+ .PHONY: print-targets print-modules reconfigure main
endif
--- a/make/InitSupport.gmk Mon Apr 13 17:03:11 2015 -0700
+++ b/make/InitSupport.gmk Tue Apr 14 12:10:00 2015 -0700
@@ -32,13 +32,6 @@
ifndef _INITSUPPORT_GMK
_INITSUPPORT_GMK := 1
-# Setup information about available configurations, if any.
-build_dir=$(topdir)/build
-all_spec_files=$(wildcard $(build_dir)/*/spec.gmk)
-# Extract the configuration names from the path
-all_confs=$(patsubst %/spec.gmk, %, $(patsubst $(build_dir)/%, %, $(all_spec_files)))
-any_spec_file=$(firstword $(all_spec_files))
-
ifeq ($(HAS_SPEC),)
##############################################################################
# Helper functions for the initial part of Init.gmk, before the spec file is
@@ -62,17 +55,24 @@
# line, but in reverse order to what the user entered.
COMMAND_LINE_VARIABLES := $(subst \#,\ , $(call reverse, $(subst \ ,\#,$(MAKEOVERRIDES))))
- # A list like FOO="val1" BAR="val2" containing all user-supplied make variables
- # that we should propagate.
+ # A list like FOO="val1" BAR="val2" containing all user-supplied make
+ # variables that we should propagate.
USER_MAKE_VARS := $(filter-out $(addsuffix =%, $(INIT_CONTROL_VARIABLES)), \
$(MAKEOVERRIDES))
+ # Setup information about available configurations, if any.
+ build_dir=$(topdir)/build
+ all_spec_files=$(wildcard $(build_dir)/*/spec.gmk)
+ # Extract the configuration names from the path
+ all_confs=$(patsubst %/spec.gmk, %, $(patsubst $(build_dir)/%, %, $(all_spec_files)))
+
# Check for unknown command-line variables
define CheckControlVariables
command_line_variables := $$(strip $$(foreach var, \
$$(subst \ ,_,$$(MAKEOVERRIDES)), \
$$(firstword $$(subst =, , $$(var)))))
- unknown_command_line_variables := $$(strip $$(filter-out $$(MAKE_CONTROL_VARIABLES), $$(command_line_variables)))
+ unknown_command_line_variables := $$(strip \
+ $$(filter-out $$(MAKE_CONTROL_VARIABLES), $$(command_line_variables)))
ifneq ($$(unknown_command_line_variables), )
$$(info Note: Command line contains non-control variables:)
$$(foreach var, $$(unknown_command_line_variables), $$(info * $$(var)=$$($$(var))))
@@ -182,7 +182,7 @@
override SPEC :=
else
# Use spec.gmk files in the build output directory
- ifeq ($$(any_spec_file),)
+ ifeq ($$(all_spec_files),)
$$(info Error: No configurations found for $$(topdir).)
$$(info Please run 'bash configure' to create a configuration.)
$$(info )
@@ -196,7 +196,8 @@
matching_confs := $$(strip $$(all_confs))
else
# Otherwise select those that contain the given CONF string
- matching_confs := $$(strip $$(foreach var, $$(all_confs), $$(if $$(findstring $$(CONF), $$(var)), $$(var))))
+ matching_confs := $$(strip $$(foreach var, $$(all_confs), \
+ $$(if $$(findstring $$(CONF), $$(var)), $$(var))))
endif
ifeq ($$(matching_confs),)
$$(info Error: No configurations found matching CONF=$$(CONF).)
@@ -231,6 +232,37 @@
endif
endef
+ # Extract main targets from Main.gmk using the spec provided in $2.
+ #
+ # Param 1: FORCE = force generation of main-targets.gmk or LAZY = do not force.
+ # Param 2: The SPEC file to use.
+ define DefineMainTargets
+
+ # We will start by making sure the main-targets.gmk file is removed, if
+ # make has not been restarted. By the -include, we will trigger the
+ # rule for generating the file (which is never there since we removed it),
+ # thus generating it fresh, and make will restart, incrementing the restart
+ # count.
+ main_targets_file := $$(dir $(strip $2))make-support/main-targets.gmk
+
+ ifeq ($$(MAKE_RESTARTS),)
+ # Only do this if make has not been restarted, and if we do not force it.
+ ifeq ($(strip $1), FORCE)
+ $$(shell rm -f $$(main_targets_file))
+ endif
+ endif
+
+ $$(main_targets_file):
+ @( cd $$(topdir) && \
+ $$(MAKE) $$(MAKE_LOG_FLAGS) -r -R -f $$(topdir)/make/Main.gmk \
+ -I $$(topdir)/make/common SPEC=$(strip $2) NO_RECIPES=true \
+ LOG_LEVEL=$$(LOG_LEVEL) \
+ create-main-targets-include )
+
+ # Now include main-targets.gmk. This will define ALL_MAIN_TARGETS.
+ -include $$(main_targets_file)
+ endef
+
define PrintConfCheckFailed
@echo ' '
@echo "Please rerun configure! Easiest way to do this is by running"
@@ -242,10 +274,9 @@
else # $(HAS_SPEC)=true
##############################################################################
# Helper functions for the 'main' target. These functions assume a single,
- # proper and existing SPEC is provided, and will load it.
+ # proper and existing SPEC is included.
##############################################################################
- include $(SPEC)
include $(SRC_ROOT)/make/common/MakeBase.gmk
# Define basic logging setup
@@ -263,11 +294,11 @@
# Sanity check the spec file, so it matches this source code
define CheckSpecSanity
- ifneq ($$(topdir), $$(TOPDIR))
- ifneq ($$(topdir), $$(ORIGINAL_TOPDIR))
- ifneq ($$(topdir), $$(CANONICAL_TOPDIR))
+ ifneq ($$(ACTUAL_TOPDIR), $$(TOPDIR))
+ ifneq ($$(ACTUAL_TOPDIR), $$(ORIGINAL_TOPDIR))
+ ifneq ($$(ACTUAL_TOPDIR), $$(CANONICAL_TOPDIR))
$$(info Error: SPEC mismatch! Current working directory)
- $$(info $$(topdir))
+ $$(info $$(ACTUAL_TOPDIR))
$$(info does not match either TOPDIR, ORIGINAL_TOPDIR or CANONICAL_TOPDIR)
$$(info $$(TOPDIR))
$$(info $$(ORIGINAL_TOPDIR))
--- a/make/Main.gmk Mon Apr 13 17:03:11 2015 -0700
+++ b/make/Main.gmk Tue Apr 14 12:10:00 2015 -0700
@@ -544,7 +544,7 @@
CLEAN_DIR_TARGETS := $(addprefix clean-, $(CLEAN_DIRS))
CLEAN_TESTS += hotspot-jtreg-native jdk-jtreg-native
CLEAN_TEST_TARGETS += $(addprefix clean-test-, $(CLEAN_TESTS))
-CLEAN_PHASES := gensrc java native include
+CLEAN_PHASES := gensrc java native include docs
CLEAN_PHASE_TARGETS := $(addprefix clean-, $(CLEAN_PHASES))
CLEAN_MODULE_TARGETS := $(addprefix clean-, $(ALL_MODULES))
# Construct targets of the form clean-$module-$phase
@@ -553,7 +553,7 @@
# Remove everything, except the output from configure.
clean: $(CLEAN_DIR_TARGETS)
- ($(CD) $(OUTPUT_ROOT) && $(RM) -r source_tips build.log* build-trace*.log*)
+ ($(CD) $(OUTPUT_ROOT) && $(RM) -r build*.log*)
$(ECHO) Cleaned all build artifacts.
$(CLEAN_DIR_TARGETS):
@@ -577,13 +577,11 @@
# while classes and touch files end up in jdk.
clean-support: clean-jdk
-clean-docs: clean-docstemp
-
-# Remove everything, including configure configuration.
-# If the output directory was created by configure and now becomes empty, remove it as well.
+# Remove everything, including configure configuration. If the output
+# directory was created by configure and now becomes empty, remove it as well.
dist-clean: clean
- ($(CD) $(OUTPUT_ROOT) && $(RM) -r *spec.gmk config.* configure-arguments \
- Makefile compare.sh tmp javacservers)
+ ($(CD) $(OUTPUT_ROOT) && \
+ $(RM) -r *spec.gmk $(CONFIGURESUPPORT_OUTPUTDIR) Makefile compare.sh ide)
$(if $(filter $(CONF_NAME),$(notdir $(OUTPUT_ROOT))), \
if test "x`$(LS) $(OUTPUT_ROOT)`" != x; then \
$(ECHO) "Warning: Not removing non-empty configuration directory for '$(CONF_NAME)'" ; \
@@ -610,14 +608,19 @@
################################################################################
+# The following targets are intentionally not added to ALL_TARGETS since they
+# are internal only, to support Init.gmk.
+
print-targets:
@$(ECHO) $(sort $(ALL_TARGETS))
print-modules:
@$(ECHO) $(sort $(ALL_MODULES))
-# print-* targets intentionally not added to ALL_TARGETS since they are internal only.
-# The corresponding external targets are in Help.gmk
+create-main-targets-include:
+ @$(ECHO) $(LOG_INFO) Generating main target list
+ @$(ECHO) ALL_MAIN_TARGETS := $(sort $(ALL_TARGETS)) > \
+ $(MAKESUPPORT_OUTPUTDIR)/main-targets.gmk
################################################################################
--- a/make/MainSupport.gmk Mon Apr 13 17:03:11 2015 -0700
+++ b/make/MainSupport.gmk Tue Apr 14 12:10:00 2015 -0700
@@ -41,46 +41,60 @@
# Cleans the dir given as $1
define CleanDir
@$(PRINTF) "Cleaning $(strip $1) build artifacts ..."
- @($(CD) $(OUTPUT_ROOT) && $(RM) -r $1)
+ @$(PRINTF) "\n" $(LOG_DEBUG)
+ ($(CD) $(OUTPUT_ROOT) && $(RM) -r $1)
@$(PRINTF) " done\n"
endef
define CleanTest
@$(PRINTF) "Cleaning test $(strip $1) ..."
- @$(RM) -r $(SUPPORT_OUTPUTDIR)/test/$(strip $(subst -,/,$1))
+ @$(PRINTF) "\n" $(LOG_DEBUG)
+ $(RM) -r $(SUPPORT_OUTPUTDIR)/test/$(strip $(subst -,/,$1))
@$(PRINTF) " done\n"
endef
define Clean-gensrc
@$(PRINTF) "Cleaning gensrc $(if $1,for $(strip $1) )..."
- @$(RM) -r $(SUPPORT_OUTPUTDIR)/gensrc/$(strip $1)
- @$(RM) -r $(SUPPORT_OUTPUTDIR)/gensrc_no_docs/$(strip $1)
+ @$(PRINTF) "\n" $(LOG_DEBUG)
+ $(RM) -r $(SUPPORT_OUTPUTDIR)/gensrc/$(strip $1)
+ $(RM) -r $(SUPPORT_OUTPUTDIR)/gensrc_no_docs/$(strip $1)
@$(PRINTF) " done\n"
endef
define Clean-java
@$(PRINTF) "Cleaning java $(if $1,for $(strip $1) )..."
- @$(RM) -r $(JDK_OUTPUTDIR)/modules/$(strip $1)
- @$(RM) -r $(SUPPORT_OUTPUTDIR)/misc/$(strip $1)
- @$(PRINTF) " done\n"
- @$(PRINTF) "Cleaning headers $(if $1,for $(strip $1)) ..."
- @$(RM) -r $(SUPPORT_OUTPUTDIR)/headers/$(strip $1)
+ @$(PRINTF) "\n" $(LOG_DEBUG)
+ $(RM) -r $(JDK_OUTPUTDIR)/modules/$(strip $1)
+ $(RM) -r $(SUPPORT_OUTPUTDIR)/misc/$(strip $1)
+ $(PRINTF) " done\n"
+ $(PRINTF) "Cleaning headers $(if $1,for $(strip $1)) ..."
+ $(RM) -r $(SUPPORT_OUTPUTDIR)/headers/$(strip $1)
@$(PRINTF) " done\n"
endef
define Clean-native
@$(PRINTF) "Cleaning native $(if $1,for $(strip $1) )..."
- @$(RM) -r $(SUPPORT_OUTPUTDIR)/native/$(strip $1)
- @$(RM) -r $(SUPPORT_OUTPUTDIR)/modules_libs/$(strip $1)
- @$(RM) -r $(SUPPORT_OUTPUTDIR)/modules_libs-stripped/$(strip $1)
- @$(RM) -r $(SUPPORT_OUTPUTDIR)/modules_cmds/$(strip $1)
- @$(RM) -r $(SUPPORT_OUTPUTDIR)/modules_cmds-stripped/$(strip $1)
+ @$(PRINTF) "\n" $(LOG_DEBUG)
+ $(RM) -r $(SUPPORT_OUTPUTDIR)/native/$(strip $1)
+ $(RM) -r $(SUPPORT_OUTPUTDIR)/modules_libs/$(strip $1)
+ $(RM) -r $(SUPPORT_OUTPUTDIR)/modules_libs-stripped/$(strip $1)
+ $(RM) -r $(SUPPORT_OUTPUTDIR)/modules_cmds/$(strip $1)
+ $(RM) -r $(SUPPORT_OUTPUTDIR)/modules_cmds-stripped/$(strip $1)
@$(PRINTF) " done\n"
endef
define Clean-include
@$(PRINTF) "Cleaning include $(if $1,for $(strip $1) )..."
- @$(RM) -r $(SUPPORT_OUTPUTDIR)/modules_include/$(strip $1)
+ @$(PRINTF) "\n" $(LOG_DEBUG)
+ $(RM) -r $(SUPPORT_OUTPUTDIR)/modules_include/$(strip $1)
+ @$(PRINTF) " done\n"
+endef
+
+define Clean-docs
+ @$(PRINTF) "Cleaning docs ..."
+ @$(PRINTF) "\n" $(LOG_DEBUG)
+ $(RM) -r $(SUPPORT_OUTPUTDIR)/docs
+ $(RM) -r $(IMAGES_OUTPUTDIR)/docs
@$(PRINTF) " done\n"
endef
--- a/make/common/NativeCompilation.gmk Mon Apr 13 17:03:11 2015 -0700
+++ b/make/common/NativeCompilation.gmk Tue Apr 14 12:10:00 2015 -0700
@@ -70,6 +70,7 @@
-e 's/\#.*//' \
-e 's/^[^:]*: *//' \
-e 's/ *\\$$$$//' \
+ -e 's/^[ ]*//' \
-e '/^$$$$/ d' \
-e 's/$$$$/ :/' \
#
--- a/nashorn/.hgtags Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/.hgtags Tue Apr 14 12:10:00 2015 -0700
@@ -291,3 +291,5 @@
b2b332e64b7b2e06e25bccae9c0c0b585a03b4b5 jdk9-b55
2e640036000dfadcadaf6638b5fd61db9c71a25c jdk9-b56
3bcfcb13c23402cf435079766eb2f9a3c4f890e8 jdk9-b57
+5096a7cca5f0fda814832ac777966bea893f837e jdk9-b58
+ea4e794c3927df4e03f53202e15a3248375b7902 jdk9-b59
--- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/PrototypeGenerator.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/PrototypeGenerator.java Tue Apr 14 12:10:00 2015 -0700
@@ -124,8 +124,6 @@
if (memberCount > 0) {
// call "super(map$)"
mi.getStatic(className, PROPERTYMAP_FIELD_NAME, PROPERTYMAP_DESC);
- // make sure we use duplicated PropertyMap so that original map
- // stays intact and so can be used for many global.
mi.invokeSpecial(PROTOTYPEOBJECT_TYPE, INIT, SCRIPTOBJECT_INIT_DESC);
// initialize Function type fields
initFunctionFields(mi);
--- a/nashorn/docs/DEVELOPER_README Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/docs/DEVELOPER_README Tue Apr 14 12:10:00 2015 -0700
@@ -63,16 +63,19 @@
See the description of the codegen logger below.
-SYSTEM PROPERTY: -Dnashorn.fields.objects
+SYSTEM PROPERTY: -Dnashorn.fields.objects, -Dnashorn.fields.dual
-When this property is true, Nashorn will only use object fields for
-AccessorProperties. This means that primitive values must be boxed
-when stored in a field, which is significantly slower than using
-primitive fields.
+When the nashorn.fields.objects property is true, Nashorn will always
+use object fields for AccessorProperties, requiring boxing for all
+primitive property values. When nashorn.fields.dual is set, Nashorn
+will always use dual long/object fields, which allows primitives to be
+stored without boxing. When neither system property is set, Nashorn
+chooses a setting depending on the optimistic types setting (dual
+fields when optimistic types are enabled, object-only fields otherwise).
-By default, Nashorn uses dual object and long fields. Ints are
-represented as the 32 low bits of the long fields. Doubles are
-represented as the doubleToLongBits of their value. This way a
+With dual fields, Nashorn uses long fields to store primitive values.
+Ints are represented as the 32 low bits of the long fields. Doubles
+are represented as the doubleToLongBits of their value. This way a
single field can be used for all primitive types. Packing and
unpacking doubles to their bit representation is intrinsified by
the JVM and extremely fast.
--- a/nashorn/make/Makefile Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-#
-# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation. Oracle designates this
-# particular file as subject to the "Classpath" exception as provided
-# by Oracle in the LICENSE file that accompanied this code.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# Locate this Makefile
-ifeq ($(filter /%, $(lastword $(MAKEFILE_LIST))), )
- makefile_path := $(CURDIR)/$(lastword $(MAKEFILE_LIST))
-else
- makefile_path := $(lastword $(MAKEFILE_LIST))
-endif
-repo_dir := $(patsubst %/make/Makefile, %, $(makefile_path))
-
-# What is the name of this subsystem (langtools, corba, etc)?
-subsystem_name := $(notdir $(repo_dir))
-
-# Try to locate top-level makefile
-top_level_makefile := $(repo_dir)/../Makefile
-ifneq ($(wildcard $(top_level_makefile)), )
- $(info Will run $(subsystem_name) target on top-level Makefile)
- $(info WARNING: This is a non-recommended way of building!)
- $(info ===================================================)
-else
- $(info Cannot locate top-level Makefile. Is this repo not checked out as part of a complete forest?)
- $(error Build from top-level Makefile instead)
-endif
-
-all:
- @$(MAKE) -f $(top_level_makefile) $(subsystem_name)
--- a/nashorn/make/build.xml Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/make/build.xml Tue Apr 14 12:10:00 2015 -0700
@@ -281,12 +281,12 @@
<fileset dir="${test.src.dir}/META-INF/services/"/>
</copy>
- <copy todir="${build.test.classes.dir}/jdk/nashorn/internal/runtime/resources">
- <fileset dir="${test.src.dir}/jdk/nashorn/internal/runtime/resources"/>
+ <copy todir="${build.test.classes.dir}/jdk/nashorn/internal/runtime/test/resources">
+ <fileset dir="${test.src.dir}/jdk/nashorn/internal/runtime/test/resources"/>
</copy>
- <copy todir="${build.test.classes.dir}/jdk/nashorn/api/scripting/resources">
- <fileset dir="${test.src.dir}/jdk/nashorn/api/scripting/resources"/>
+ <copy todir="${build.test.classes.dir}/jdk/nashorn/api/scripting/test/resources">
+ <fileset dir="${test.src.dir}/jdk/nashorn/api/scripting/test/resources"/>
</copy>
<!-- tests that check nashorn internals and internal API -->
@@ -402,14 +402,14 @@
<!-- only to be invoked as dependency of "test" target -->
<target name="-test-classes-all" depends="jar" unless="test.class">
<fileset id="test.classes" dir="${build.test.classes.dir}">
- <include name="**/api/javaaccess/*Test.class"/>
- <include name="**/api/scripting/*Test.class"/>
- <include name="**/api/tree/*Test.class"/>
- <include name="**/codegen/*Test.class"/>
- <include name="**/parser/*Test.class"/>
- <include name="**/runtime/*Test.class"/>
- <include name="**/runtime/regexp/*Test.class"/>
- <include name="**/runtime/regexp/joni/*Test.class"/>
+ <include name="**/api/javaaccess/test/*Test.class"/>
+ <include name="**/api/scripting/test/*Test.class"/>
+ <include name="**/api/tree/test/*Test.class"/>
+ <include name="**/codegen/test/*Test.class"/>
+ <include name="**/parser/test/*Test.class"/>
+ <include name="**/runtime/test/*Test.class"/>
+ <include name="**/runtime/regexp/test/*Test.class"/>
+ <include name="**/runtime/regexp/joni/test/*Test.class"/>
<include name="**/framework/*Test.class"/>
</fileset>
</target>
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java Tue Apr 14 12:10:00 2015 -0700
@@ -43,7 +43,6 @@
import static jdk.nashorn.internal.codegen.CompilerConstants.staticCallNoLookup;
import static jdk.nashorn.internal.codegen.CompilerConstants.typeDescriptor;
import static jdk.nashorn.internal.codegen.CompilerConstants.virtualCallNoLookup;
-import static jdk.nashorn.internal.codegen.ObjectClassGenerator.OBJECT_FIELDS_ONLY;
import static jdk.nashorn.internal.ir.Symbol.HAS_SLOT;
import static jdk.nashorn.internal.ir.Symbol.IS_INTERNAL;
import static jdk.nashorn.internal.runtime.UnwarrantedOptimismException.INVALID_PROGRAM_POINT;
@@ -306,6 +305,14 @@
}
/**
+ * Are we using dual primitive/object field representation?
+ * @return true if using dual field representation, false for object-only fields
+ */
+ boolean useDualFields() {
+ return compiler.getContext().useDualFields();
+ }
+
+ /**
* Load an identity node
*
* @param identNode an identity node to load
@@ -1896,10 +1903,10 @@
//this symbol will be put fielded, we can't initialize it as undefined with a known type
@Override
public Class<?> getValueType() {
- if (OBJECT_FIELDS_ONLY || value == null || paramType == null) {
+ if (!useDualFields() || value == null || paramType == null || paramType.isBoolean()) {
return Object.class;
}
- return paramType.isBoolean() ? Object.class : paramType.getTypeClass();
+ return paramType.getTypeClass();
}
});
}
@@ -2555,7 +2562,7 @@
//for literals, a value of null means object type, i.e. the value null or getter setter function
//(I think)
- final Class<?> valueType = (OBJECT_FIELDS_ONLY || value == null || value.getType().isBoolean()) ? Object.class : value.getType().getTypeClass();
+ final Class<?> valueType = (!useDualFields() || value == null || value.getType().isBoolean()) ? Object.class : value.getType().getTypeClass();
tuples.add(new MapTuple<Expression>(key, symbol, Type.typeFor(valueType), value) {
@Override
public Class<?> getValueType() {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CompilerConstants.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CompilerConstants.java Tue Apr 14 12:10:00 2015 -0700
@@ -149,8 +149,11 @@
/** Arguments parameter in scope object constructors; in slot 3 when present */
INIT_ARGUMENTS(null, 3),
- /** prefix for all ScriptObject subclasses with fields, @see ObjectGenerator */
- JS_OBJECT_PREFIX("JO"),
+ /** prefix for all ScriptObject subclasses with dual object/primitive fields, see {@link ObjectClassGenerator} */
+ JS_OBJECT_DUAL_FIELD_PREFIX("JD"),
+
+ /** prefix for all ScriptObject subclasses with object fields only, see {@link ObjectClassGenerator} */
+ JS_OBJECT_SINGLE_FIELD_PREFIX("JO"),
/** name for allocate method in JO objects */
ALLOCATE("allocate"),
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FieldObjectCreator.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FieldObjectCreator.java Tue Apr 14 12:10:00 2015 -0700
@@ -151,7 +151,7 @@
@Override
protected PropertyMap makeMap() {
assert propertyMap == null : "property map already initialized";
- propertyMap = newMapCreator(fieldObjectClass).makeFieldMap(hasArguments(), fieldCount, paddedFieldCount, evalCode);
+ propertyMap = newMapCreator(fieldObjectClass).makeFieldMap(hasArguments(), codegen.useDualFields(), fieldCount, paddedFieldCount, evalCode);
return propertyMap;
}
@@ -166,7 +166,7 @@
private void putField(final MethodEmitter method, final String key, final int fieldIndex, final MapTuple<T> tuple) {
method.dup();
- final Type fieldType = tuple.isPrimitive() ? PRIMITIVE_FIELD_TYPE : Type.OBJECT;
+ final Type fieldType = codegen.useDualFields() && tuple.isPrimitive() ? PRIMITIVE_FIELD_TYPE : Type.OBJECT;
final String fieldClass = getClassName();
final String fieldName = getFieldName(fieldIndex, fieldType);
final String fieldDesc = typeDescriptor(fieldType.getTypeClass());
@@ -202,8 +202,8 @@
*/
private void findClass() {
fieldObjectClassName = isScope() ?
- ObjectClassGenerator.getClassName(fieldCount, paramCount) :
- ObjectClassGenerator.getClassName(paddedFieldCount);
+ ObjectClassGenerator.getClassName(fieldCount, paramCount, codegen.useDualFields()) :
+ ObjectClassGenerator.getClassName(paddedFieldCount, codegen.useDualFields());
try {
this.fieldObjectClass = Context.forStructureClass(Compiler.binaryName(fieldObjectClassName));
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FindScopeDepths.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/FindScopeDepths.java Tue Apr 14 12:10:00 2015 -0700
@@ -207,7 +207,7 @@
final RecompilableScriptFunctionData data = new RecompilableScriptFunctionData(
newFunctionNode,
compiler.getCodeInstaller(),
- ObjectClassGenerator.createAllocationStrategy(newFunctionNode.getThisProperties()),
+ ObjectClassGenerator.createAllocationStrategy(newFunctionNode.getThisProperties(), compiler.getContext().useDualFields()),
nestedFunctions,
externalSymbolDepths.get(fnId),
internalSymbols.get(fnId),
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/MapCreator.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/MapCreator.java Tue Apr 14 12:10:00 2015 -0700
@@ -68,17 +68,17 @@
* @param evalCode is this property map created for 'eval' code?
* @return New map populated with accessor properties.
*/
- PropertyMap makeFieldMap(final boolean hasArguments, final int fieldCount, final int fieldMaximum, final boolean evalCode) {
+ PropertyMap makeFieldMap(final boolean hasArguments, final boolean dualFields, final int fieldCount, final int fieldMaximum, final boolean evalCode) {
final List<Property> properties = new ArrayList<>();
assert tuples != null;
for (final MapTuple<T> tuple : tuples) {
final String key = tuple.key;
final Symbol symbol = tuple.symbol;
- final Class<?> initialType = tuple.getValueType();
+ final Class<?> initialType = dualFields ? tuple.getValueType() : Object.class;
if (symbol != null && !isValidArrayIndex(getArrayIndex(key))) {
- final int flags = getPropertyFlags(symbol, hasArguments, evalCode);
+ final int flags = getPropertyFlags(symbol, hasArguments, evalCode, dualFields);
final Property property = new AccessorProperty(
key,
flags,
@@ -92,7 +92,7 @@
return PropertyMap.newMap(properties, structure.getName(), fieldCount, fieldMaximum, 0);
}
- PropertyMap makeSpillMap(final boolean hasArguments) {
+ PropertyMap makeSpillMap(final boolean hasArguments, final boolean dualFields) {
final List<Property> properties = new ArrayList<>();
int spillIndex = 0;
assert tuples != null;
@@ -100,10 +100,10 @@
for (final MapTuple<T> tuple : tuples) {
final String key = tuple.key;
final Symbol symbol = tuple.symbol;
- final Class<?> initialType = tuple.getValueType();
+ final Class<?> initialType = dualFields ? tuple.getValueType() : Object.class;
if (symbol != null && !isValidArrayIndex(getArrayIndex(key))) {
- final int flags = getPropertyFlags(symbol, hasArguments, false);
+ final int flags = getPropertyFlags(symbol, hasArguments, false, dualFields);
properties.add(
new SpillProperty(
key,
@@ -124,7 +124,7 @@
*
* @return flags to use for fields
*/
- static int getPropertyFlags(final Symbol symbol, final boolean hasArguments, final boolean evalCode) {
+ static int getPropertyFlags(final Symbol symbol, final boolean hasArguments, final boolean evalCode, final boolean dualFields) {
int flags = 0;
if (symbol.isParam()) {
@@ -162,6 +162,10 @@
flags |= Property.NEEDS_DECLARATION;
}
+ if (dualFields) {
+ flags |= Property.DUAL_FIELDS;
+ }
+
return flags;
}
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/MapTuple.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/MapTuple.java Tue Apr 14 12:10:00 2015 -0700
@@ -25,8 +25,6 @@
package jdk.nashorn.internal.codegen;
-import static jdk.nashorn.internal.codegen.ObjectClassGenerator.OBJECT_FIELDS_ONLY;
-
import jdk.nashorn.internal.codegen.types.Type;
import jdk.nashorn.internal.ir.Symbol;
@@ -52,11 +50,11 @@
}
public Class<?> getValueType() {
- return OBJECT_FIELDS_ONLY ? Object.class : null; //until proven otherwise we are undefined, see NASHORN-592 int.class;
+ return null; //until proven otherwise we are undefined, see NASHORN-592 int.class;
}
boolean isPrimitive() {
- return !OBJECT_FIELDS_ONLY && getValueType().isPrimitive() && getValueType() != boolean.class;
+ return getValueType() != null && getValueType().isPrimitive() && getValueType() != boolean.class;
}
@Override
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/ObjectClassGenerator.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/ObjectClassGenerator.java Tue Apr 14 12:10:00 2015 -0700
@@ -31,7 +31,8 @@
import static jdk.nashorn.internal.codegen.CompilerConstants.INIT_MAP;
import static jdk.nashorn.internal.codegen.CompilerConstants.INIT_SCOPE;
import static jdk.nashorn.internal.codegen.CompilerConstants.JAVA_THIS;
-import static jdk.nashorn.internal.codegen.CompilerConstants.JS_OBJECT_PREFIX;
+import static jdk.nashorn.internal.codegen.CompilerConstants.JS_OBJECT_DUAL_FIELD_PREFIX;
+import static jdk.nashorn.internal.codegen.CompilerConstants.JS_OBJECT_SINGLE_FIELD_PREFIX;
import static jdk.nashorn.internal.codegen.CompilerConstants.className;
import static jdk.nashorn.internal.codegen.CompilerConstants.constructorNoLookup;
import static jdk.nashorn.internal.lookup.Lookup.MH;
@@ -99,18 +100,10 @@
*/
private final DebugLogger log;
- /**
- * Should the runtime only use java.lang.Object slots for fields? If this is false, the representation
- * will be a primitive 64-bit long value used for all primitives and a java.lang.Object for references.
- * This introduces a larger number of method handles in the system, as we need to have different getters
- * and setters for the different fields.
- *
- * This is engineered to plug into the TaggedArray implementation, when it's done.
- */
- public static final boolean OBJECT_FIELDS_ONLY = Options.getBooleanProperty("nashorn.fields.objects");
-
- /** The field types in the system */
- private static final List<Type> FIELD_TYPES = new LinkedList<>();
+ /** Field types for object-only fields */
+ private static final Type[] FIELD_TYPES_OBJECT = new Type[] { Type.OBJECT };
+ /** Field types for dual primitive/object fields */
+ private static final Type[] FIELD_TYPES_DUAL = new Type[] { Type.LONG, Type.OBJECT };
/** What type is the primitive type in dual representation */
public static final Type PRIMITIVE_FIELD_TYPE = Type.LONG;
@@ -118,33 +111,27 @@
private static final MethodHandle GET_DIFFERENT = findOwnMH("getDifferent", Object.class, Object.class, Class.class, MethodHandle.class, MethodHandle.class, int.class);
private static final MethodHandle GET_DIFFERENT_UNDEFINED = findOwnMH("getDifferentUndefined", Object.class, int.class);
- /**
- * The list of field types that we support - one type creates one field. This is currently either
- * LONG + OBJECT or just OBJECT for classic mode.
- */
- static {
- if (!OBJECT_FIELDS_ONLY) {
- FIELD_TYPES.add(PRIMITIVE_FIELD_TYPE);
- }
- FIELD_TYPES.add(Type.OBJECT);
- }
private static boolean initialized = false;
/** The context */
private final Context context;
+ private final boolean dualFields;
+
/**
* Constructor
*
* @param context a context
+ * @param dualFields whether to use dual fields representation
*/
- public ObjectClassGenerator(final Context context) {
+ public ObjectClassGenerator(final Context context, final boolean dualFields) {
this.context = context;
+ this.dualFields = dualFields;
assert context != null;
this.log = initLogger(context);
if (!initialized) {
initialized = true;
- if (OBJECT_FIELDS_ONLY) {
+ if (!dualFields) {
log.warning("Running with object fields only - this is a deprecated configuration.");
}
}
@@ -176,16 +163,30 @@
throw new AssertionError("cannot pack" + n);
}
+ private static String getPrefixName(final boolean dualFields) {
+ return dualFields ? JS_OBJECT_DUAL_FIELD_PREFIX.symbolName() : JS_OBJECT_SINGLE_FIELD_PREFIX.symbolName();
+ }
+
+ private static String getPrefixName(final String className) {
+ if (className.startsWith(JS_OBJECT_DUAL_FIELD_PREFIX.symbolName())) {
+ return getPrefixName(true);
+ } else if (className.startsWith(JS_OBJECT_SINGLE_FIELD_PREFIX.symbolName())) {
+ return getPrefixName(false);
+ }
+ throw new AssertionError("Not a structure class: " + className);
+ }
+
/**
* Returns the class name for JavaScript objects with fieldCount fields.
*
* @param fieldCount Number of fields to allocate.
- *
+ * @param dualFields whether to use dual fields representation
* @return The class name.
*/
- public static String getClassName(final int fieldCount) {
- return fieldCount != 0 ? SCRIPTS_PACKAGE + '/' + JS_OBJECT_PREFIX.symbolName() + fieldCount :
- SCRIPTS_PACKAGE + '/' + JS_OBJECT_PREFIX.symbolName();
+ public static String getClassName(final int fieldCount, final boolean dualFields) {
+ final String prefix = getPrefixName(dualFields);
+ return fieldCount != 0 ? SCRIPTS_PACKAGE + '/' + prefix + fieldCount :
+ SCRIPTS_PACKAGE + '/' + prefix;
}
/**
@@ -194,22 +195,23 @@
*
* @param fieldCount Number of fields to allocate.
* @param paramCount Number of parameters to allocate
- *
+ * @param dualFields whether to use dual fields representation
* @return The class name.
*/
- public static String getClassName(final int fieldCount, final int paramCount) {
- return SCRIPTS_PACKAGE + '/' + JS_OBJECT_PREFIX.symbolName() + fieldCount + SCOPE_MARKER + paramCount;
+ public static String getClassName(final int fieldCount, final int paramCount, final boolean dualFields) {
+ return SCRIPTS_PACKAGE + '/' + getPrefixName(dualFields) + fieldCount + SCOPE_MARKER + paramCount;
}
/**
* Returns the number of fields in the JavaScript scope class. Its name had to be generated using either
- * {@link #getClassName(int)} or {@link #getClassName(int, int)}.
+ * {@link #getClassName(int, boolean)} or {@link #getClassName(int, int, boolean)}.
* @param clazz the JavaScript scope class.
* @return the number of fields in the scope class.
*/
public static int getFieldCount(final Class<?> clazz) {
final String name = clazz.getSimpleName();
- final String prefix = JS_OBJECT_PREFIX.symbolName();
+ final String prefix = getPrefixName(name);
+
if (prefix.equals(name)) {
return 0;
}
@@ -238,8 +240,8 @@
* @param className name of class
* @param fieldNames fields to initialize to undefined, where applicable
*/
- private static void initializeToUndefined(final MethodEmitter init, final String className, final List<String> fieldNames) {
- if (!OBJECT_FIELDS_ONLY) {
+ private void initializeToUndefined(final MethodEmitter init, final String className, final List<String> fieldNames) {
+ if (dualFields) {
// no need to initialize anything to undefined in the dual field world
// - then we have a constant getter for undefined for any unknown type
return;
@@ -292,7 +294,7 @@
* @return Byte codes for generated class.
*/
public byte[] generate(final int fieldCount) {
- final String className = getClassName(fieldCount);
+ final String className = getClassName(fieldCount, dualFields);
final String superName = className(ScriptObject.class);
final ClassEmitter classEmitter = newClassEmitter(className, superName);
@@ -322,7 +324,7 @@
* @return Byte codes for generated class.
*/
public byte[] generate(final int fieldCount, final int paramCount) {
- final String className = getClassName(fieldCount, paramCount);
+ final String className = getClassName(fieldCount, paramCount, dualFields);
final String superName = className(FunctionScope.class);
final ClassEmitter classEmitter = newClassEmitter(className, superName);
final List<String> initFields = addFields(classEmitter, fieldCount);
@@ -353,11 +355,11 @@
*
* @return List fields that need to be initialized.
*/
- private static List<String> addFields(final ClassEmitter classEmitter, final int fieldCount) {
+ private List<String> addFields(final ClassEmitter classEmitter, final int fieldCount) {
final List<String> initFields = new LinkedList<>();
-
+ final Type[] fieldTypes = dualFields ? FIELD_TYPES_DUAL : FIELD_TYPES_OBJECT;
for (int i = 0; i < fieldCount; i++) {
- for (final Type type : FIELD_TYPES) {
+ for (final Type type : fieldTypes) {
final String fieldName = getFieldName(i, type);
classEmitter.field(fieldName, type.getTypeClass());
@@ -533,13 +535,10 @@
private static MethodHandle getterForType(final Class<?> forType, final MethodHandle primitiveGetter, final MethodHandle objectGetter) {
switch (getAccessorTypeIndex(forType)) {
case TYPE_INT_INDEX:
- assert !OBJECT_FIELDS_ONLY : "this can only happen with dual fields";
return MH.explicitCastArguments(primitiveGetter, primitiveGetter.type().changeReturnType(int.class));
case TYPE_LONG_INDEX:
- assert !OBJECT_FIELDS_ONLY : "this can only happen with dual fields";
return primitiveGetter;
case TYPE_DOUBLE_INDEX:
- assert !OBJECT_FIELDS_ONLY : "this can only happen with dual fields";
return MH.filterReturnValue(primitiveGetter, UNPACK_DOUBLE);
case TYPE_OBJECT_INDEX:
return objectGetter;
@@ -557,7 +556,7 @@
final boolean isPrimitiveStorage = forType != null && forType.isPrimitive();
//which is the primordial getter
- final MethodHandle getter = OBJECT_FIELDS_ONLY ? objectGetter : isPrimitiveStorage ? primitiveGetter : objectGetter;
+ final MethodHandle getter = primitiveGetter == null ? objectGetter : isPrimitiveStorage ? primitiveGetter : objectGetter;
if (forType == null) {
if (isOptimistic) {
@@ -580,8 +579,7 @@
return MH.dropArguments(GET_UNDEFINED.get(ti), 0, Object.class);
}
- assert forType != null;
- assert !OBJECT_FIELDS_ONLY || forType == Object.class : forType;
+ assert primitiveGetter != null || forType == Object.class : forType;
if (isOptimistic) {
if (fti < ti) {
@@ -635,8 +633,6 @@
return tgetter;
}
- assert !OBJECT_FIELDS_ONLY;
- //final MethodType pmt = primitiveGetter.type();
assert primitiveGetter != null;
final MethodType tgetterType = tgetter.type();
switch (fti) {
@@ -727,7 +723,7 @@
final int fti = getAccessorTypeIndex(forType);
final int ti = getAccessorTypeIndex(type);
- if (fti == TYPE_OBJECT_INDEX || OBJECT_FIELDS_ONLY) {
+ if (fti == TYPE_OBJECT_INDEX || primitiveSetter == null) {
if (ti == TYPE_OBJECT_INDEX) {
return objectSetter;
}
@@ -735,8 +731,6 @@
return MH.asType(objectSetter, objectSetter.type().changeParameterType(1, type));
}
- assert !OBJECT_FIELDS_ONLY;
-
final MethodType pmt = primitiveSetter.type();
switch (fti) {
@@ -832,8 +826,8 @@
* @param thisProperties number of properties assigned to "this"
* @return the allocation strategy
*/
- static AllocationStrategy createAllocationStrategy(final int thisProperties) {
+ static AllocationStrategy createAllocationStrategy(final int thisProperties, final boolean dualFields) {
final int paddedFieldCount = getPaddedFieldCount(thisProperties);
- return new AllocationStrategy(paddedFieldCount);
+ return new AllocationStrategy(paddedFieldCount, dualFields);
}
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/ObjectCreator.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/ObjectCreator.java Tue Apr 14 12:10:00 2015 -0700
@@ -134,7 +134,7 @@
MethodEmitter loadTuple(final MethodEmitter method, final MapTuple<T> tuple, final boolean pack) {
loadValue(tuple.value, tuple.type);
- if (pack && tuple.isPrimitive()) {
+ if (pack && codegen.useDualFields() && tuple.isPrimitive()) {
method.pack();
} else {
method.convert(Type.OBJECT);
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/SpillObjectCreator.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/SpillObjectCreator.java Tue Apr 14 12:10:00 2015 -0700
@@ -27,7 +27,6 @@
import static jdk.nashorn.internal.codegen.CompilerConstants.constructorNoLookup;
import static jdk.nashorn.internal.codegen.CompilerConstants.virtualCallNoLookup;
-import static jdk.nashorn.internal.codegen.ObjectClassGenerator.OBJECT_FIELDS_ONLY;
import java.util.LinkedHashSet;
import java.util.List;
@@ -42,6 +41,7 @@
import jdk.nashorn.internal.runtime.ScriptRuntime;
import jdk.nashorn.internal.runtime.arrays.ArrayData;
import jdk.nashorn.internal.runtime.arrays.ArrayIndex;
+import jdk.nashorn.internal.scripts.JD;
import jdk.nashorn.internal.scripts.JO;
/**
@@ -65,10 +65,13 @@
assert !isScope() : "spill scope objects are not currently supported";
final int length = tuples.size();
- final long[] jpresetValues = new long[ScriptObject.spillAllocationLength(length)];
- final Object[] opresetValues = new Object[ScriptObject.spillAllocationLength(length)];
+ final boolean dualFields = codegen.useDualFields();
+ final int spillLength = ScriptObject.spillAllocationLength(length);
+ final long[] jpresetValues = dualFields ? new long[spillLength] : null;
+ final Object[] opresetValues = new Object[spillLength];
final Set<Integer> postsetValues = new LinkedHashSet<>();
final int callSiteFlags = codegen.getCallSiteFlags();
+ final Class<?> objectClass = dualFields ? JD.class : JO.class;
ArrayData arrayData = ArrayData.allocate(ScriptRuntime.EMPTY_ARRAY);
// Compute constant property values
@@ -88,9 +91,9 @@
final Property property = propertyMap.findProperty(key);
if (property != null) {
// normal property key
- property.setType(JSType.unboxedFieldType(constantValue));
+ property.setType(dualFields ? JSType.unboxedFieldType(constantValue) : Object.class);
final int slot = property.getSlot();
- if (!OBJECT_FIELDS_ONLY && constantValue instanceof Number) {
+ if (dualFields && constantValue instanceof Number) {
jpresetValues[slot] = ObjectClassGenerator.pack((Number)constantValue);
} else {
opresetValues[slot] = constantValue;
@@ -130,28 +133,32 @@
//assert postsetValues.isEmpty() : "test me " + postsetValues;
// create object and invoke constructor
- method._new(JO.class).dup();
+ method._new(objectClass).dup();
codegen.loadConstant(propertyMap);
//load primitive values to j spill array
- codegen.loadConstant(jpresetValues);
- for (final int i : postsetValues) {
- final MapTuple<Expression> tuple = tuples.get(i);
- final Property property = propertyMap.findProperty(tuple.key);
- if (property != null && tuple.isPrimitive()) {
- method.dup();
- method.load(property.getSlot());
- loadTuple(method, tuple);
- method.arraystore();
+ if (dualFields) {
+ codegen.loadConstant(jpresetValues);
+ for (final int i : postsetValues) {
+ final MapTuple<Expression> tuple = tuples.get(i);
+ final Property property = propertyMap.findProperty(tuple.key);
+ if (property != null && tuple.isPrimitive()) {
+ method.dup();
+ method.load(property.getSlot());
+ loadTuple(method, tuple);
+ method.arraystore();
+ }
}
+ } else {
+ method.loadNull();
}
//load object values to o spill array
codegen.loadConstant(opresetValues);
for (final int i : postsetValues) {
- final MapTuple<Expression> tuple = tuples.get(i);
- final Property property = propertyMap.findProperty(tuple.key);
- if (property != null && !tuple.isPrimitive()) {
+ final MapTuple<Expression> tuple = tuples.get(i);
+ final Property property = propertyMap.findProperty(tuple.key);
+ if (property != null && (!dualFields || !tuple.isPrimitive())) {
method.dup();
method.load(property.getSlot());
loadTuple(method, tuple);
@@ -160,7 +167,7 @@
}
//instantiate the script object with spill objects
- method.invoke(constructorNoLookup(JO.class, PropertyMap.class, long[].class, Object[].class));
+ method.invoke(constructorNoLookup(objectClass, PropertyMap.class, long[].class, Object[].class));
// Set prefix array data if any
if (arrayData.length() > 0) {
@@ -171,8 +178,8 @@
// set postfix
for (final int i : postsetValues) {
- final MapTuple<Expression> tuple = tuples.get(i);
- final Property property = propertyMap.findProperty(tuple.key);
+ final MapTuple<Expression> tuple = tuples.get(i);
+ final Property property = propertyMap.findProperty(tuple.key);
if (property == null) {
final int index = ArrayIndex.getArrayIndex(tuple.key);
assert ArrayIndex.isValidArrayIndex(index);
@@ -188,7 +195,9 @@
@Override
protected PropertyMap makeMap() {
assert propertyMap == null : "property map already initialized";
- propertyMap = new MapCreator<>(JO.class, tuples).makeSpillMap(false);
+ final boolean dualFields = codegen.useDualFields();
+ final Class<? extends ScriptObject> clazz = dualFields ? JD.class : JO.class;
+ propertyMap = new MapCreator<>(clazz, tuples).makeSpillMap(false, codegen.useDualFields());
return propertyMap;
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java Tue Apr 14 12:10:00 2015 -0700
@@ -60,6 +60,7 @@
import jdk.nashorn.internal.objects.annotations.Setter;
import jdk.nashorn.internal.runtime.Context;
import jdk.nashorn.internal.runtime.ECMAErrors;
+import jdk.nashorn.internal.runtime.FindProperty;
import jdk.nashorn.internal.runtime.GlobalConstants;
import jdk.nashorn.internal.runtime.GlobalFunctions;
import jdk.nashorn.internal.runtime.JSType;
@@ -78,6 +79,7 @@
import jdk.nashorn.internal.runtime.linker.InvokeByName;
import jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor;
import jdk.nashorn.internal.runtime.regexp.RegExpResult;
+import jdk.nashorn.internal.scripts.JD;
import jdk.nashorn.internal.scripts.JO;
import jdk.nashorn.tools.ShellFunctions;
@@ -717,7 +719,7 @@
private static final MethodHandle LOAD = findOwnMH_S("load", Object.class, Object.class, Object.class);
private static final MethodHandle LOAD_WITH_NEW_GLOBAL = findOwnMH_S("loadWithNewGlobal", Object.class, Object.class, Object[].class);
private static final MethodHandle EXIT = findOwnMH_S("exit", Object.class, Object.class, Object.class);
- private static final MethodHandle LEXICAL_SCOPE_FILTER = findOwnMH_S("lexicalScopeFilter", Object.class, Object.class);
+ private static final MethodHandle LEXICAL_SCOPE_FILTER = findOwnMH_S("lexicalScopeFilter", Object.class, Object.class);
// initialized by nasgen
private static PropertyMap $nasgenmap$;
@@ -749,6 +751,11 @@
return context;
}
+ @Override
+ protected boolean useDualFields() {
+ return context.useDualFields();
+ }
+
// performs initialization checks for Global constructor and returns the
// PropertyMap, if everything is fine.
private static PropertyMap checkAndGetMap(final Context context) {
@@ -932,7 +939,7 @@
* @return the new ScriptObject
*/
public ScriptObject newObject() {
- return new JO(getObjectPrototype(), JO.getInitialMap());
+ return useDualFields() ? new JD(getObjectPrototype()) : new JO(getObjectPrototype());
}
/**
@@ -2204,6 +2211,17 @@
}
@Override
+ protected FindProperty findProperty(final String key, final boolean deep, final ScriptObject start) {
+ if (lexicalScope != null && start != this && start.isScope()) {
+ final FindProperty find = lexicalScope.findProperty(key, false);
+ if (find != null) {
+ return find;
+ }
+ }
+ return super.findProperty(key, deep, start);
+ }
+
+ @Override
public GuardedInvocation findSetMethod(final CallSiteDescriptor desc, final LinkRequest request) {
final boolean isScope = NashornCallSiteDescriptor.isScope(desc);
@@ -2732,8 +2750,8 @@
*/
private static class LexicalScope extends ScriptObject {
- LexicalScope(final ScriptObject proto) {
- super(proto, PropertyMap.newMap());
+ LexicalScope(final Global global) {
+ super(global, PropertyMap.newMap());
}
@Override
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFloat32Array.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFloat32Array.java Tue Apr 14 12:10:00 2015 -0700
@@ -114,12 +114,11 @@
private void setElem(final int index, final double elem) {
try {
- nb.put(index, (float)elem);
+ if (index < nb.limit()) {
+ nb.put(index, (float) elem);
+ }
} catch (final IndexOutOfBoundsException e) {
- //swallow valid array indexes. it's ok.
- if (index < 0) {
- throw new ClassCastException();
- }
+ throw new ClassCastException();
}
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFloat64Array.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFloat64Array.java Tue Apr 14 12:10:00 2015 -0700
@@ -114,12 +114,11 @@
private void setElem(final int index, final double elem) {
try {
- nb.put(index, elem);
+ if (index < nb.limit()) {
+ nb.put(index, elem);
+ }
} catch (final IndexOutOfBoundsException e) {
- //swallow valid array indexes. it's ok.
- if (index < 0) {
- throw new ClassCastException();
- }
+ throw new ClassCastException();
}
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt16Array.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt16Array.java Tue Apr 14 12:10:00 2015 -0700
@@ -115,12 +115,11 @@
private void setElem(final int index, final int elem) {
try {
- nb.put(index, (short)elem);
+ if (index < nb.limit()) {
+ nb.put(index, (short) elem);
+ }
} catch (final IndexOutOfBoundsException e) {
- //swallow valid array indexes. it's ok.
- if (index < 0) {
- throw new ClassCastException();
- }
+ throw new ClassCastException();
}
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt32Array.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt32Array.java Tue Apr 14 12:10:00 2015 -0700
@@ -104,11 +104,11 @@
private void setElem(final int index, final int elem) {
try {
- nb.put(index, elem);
- } catch (final IndexOutOfBoundsException e) {
- if (index < 0) {
- throw new ClassCastException();
- }
+ if (index < nb.limit()) {
+ nb.put(index, elem);
+ }
+ } catch (final IndexOutOfBoundsException e) {
+ throw new ClassCastException();
}
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt8Array.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt8Array.java Tue Apr 14 12:10:00 2015 -0700
@@ -113,12 +113,11 @@
private void setElem(final int index, final int elem) {
try {
- nb.put(index, (byte)elem);
+ if (index < nb.limit()) {
+ nb.put(index, (byte) elem);
+ }
} catch (final IndexOutOfBoundsException e) {
- //swallow valid array indexes. it's ok.
- if (index < 0) {
- throw new ClassCastException();
- }
+ throw new ClassCastException();
}
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeJSAdapter.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeJSAdapter.java Tue Apr 14 12:10:00 2015 -0700
@@ -160,7 +160,7 @@
}
private static ScriptObject wrapAdaptee(final ScriptObject adaptee) {
- return new JO(adaptee, JO.getInitialMap());
+ return new JO(adaptee);
}
@Override
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint16Array.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint16Array.java Tue Apr 14 12:10:00 2015 -0700
@@ -104,12 +104,11 @@
private void setElem(final int index, final int elem) {
try {
- nb.put(index, (char)elem);
+ if (index < nb.limit()) {
+ nb.put(index, (char) elem);
+ }
} catch (final IndexOutOfBoundsException e) {
- //swallow valid array indexes. it's ok.
- if (index < 0) {
- throw new ClassCastException();
- }
+ throw new ClassCastException();
}
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint32Array.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint32Array.java Tue Apr 14 12:10:00 2015 -0700
@@ -113,12 +113,11 @@
private void setElem(final int index, final int elem) {
try {
- nb.put(index, elem);
+ if (index < nb.limit()) {
+ nb.put(index, elem);
+ }
} catch (final IndexOutOfBoundsException e) {
- //swallow valid array indexes. it's ok.
- if (index < 0) {
- throw new ClassCastException();
- }
+ throw new ClassCastException();
}
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint8Array.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint8Array.java Tue Apr 14 12:10:00 2015 -0700
@@ -104,12 +104,11 @@
private void setElem(final int index, final int elem) {
try {
- nb.put(index, (byte)elem);
+ if (index < nb.limit()) {
+ nb.put(index, (byte) elem);
+ }
} catch (final IndexOutOfBoundsException e) {
- //swallow valid array indexes. it's ok.
- if (index < 0) {
- throw new ClassCastException();
- }
+ throw new ClassCastException();
}
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java Tue Apr 14 12:10:00 2015 -0700
@@ -133,18 +133,17 @@
private void setElem(final int index, final int elem) {
try {
- final byte clamped;
- if ((elem & 0xffff_ff00) == 0) {
- clamped = (byte)elem;
- } else {
- clamped = elem < 0 ? 0 : (byte)0xff;
+ if (index < nb.limit()) {
+ final byte clamped;
+ if ((elem & 0xffff_ff00) == 0) {
+ clamped = (byte) elem;
+ } else {
+ clamped = elem < 0 ? 0 : (byte) 0xff;
+ }
+ nb.put(index, clamped);
}
- nb.put(index, clamped);
} catch (final IndexOutOfBoundsException e) {
- //swallow valid array indexes. it's ok.
- if (index < 0) {
- throw new ClassCastException();
- }
+ throw new ClassCastException();
}
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/JSONParser.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/JSONParser.java Tue Apr 14 12:10:00 2015 -0700
@@ -41,6 +41,7 @@
import jdk.nashorn.internal.runtime.SpillProperty;
import jdk.nashorn.internal.runtime.arrays.ArrayData;
import jdk.nashorn.internal.runtime.arrays.ArrayIndex;
+import jdk.nashorn.internal.scripts.JD;
import jdk.nashorn.internal.scripts.JO;
import static jdk.nashorn.internal.parser.TokenType.STRING;
@@ -54,11 +55,10 @@
final private String source;
final private Global global;
+ final private boolean dualFields;
final int length;
int pos = 0;
- private static PropertyMap EMPTY_MAP = PropertyMap.newMap();
-
private static final int EOF = -1;
private static final String TRUE = "true";
@@ -74,10 +74,11 @@
* @param source the source
* @param global the global object
*/
- public JSONParser(final String source, final Global global ) {
+ public JSONParser(final String source, final Global global, final boolean dualFields) {
this.source = source;
this.global = global;
this.length = source.length();
+ this.dualFields = dualFields;
}
/**
@@ -180,7 +181,7 @@
}
private Object parseObject() {
- PropertyMap propertyMap = EMPTY_MAP;
+ PropertyMap propertyMap = dualFields ? JD.getInitialMap() : JO.getInitialMap();
ArrayData arrayData = ArrayData.EMPTY_ARRAY;
final ArrayList<Object> values = new ArrayList<>();
int state = STATE_EMPTY;
@@ -241,36 +242,45 @@
return newArrayData.set(index, value, false);
}
- private static PropertyMap addObjectProperty(final PropertyMap propertyMap, final List<Object> values,
+ private PropertyMap addObjectProperty(final PropertyMap propertyMap, final List<Object> values,
final String id, final Object value) {
final Property oldProperty = propertyMap.findProperty(id);
final PropertyMap newMap;
- final Class<?> type = ObjectClassGenerator.OBJECT_FIELDS_ONLY ? Object.class : getType(value);
+ final Class<?> type;
+ final int flags;
+ if (dualFields) {
+ type = getType(value);
+ flags = Property.DUAL_FIELDS;
+ } else {
+ type = Object.class;
+ flags = 0;
+ }
if (oldProperty != null) {
values.set(oldProperty.getSlot(), value);
- newMap = propertyMap.replaceProperty(oldProperty, new SpillProperty(id, 0, oldProperty.getSlot(), type));;
+ newMap = propertyMap.replaceProperty(oldProperty, new SpillProperty(id, flags, oldProperty.getSlot(), type));;
} else {
values.add(value);
- newMap = propertyMap.addProperty(new SpillProperty(id, 0, propertyMap.size(), type));
+ newMap = propertyMap.addProperty(new SpillProperty(id, flags, propertyMap.size(), type));
}
return newMap;
}
private Object createObject(final PropertyMap propertyMap, final List<Object> values, final ArrayData arrayData) {
- final long[] primitiveSpill = new long[values.size()];
+ final long[] primitiveSpill = dualFields ? new long[values.size()] : null;
final Object[] objectSpill = new Object[values.size()];
for (final Property property : propertyMap.getProperties()) {
- if (property.getType() == Object.class) {
+ if (!dualFields || property.getType() == Object.class) {
objectSpill[property.getSlot()] = values.get(property.getSlot());
} else {
primitiveSpill[property.getSlot()] = ObjectClassGenerator.pack((Number) values.get(property.getSlot()));
}
}
- final ScriptObject object = new JO(propertyMap, primitiveSpill, objectSpill);
+ final ScriptObject object = dualFields ?
+ new JD(propertyMap, primitiveSpill, objectSpill) : new JO(propertyMap, null, objectSpill);
object.setInitialProto(global.getObjectPrototype());
object.setArray(arrayData);
return object;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/AccessorProperty.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/AccessorProperty.java Tue Apr 14 12:10:00 2015 -0700
@@ -25,7 +25,6 @@
package jdk.nashorn.internal.runtime;
-import static jdk.nashorn.internal.codegen.ObjectClassGenerator.OBJECT_FIELDS_ONLY;
import static jdk.nashorn.internal.codegen.ObjectClassGenerator.PRIMITIVE_FIELD_TYPE;
import static jdk.nashorn.internal.codegen.ObjectClassGenerator.createGetter;
import static jdk.nashorn.internal.codegen.ObjectClassGenerator.createSetter;
@@ -98,7 +97,7 @@
objectSetters[i] = MH.asType(MH.setter(LOOKUP, structure, fieldName, typeClass), Lookup.SET_OBJECT_TYPE);
}
- if (!OBJECT_FIELDS_ONLY) {
+ if (!StructureLoader.isSingleFieldStructure(structure.getName())) {
for (int i = 0; i < fieldCount; i++) {
final String fieldNamePrimitive = getFieldName(i, PRIMITIVE_FIELD_TYPE);
final Class<?> typeClass = PRIMITIVE_FIELD_TYPE.getTypeClass();
@@ -211,7 +210,7 @@
* @param setter the property setter or null if non writable, non configurable
*/
private AccessorProperty(final String key, final int flags, final int slot, final MethodHandle getter, final MethodHandle setter) {
- super(key, flags | IS_BUILTIN | (getter.type().returnType().isPrimitive() ? IS_NASGEN_PRIMITIVE : 0), slot);
+ super(key, flags | IS_BUILTIN | DUAL_FIELDS | (getter.type().returnType().isPrimitive() ? IS_NASGEN_PRIMITIVE : 0), slot);
assert !isSpill();
// we don't need to prep the setters these will never be invalidated as this is a nasgen
@@ -221,18 +220,15 @@
final Class<?> setterType = setter == null ? null : setter.type().parameterType(1);
assert setterType == null || setterType == getterType;
- if (OBJECT_FIELDS_ONLY) {
- primitiveGetter = primitiveSetter = null;
+
+ if (getterType == int.class || getterType == long.class) {
+ primitiveGetter = MH.asType(getter, Lookup.GET_PRIMITIVE_TYPE);
+ primitiveSetter = setter == null ? null : MH.asType(setter, Lookup.SET_PRIMITIVE_TYPE);
+ } else if (getterType == double.class) {
+ primitiveGetter = MH.asType(MH.filterReturnValue(getter, ObjectClassGenerator.PACK_DOUBLE), Lookup.GET_PRIMITIVE_TYPE);
+ primitiveSetter = setter == null ? null : MH.asType(MH.filterArguments(setter, 1, ObjectClassGenerator.UNPACK_DOUBLE), Lookup.SET_PRIMITIVE_TYPE);
} else {
- if (getterType == int.class || getterType == long.class) {
- primitiveGetter = MH.asType(getter, Lookup.GET_PRIMITIVE_TYPE);
- primitiveSetter = setter == null ? null : MH.asType(setter, Lookup.SET_PRIMITIVE_TYPE);
- } else if (getterType == double.class) {
- primitiveGetter = MH.asType(MH.filterReturnValue(getter, ObjectClassGenerator.PACK_DOUBLE), Lookup.GET_PRIMITIVE_TYPE);
- primitiveSetter = setter == null ? null : MH.asType(MH.filterArguments(setter, 1, ObjectClassGenerator.UNPACK_DOUBLE), Lookup.SET_PRIMITIVE_TYPE);
- } else {
- primitiveGetter = primitiveSetter = null;
- }
+ primitiveGetter = primitiveSetter = null;
}
assert primitiveGetter == null || primitiveGetter.type() == Lookup.GET_PRIMITIVE_TYPE : primitiveGetter + "!=" + Lookup.GET_PRIMITIVE_TYPE;
@@ -241,7 +237,7 @@
objectGetter = getter.type() != Lookup.GET_OBJECT_TYPE ? MH.asType(getter, Lookup.GET_OBJECT_TYPE) : getter;
objectSetter = setter != null && setter.type() != Lookup.SET_OBJECT_TYPE ? MH.asType(setter, Lookup.SET_OBJECT_TYPE) : setter;
- setType(OBJECT_FIELDS_ONLY ? Object.class : getterType);
+ setType(getterType);
}
/**
@@ -282,6 +278,9 @@
objectSetter = gs.objectSetters[slot];
primitiveSetter = gs.primitiveSetters[slot];
}
+
+ // Always use dual fields except for single field structures
+ assert hasDualFields() != StructureLoader.isSingleFieldStructure(structure.getName());
}
/**
@@ -310,7 +309,7 @@
*/
public AccessorProperty(final String key, final int flags, final Class<?> structure, final int slot, final Class<?> initialType) {
this(key, flags, structure, slot);
- setType(OBJECT_FIELDS_ONLY ? Object.class : initialType);
+ setType(hasDualFields() ? initialType : Object.class);
}
/**
@@ -347,7 +346,7 @@
* @param initialValue initial value
*/
protected final void setInitialValue(final ScriptObject owner, final Object initialValue) {
- setType(JSType.unboxedFieldType(initialValue));
+ setType(hasDualFields() ? JSType.unboxedFieldType(initialValue) : Object.class);
if (initialValue instanceof Integer) {
invokeSetter(owner, ((Integer)initialValue).intValue());
} else if (initialValue instanceof Long) {
@@ -363,7 +362,7 @@
* Initialize the type of a property
*/
protected final void initializeType() {
- setType(OBJECT_FIELDS_ONLY ? Object.class : null);
+ setType(!hasDualFields() ? Object.class : null);
}
private void readObject(final ObjectInputStream s) throws IOException, ClassNotFoundException {
@@ -670,7 +669,7 @@
@Override
public final boolean canChangeType() {
- if (OBJECT_FIELDS_ONLY) {
+ if (!hasDualFields()) {
return false;
}
// Return true for currently undefined even if non-writable/configurable to allow initialization of ES6 CONST.
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/AllocationStrategy.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/AllocationStrategy.java Tue Apr 14 12:10:00 2015 -0700
@@ -44,6 +44,9 @@
/** Number of fields in the allocated object */
private final int fieldCount;
+ /** Whether to use dual field representation */
+ private final boolean dualFields;
+
/** Name of class where allocator function resides */
private transient String allocatorClassName;
@@ -53,15 +56,17 @@
/**
* Construct an allocation strategy with the given map and class name.
* @param fieldCount number of fields in the allocated object
+ * @param dualFields whether to use dual field representation
*/
- public AllocationStrategy(final int fieldCount) {
+ public AllocationStrategy(final int fieldCount, final boolean dualFields) {
this.fieldCount = fieldCount;
+ this.dualFields = dualFields;
}
private String getAllocatorClassName() {
if (allocatorClassName == null) {
// These classes get loaded, so an interned variant of their name is most likely around anyway.
- allocatorClassName = Compiler.binaryName(ObjectClassGenerator.getClassName(fieldCount)).intern();
+ allocatorClassName = Compiler.binaryName(ObjectClassGenerator.getClassName(fieldCount, dualFields)).intern();
}
return allocatorClassName;
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Context.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Context.java Tue Apr 14 12:10:00 2015 -0700
@@ -131,6 +131,23 @@
private static MethodType CREATE_PROGRAM_FUNCTION_TYPE = MethodType.methodType(ScriptFunction.class, ScriptObject.class);
/**
+ * Should scripts use only object slots for fields, or dual long/object slots? The default
+ * behaviour is to couple this to optimistic types, using dual representation if optimistic types are enabled
+ * and single field representation otherwise. This can be overridden by setting either the "nashorn.fields.objects"
+ * or "nashorn.fields.dual" system property.
+ */
+ private final FieldMode fieldMode;
+
+ private static enum FieldMode {
+ /** Value for automatic field representation depending on optimistic types setting */
+ AUTO,
+ /** Value for object field representation regardless of optimistic types setting */
+ OBJECTS,
+ /** Value for dual primitive/object field representation regardless of optimistic types setting */
+ DUAL
+ }
+
+ /**
* Keeps track of which builtin prototypes and properties have been relinked
* Currently we are conservative and associate the name of a builtin class with all
* its properties, so it's enough to invalidate a property to break all assumptions
@@ -434,7 +451,7 @@
* @param appLoader application class loader
*/
public Context(final Options options, final ErrorManager errors, final ClassLoader appLoader) {
- this(options, errors, appLoader, (ClassFilter)null);
+ this(options, errors, appLoader, null);
}
/**
@@ -522,6 +539,14 @@
getErr().println("nashorn full version " + Version.fullVersion());
}
+ if (Options.getBooleanProperty("nashorn.fields.dual")) {
+ fieldMode = FieldMode.DUAL;
+ } else if (Options.getBooleanProperty("nashorn.fields.objects")) {
+ fieldMode = FieldMode.OBJECTS;
+ } else {
+ fieldMode = FieldMode.AUTO;
+ }
+
initLoggers();
}
@@ -576,6 +601,14 @@
}
/**
+ * Should scripts compiled by this context use dual field representation?
+ * @return true if using dual fields, false for object-only fields
+ */
+ public boolean useDualFields() {
+ return fieldMode == FieldMode.DUAL || (fieldMode == FieldMode.AUTO && env._optimistic_types);
+ }
+
+ /**
* Get the PropertyMap of the current global scope
* @return the property map of the current global scope
*/
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/JSONFunctions.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/JSONFunctions.java Tue Apr 14 12:10:00 2015 -0700
@@ -72,7 +72,8 @@
public static Object parse(final Object text, final Object reviver) {
final String str = JSType.toString(text);
final Global global = Context.getGlobal();
- final JSONParser parser = new JSONParser(str, global);
+ final boolean dualFields = ((ScriptObject) global).useDualFields();
+ final JSONParser parser = new JSONParser(str, global, dualFields);
final Object value;
try {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/JSType.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/JSType.java Tue Apr 14 12:10:00 2015 -0700
@@ -26,7 +26,6 @@
package jdk.nashorn.internal.runtime;
import static jdk.nashorn.internal.codegen.CompilerConstants.staticCall;
-import static jdk.nashorn.internal.codegen.ObjectClassGenerator.OBJECT_FIELDS_ONLY;
import static jdk.nashorn.internal.lookup.Lookup.MH;
import static jdk.nashorn.internal.runtime.ECMAErrors.typeError;
@@ -1972,10 +1971,6 @@
* @return primive type or Object.class if not primitive
*/
public static Class<?> unboxedFieldType(final Object o) {
- if (OBJECT_FIELDS_ONLY) {
- return Object.class;
- }
-
if (o == null) {
return Object.class;
} else if (o.getClass() == Integer.class) {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Property.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Property.java Tue Apr 14 12:10:00 2015 -0700
@@ -96,6 +96,9 @@
/** Is this property an ES6 lexical binding? */
public static final int IS_LEXICAL_BINDING = 1 << 10;
+ /** Does this property support dual field representation? */
+ public static final int DUAL_FIELDS = 1 << 11;
+
/** Property key. */
private final String key;
@@ -286,7 +289,7 @@
* @return true if parameter
*/
public boolean isParameter() {
- return (flags & IS_PARAMETER) == IS_PARAMETER;
+ return (flags & IS_PARAMETER) != 0;
}
/**
@@ -294,7 +297,7 @@
* @return true if has arguments
*/
public boolean hasArguments() {
- return (flags & HAS_ARGUMENTS) == HAS_ARGUMENTS;
+ return (flags & HAS_ARGUMENTS) != 0;
}
/**
@@ -316,7 +319,7 @@
* @return true if this is a bound property
*/
public boolean isBound() {
- return (flags & IS_BOUND) == IS_BOUND;
+ return (flags & IS_BOUND) != 0;
}
/**
@@ -325,7 +328,7 @@
* @return true if this is a block-scoped variable
*/
public boolean needsDeclaration() {
- return (flags & NEEDS_DECLARATION) == NEEDS_DECLARATION;
+ return (flags & NEEDS_DECLARATION) != 0;
}
/**
@@ -346,16 +349,6 @@
}
/**
- * Check if a flag is set for a property
- * @param property property
- * @param flag flag to check
- * @return true if flag is set
- */
- public static boolean checkFlag(final Property property, final int flag) {
- return (property.getFlags() & flag) == flag;
- }
-
- /**
* Get the flags for this property
* @return property flags
*/
@@ -364,16 +357,6 @@
}
/**
- * Get the modify flags for this property. The modify flags are the ECMA 8.6.1
- * flags that decide if the Property is writable, configurable and/or enumerable.
- *
- * @return modify flags for property
- */
- public int getModifyFlags() {
- return flags & MODIFY_MASK;
- }
-
- /**
* Remove property flags from the property. Properties are immutable here,
* so any property change that results in a smaller flag set results in the
* property being cloned. Use only the return value
@@ -715,7 +698,7 @@
* @return whether this property is a function declaration or not.
*/
public boolean isFunctionDeclaration() {
- return (flags & IS_FUNCTION_DECLARATION) == IS_FUNCTION_DECLARATION;
+ return (flags & IS_FUNCTION_DECLARATION) != 0;
}
/**
@@ -723,6 +706,14 @@
* @return true if this property represents a lexical binding.
*/
public boolean isLexicalBinding() {
- return (flags & IS_LEXICAL_BINDING) == IS_LEXICAL_BINDING;
+ return (flags & IS_LEXICAL_BINDING) != 0;
+ }
+
+ /**
+ * Does this property support dual fields for both primitive and object values?
+ * @return true if supports dual fields
+ */
+ public boolean hasDualFields() {
+ return (flags & DUAL_FIELDS) != 0;
}
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyMap.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyMap.java Tue Apr 14 12:10:00 2015 -0700
@@ -199,12 +199,21 @@
}
/**
+ * Return a sharable empty map for the given object class.
+ * @param clazz the base object class
+ * @return New empty {@link PropertyMap}.
+ */
+ public static PropertyMap newMap(final Class<? extends ScriptObject> clazz) {
+ return new PropertyMap(EMPTY_HASHMAP, clazz.getName(), 0, 0, 0, false);
+ }
+
+ /**
* Return a sharable empty map.
*
* @return New empty {@link PropertyMap}.
*/
public static PropertyMap newMap() {
- return new PropertyMap(EMPTY_HASHMAP, JO.class.getName(), 0, 0, 0, false);
+ return newMap(JO.class);
}
/**
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java Tue Apr 14 12:10:00 2015 -0700
@@ -28,7 +28,6 @@
import static jdk.nashorn.internal.codegen.CompilerConstants.staticCallNoLookup;
import static jdk.nashorn.internal.codegen.CompilerConstants.virtualCall;
import static jdk.nashorn.internal.codegen.CompilerConstants.virtualCallNoLookup;
-import static jdk.nashorn.internal.codegen.ObjectClassGenerator.OBJECT_FIELDS_ONLY;
import static jdk.nashorn.internal.lookup.Lookup.MH;
import static jdk.nashorn.internal.runtime.ECMAErrors.referenceError;
import static jdk.nashorn.internal.runtime.ECMAErrors.typeError;
@@ -146,12 +145,6 @@
/** Area for reference properties added to object after instantiation, see {@link AccessorProperty} */
protected Object[] objectSpill;
- /**
- * Number of elements in the spill. This may be less than the spill array lengths, if not all of
- * the allocated memory is in use
- */
- private int spillLength;
-
/** Indexed array data. */
private ArrayData arrayData;
@@ -171,12 +164,6 @@
/** Method handle for getting the array data */
public static final Call GET_ARRAY = virtualCall(MethodHandles.lookup(), ScriptObject.class, "getArray", ArrayData.class);
- /** Method handle for getting the property map - debugging purposes */
- public static final Call GET_MAP = virtualCall(MethodHandles.lookup(), ScriptObject.class, "getMap", PropertyMap.class);
-
- /** Method handle for setting the array data */
- public static final Call SET_ARRAY = virtualCall(MethodHandles.lookup(), ScriptObject.class, "setArray", void.class, ArrayData.class);
-
/** Method handle for getting a function argument at a given index. Used from MapCreator */
public static final Call GET_ARGUMENT = virtualCall(MethodHandles.lookup(), ScriptObject.class, "getArgument", Object.class, int.class);
@@ -259,8 +246,7 @@
this(map);
this.primitiveSpill = primitiveSpill;
this.objectSpill = objectSpill;
- assert primitiveSpill.length == objectSpill.length : " primitive spill pool size is not the same length as object spill pool size";
- this.spillLength = spillAllocationLength(primitiveSpill.length);
+ assert primitiveSpill == null || primitiveSpill.length == objectSpill.length : " primitive spill pool size is not the same length as object spill pool size";
}
/**
@@ -727,7 +713,7 @@
setArray(getArray().ensure(longIndex));
doesNotHaveEnsureDelete(longIndex, oldLength, false);
}
- setArray(getArray().set(index,value, false));
+ setArray(getArray().set(index, value, false));
}
private void checkIntegerKey(final String key) {
@@ -812,7 +798,7 @@
*
* @return FindPropertyData or null if not found.
*/
- FindProperty findProperty(final String key, final boolean deep, final ScriptObject start) {
+ protected FindProperty findProperty(final String key, final boolean deep, final ScriptObject start) {
final PropertyMap selfMap = getMap();
final Property property = selfMap.findProperty(key);
@@ -976,10 +962,10 @@
* @param setter setter for {@link UserAccessorProperty}, null if not present or N/A
*/
protected final void initUserAccessors(final String key, final int propertyFlags, final ScriptFunction getter, final ScriptFunction setter) {
- final int slot = spillLength;
- ensureSpillSize(spillLength); //arguments=slot0, caller=slot0
+ final PropertyMap oldMap = getMap();
+ final int slot = oldMap.getFreeSpillSlot();
+ ensureSpillSize(slot);
objectSpill[slot] = new UserAccessorProperty.Accessors(getter, setter);
- final PropertyMap oldMap = getMap();
Property newProperty;
PropertyMap newMap;
do {
@@ -1006,19 +992,12 @@
final int slot = uc.getSlot();
assert uc.getLocalType() == Object.class;
- if (slot >= spillLength) {
- uc.setAccessors(this, getMap(), new UserAccessorProperty.Accessors(getter, setter));
- } else {
- final UserAccessorProperty.Accessors gs = uc.getAccessors(this); //this crashes
- if (gs == null) {
- uc.setAccessors(this, getMap(), new UserAccessorProperty.Accessors(getter, setter));
- } else {
- //reuse existing getter setter for speed
- gs.set(getter, setter);
- if (uc.getFlags() == propertyFlags) {
- return oldProperty;
- }
- }
+ final UserAccessorProperty.Accessors gs = uc.getAccessors(this); //this crashes
+ assert gs != null;
+ //reuse existing getter setter for speed
+ gs.set(getter, setter);
+ if (uc.getFlags() == propertyFlags) {
+ return oldProperty;
}
newProperty = new UserAccessorProperty(uc.getKey(), propertyFlags, slot);
} else {
@@ -2053,8 +2032,6 @@
protoSwitchPoint = null;
}
- assert OBJECT_FIELDS_ONLY || guard != null : "we always need a map guard here";
-
final GuardedInvocation inv = new GuardedInvocation(mh, guard, protoSwitchPoint, exception);
return inv.addSwitchPoint(findBuiltinSwitchPoint(name));
}
@@ -2531,13 +2508,14 @@
/**
* Add a spill property for the given key.
- * @param key Property key.
- * @param propertyFlags Property flags.
+ * @param key Property key.
+ * @param flags Property flags.
* @return Added property.
*/
- private Property addSpillProperty(final String key, final int propertyFlags, final Object value, final boolean hasInitialValue) {
+ private Property addSpillProperty(final String key, final int flags, final Object value, final boolean hasInitialValue) {
final PropertyMap propertyMap = getMap();
final int fieldSlot = propertyMap.getFreeFieldSlot();
+ final int propertyFlags = flags | (useDualFields() ? Property.DUAL_FIELDS : 0);
Property property;
if (fieldSlot > -1) {
@@ -2562,7 +2540,7 @@
* @return Setter method handle.
*/
MethodHandle addSpill(final Class<?> type, final String key) {
- return addSpillProperty(key, 0, null, false).getSetter(OBJECT_FIELDS_ONLY ? Object.class : type, getMap());
+ return addSpillProperty(key, 0, null, false).getSetter(type, getMap());
}
/**
@@ -2649,9 +2627,9 @@
final int spreadArgs = mh.type().parameterCount() - callSiteParamCount + 1;
return MH.filterArguments(
MH.asSpreader(
- mh,
- Object[].class,
- spreadArgs),
+ mh,
+ Object[].class,
+ spreadArgs),
callSiteParamCount - 1,
MH.insertArguments(
TRUNCATINGFILTER,
@@ -3739,24 +3717,32 @@
return uc;
}
+ /**
+ * Returns {@code true} if properties for this object should use dual field mode, {@code false} otherwise.
+ * @return {@code true} if dual fields should be used.
+ */
+ protected boolean useDualFields() {
+ return !StructureLoader.isSingleFieldStructure(getClass().getName());
+ }
+
Object ensureSpillSize(final int slot) {
- if (slot < spillLength) {
+ final int oldLength = objectSpill == null ? 0 : objectSpill.length;
+ if (slot < oldLength) {
return this;
}
final int newLength = alignUp(slot + 1, SPILL_RATE);
final Object[] newObjectSpill = new Object[newLength];
- final long[] newPrimitiveSpill = OBJECT_FIELDS_ONLY ? null : new long[newLength];
+ final long[] newPrimitiveSpill = useDualFields() ? new long[newLength] : null;
if (objectSpill != null) {
- System.arraycopy(objectSpill, 0, newObjectSpill, 0, spillLength);
- if (!OBJECT_FIELDS_ONLY) {
- System.arraycopy(primitiveSpill, 0, newPrimitiveSpill, 0, spillLength);
+ System.arraycopy(objectSpill, 0, newObjectSpill, 0, oldLength);
+ if (primitiveSpill != null && newPrimitiveSpill != null) {
+ System.arraycopy(primitiveSpill, 0, newPrimitiveSpill, 0, oldLength);
}
}
this.primitiveSpill = newPrimitiveSpill;
this.objectSpill = newObjectSpill;
- this.spillLength = newLength;
return this;
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/SetMethodCreator.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/SetMethodCreator.java Tue Apr 14 12:10:00 2015 -0700
@@ -232,14 +232,18 @@
}
private SetMethod createNewFieldSetter(final SwitchPoint builtinSwitchPoint) {
- return createNewSetter(new AccessorProperty(getName(), 0, sobj.getClass(), getMap().getFreeFieldSlot(), type), builtinSwitchPoint);
+ return createNewSetter(new AccessorProperty(getName(), getFlags(sobj), sobj.getClass(), getMap().getFreeFieldSlot(), type), builtinSwitchPoint);
}
private SetMethod createNewSpillPropertySetter(final SwitchPoint builtinSwitchPoint) {
- return createNewSetter(new SpillProperty(getName(), 0, getMap().getFreeSpillSlot(), type), builtinSwitchPoint);
+ return createNewSetter(new SpillProperty(getName(), getFlags(sobj), getMap().getFreeSpillSlot(), type), builtinSwitchPoint);
}
private PropertyMap getNewMap(final Property property) {
return getMap().addProperty(property);
}
+
+ private static int getFlags(final ScriptObject scriptObject) {
+ return scriptObject.useDualFields() ? Property.DUAL_FIELDS : 0;
+ }
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/SpillProperty.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/SpillProperty.java Tue Apr 14 12:10:00 2015 -0700
@@ -25,7 +25,6 @@
package jdk.nashorn.internal.runtime;
-import static jdk.nashorn.internal.codegen.ObjectClassGenerator.OBJECT_FIELDS_ONLY;
import static jdk.nashorn.internal.lookup.Lookup.MH;
import java.lang.invoke.MethodHandle;
@@ -139,11 +138,11 @@
}
}
- private static MethodHandle primitiveGetter(final int slot) {
- return OBJECT_FIELDS_ONLY ? null : Accessors.getCached(slot, true, true);
+ private static MethodHandle primitiveGetter(final int slot, final int flags) {
+ return (flags & DUAL_FIELDS) == DUAL_FIELDS ? Accessors.getCached(slot, true, true) : null;
}
- private static MethodHandle primitiveSetter(final int slot) {
- return OBJECT_FIELDS_ONLY ? null : Accessors.getCached(slot, true, false);
+ private static MethodHandle primitiveSetter(final int slot, final int flags) {
+ return (flags & DUAL_FIELDS) == DUAL_FIELDS ? Accessors.getCached(slot, true, false) : null;
}
private static MethodHandle objectGetter(final int slot) {
return Accessors.getCached(slot, false, true);
@@ -160,8 +159,7 @@
* @param slot spill slot
*/
public SpillProperty(final String key, final int flags, final int slot) {
- super(key, flags, slot, primitiveGetter(slot), primitiveSetter(slot), objectGetter(slot), objectSetter(slot));
- assert !OBJECT_FIELDS_ONLY || getLocalType() == Object.class;
+ super(key, flags, slot, primitiveGetter(slot, flags), primitiveSetter(slot, flags), objectGetter(slot), objectSetter(slot));
}
/**
@@ -173,7 +171,7 @@
*/
public SpillProperty(final String key, final int flags, final int slot, final Class<?> initialType) {
this(key, flags, slot);
- setType(OBJECT_FIELDS_ONLY ? Object.class : initialType);
+ setType(hasDualFields() ? initialType : Object.class);
}
SpillProperty(final String key, final int flags, final int slot, final ScriptObject owner, final Object initialValue) {
@@ -216,8 +214,8 @@
@Override
void initMethodHandles(final Class<?> structure) {
final int slot = getSlot();
- primitiveGetter = primitiveGetter(slot);
- primitiveSetter = primitiveSetter(slot);
+ primitiveGetter = primitiveGetter(slot, getFlags());
+ primitiveSetter = primitiveSetter(slot, getFlags());
objectGetter = objectGetter(slot);
objectSetter = objectSetter(slot);
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/StructureLoader.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/StructureLoader.java Tue Apr 14 12:10:00 2015 -0700
@@ -27,7 +27,8 @@
import static jdk.nashorn.internal.codegen.Compiler.SCRIPTS_PACKAGE;
import static jdk.nashorn.internal.codegen.Compiler.binaryName;
-import static jdk.nashorn.internal.codegen.CompilerConstants.JS_OBJECT_PREFIX;
+import static jdk.nashorn.internal.codegen.CompilerConstants.JS_OBJECT_DUAL_FIELD_PREFIX;
+import static jdk.nashorn.internal.codegen.CompilerConstants.JS_OBJECT_SINGLE_FIELD_PREFIX;
import java.security.ProtectionDomain;
import jdk.nashorn.internal.codegen.ObjectClassGenerator;
@@ -36,7 +37,8 @@
* Responsible for on the fly construction of structure classes.
*/
final class StructureLoader extends NashornLoader {
- private static final String JS_OBJECT_PREFIX_EXTERNAL = binaryName(SCRIPTS_PACKAGE) + '.' + JS_OBJECT_PREFIX.symbolName();
+ private static final String SINGLE_FIELD_PREFIX = binaryName(SCRIPTS_PACKAGE) + '.' + JS_OBJECT_SINGLE_FIELD_PREFIX.symbolName();
+ private static final String DUAL_FIELD_PREFIX = binaryName(SCRIPTS_PACKAGE) + '.' + JS_OBJECT_DUAL_FIELD_PREFIX.symbolName();
/**
* Constructor.
@@ -45,14 +47,39 @@
super(parent);
}
+ /**
+ * Returns true if the class name represents a structure object with dual primitive/object fields.
+ * @param name a class name
+ * @return true if a dual field structure class
+ */
+ private static boolean isDualFieldStructure(final String name) {
+ return name.startsWith(DUAL_FIELD_PREFIX);
+ }
+
+ /**
+ * Returns true if the class name represents a structure object with single object-only fields.
+ * @param name a class name
+ * @return true if a single field structure class
+ */
+ static boolean isSingleFieldStructure(final String name) {
+ return name.startsWith(SINGLE_FIELD_PREFIX);
+ }
+
+ /**
+ * Returns true if the class name represents a Nashorn structure object.
+ * @param name a class name
+ * @return true if a structure class
+ */
static boolean isStructureClass(final String name) {
- return name.startsWith(JS_OBJECT_PREFIX_EXTERNAL);
+ return isDualFieldStructure(name) || isSingleFieldStructure(name);
}
@Override
protected Class<?> findClass(final String name) throws ClassNotFoundException {
- if (isStructureClass(name)) {
- return generateClass(name, name.substring(JS_OBJECT_PREFIX_EXTERNAL.length()));
+ if (isDualFieldStructure(name)) {
+ return generateClass(name, name.substring(DUAL_FIELD_PREFIX.length()), true);
+ } else if (isSingleFieldStructure(name)) {
+ return generateClass(name, name.substring(SINGLE_FIELD_PREFIX.length()), false);
}
return super.findClass(name);
}
@@ -63,10 +90,10 @@
* @param descriptor Layout descriptor.
* @return Generated class.
*/
- private Class<?> generateClass(final String name, final String descriptor) {
+ private Class<?> generateClass(final String name, final String descriptor, final boolean dualFields) {
final Context context = Context.getContextTrusted();
- final byte[] code = new ObjectClassGenerator(context).generate(descriptor);
+ final byte[] code = new ObjectClassGenerator(context, dualFields).generate(descriptor);
return defineClass(name, code, 0, code.length, new ProtectionDomain(null, getPermissions(null)));
}
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/WithObject.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/WithObject.java Tue Apr 14 12:10:00 2015 -0700
@@ -198,7 +198,7 @@
* @return FindPropertyData or null if not found.
*/
@Override
- FindProperty findProperty(final String key, final boolean deep, final ScriptObject start) {
+ protected FindProperty findProperty(final String key, final boolean deep, final ScriptObject start) {
// We call findProperty on 'expression' with 'expression' itself as start parameter.
// This way in ScriptObject.setObject we can tell the property is from a 'with' expression
// (as opposed from another non-scope object in the proto chain such as Object.prototype).
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/Bootstrap.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/Bootstrap.java Tue Apr 14 12:10:00 2015 -0700
@@ -74,17 +74,16 @@
* of object fields only, it is fine. However, with dual fields, in order to get
* performance on benchmarks with a lot of object instantiation and then field
* reassignment, it can take slightly more relinks to become stable with type
- * changes swapping out an entire proprety map and making a map guard fail.
- * Therefore the relink threshold is set to 16 for dual fields (now the default).
- * This doesn't seem to have any other negative performance implication.
+ * changes swapping out an entire property map and making a map guard fail.
+ * Since we need to set this value statically it must work with possibly changing
+ * optimistic types and dual fields settings. A higher value does not seem to have
+ * any other negative performance implication when running with object-only fields,
+ * so we choose a higher value here.
*
* See for example octane.gbemu, run with --log=fields:warning to study
* megamorphic behavior
*/
- private static final int NASHORN_DEFAULT_UNSTABLE_RELINK_THRESHOLD =
- ObjectClassGenerator.OBJECT_FIELDS_ONLY ?
- 8 :
- 16;
+ private static final int NASHORN_DEFAULT_UNSTABLE_RELINK_THRESHOLD = 16;
// do not create me!!
private Bootstrap() {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornGuards.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornGuards.java Tue Apr 14 12:10:00 2015 -0700
@@ -33,7 +33,6 @@
import jdk.internal.dynalink.CallSiteDescriptor;
import jdk.internal.dynalink.linker.LinkRequest;
import jdk.nashorn.api.scripting.JSObject;
-import jdk.nashorn.internal.codegen.ObjectClassGenerator;
import jdk.nashorn.internal.objects.Global;
import jdk.nashorn.internal.runtime.Property;
import jdk.nashorn.internal.runtime.PropertyMap;
@@ -123,7 +122,7 @@
*/
static boolean needsGuard(final Property property, final CallSiteDescriptor desc) {
return property == null || property.isConfigurable()
- || property.isBound() || !ObjectClassGenerator.OBJECT_FIELDS_ONLY
+ || property.isBound() || property.hasDualFields()
|| !NashornCallSiteDescriptor.isFastScope(desc) || property.canChangeType();
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/ArrayCompiler.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/ArrayCompiler.java Tue Apr 14 12:10:00 2015 -0700
@@ -145,9 +145,6 @@
case TargetInfo.IS_EMPTY_MEM:
addOpcode(OPCode.NULL_CHECK_END_MEMST);
break;
- case TargetInfo.IS_EMPTY_REC:
- addOpcode(OPCode.NULL_CHECK_END_MEMST_PUSH);
- break;
default:
break;
} // switch
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/ByteCodeMachine.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/ByteCodeMachine.java Tue Apr 14 12:10:00 2015 -0700
@@ -183,7 +183,6 @@
case OPCode.NULL_CHECK_START: opNullCheckStart(); continue;
case OPCode.NULL_CHECK_END: opNullCheckEnd(); continue;
case OPCode.NULL_CHECK_END_MEMST: opNullCheckEndMemST(); continue;
- case OPCode.NULL_CHECK_END_MEMST_PUSH: opNullCheckEndMemSTPush(); continue;
case OPCode.JUMP: opJump(); continue;
case OPCode.PUSH: opPush(); continue;
@@ -1025,29 +1024,6 @@
}
}
- // USE_SUBEXP_CALL
- private void opNullCheckEndMemSTPush() {
- final int mem = code[ip++]; /* mem: null check id */
-
- int isNull;
- if (Config.USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT) {
- isNull = nullCheckMemStRec(mem, s);
- } else {
- isNull = nullCheckRec(mem, s);
- }
-
- if (isNull != 0) {
- if (Config.DEBUG_MATCH) {
- Config.log.println("NULL_CHECK_END_MEMST_PUSH: skip id:" + mem + ", s:" + s);
- }
-
- if (isNull == -1) {opFail(); return;}
- nullCheckFound();
- } else {
- pushNullCheckEnd(mem);
- }
- }
-
private void opJump() {
ip += code[ip] + 1;
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/StackMachine.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/StackMachine.java Tue Apr 14 12:10:00 2015 -0700
@@ -19,7 +19,6 @@
*/
package jdk.nashorn.internal.runtime.regexp.joni;
-import static jdk.nashorn.internal.runtime.regexp.joni.BitStatus.bsAt;
import java.lang.ref.WeakReference;
import jdk.nashorn.internal.runtime.regexp.joni.constants.StackPopLevel;
import jdk.nashorn.internal.runtime.regexp.joni.constants.StackType;
@@ -369,118 +368,9 @@
}
}
- protected final int nullCheckRec(final int id, final int s) {
- int level = 0;
- int k = stk;
- while (true) {
- k--;
- final StackEntry e = stack[k];
-
- if (e.type == NULL_CHECK_START) {
- if (e.getNullCheckNum() == id) {
- if (level == 0) {
- return e.getNullCheckPStr() == s ? 1 : 0;
- }
- level--;
- }
- } else if (e.type == NULL_CHECK_END) {
- level++;
- }
- }
- }
-
protected final int nullCheckMemSt(final int id, final int s) {
- int k = stk;
- int isNull;
- while (true) {
- k--;
- StackEntry e = stack[k];
-
- if (e.type == NULL_CHECK_START) {
- if (e.getNullCheckNum() == id) {
- if (e.getNullCheckPStr() != s) {
- isNull = 0;
- break;
- }
- int endp;
- isNull = 1;
- while (k < stk) {
- if (e.type == MEM_START) {
- if (e.getMemEnd() == INVALID_INDEX) {
- isNull = 0;
- break;
- }
- if (bsAt(regex.btMemEnd, e.getMemNum())) {
- endp = stack[e.getMemEnd()].getMemPStr();
- } else {
- endp = e.getMemEnd();
- }
- if (stack[e.getMemStart()].getMemPStr() != endp) {
- isNull = 0;
- break;
- } else if (endp != s) {
- isNull = -1; /* empty, but position changed */
- }
- }
- k++;
- e = stack[k]; // !!
- }
- break;
- }
- }
- }
- return isNull;
- }
-
- protected final int nullCheckMemStRec(final int id, final int s) {
- int level = 0;
- int k = stk;
- int isNull;
- while (true) {
- k--;
- StackEntry e = stack[k];
-
- if (e.type == NULL_CHECK_START) {
- if (e.getNullCheckNum() == id) {
- if (level == 0) {
- if (e.getNullCheckPStr() != s) {
- isNull = 0;
- break;
- }
- int endp;
- isNull = 1;
- while (k < stk) {
- if (e.type == MEM_START) {
- if (e.getMemEnd() == INVALID_INDEX) {
- isNull = 0;
- break;
- }
- if (bsAt(regex.btMemEnd, e.getMemNum())) {
- endp = stack[e.getMemEnd()].getMemPStr();
- } else {
- endp = e.getMemEnd();
- }
- if (stack[e.getMemStart()].getMemPStr() != endp) {
- isNull = 0;
- break;
- } else if (endp != s) {
- isNull = -1; /* empty, but position changed */
- }
- }
- k++;
- e = stack[k];
- }
- break;
- }
- level--;
- }
- } else if (e.type == NULL_CHECK_END) {
- if (e.getNullCheckNum() == id) {
- level++;
- }
- }
- }
- return isNull;
+ // Return -1 here to cause operation to fail
+ return -nullCheck(id, s);
}
protected final int getRepeat(final int id) {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/constants/TargetInfo.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/regexp/joni/constants/TargetInfo.java Tue Apr 14 12:10:00 2015 -0700
@@ -24,5 +24,4 @@
final int ISNOT_EMPTY = 0;
final int IS_EMPTY = 1;
final int IS_EMPTY_MEM = 2;
- final int IS_EMPTY_REC = 3;
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/scripts/JD.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.scripts;
+
+import jdk.nashorn.internal.runtime.PropertyMap;
+import jdk.nashorn.internal.runtime.ScriptObject;
+
+/**
+ * Empty object class for dual primitive-object fields.
+ */
+public class JD extends ScriptObject {
+
+ private static final PropertyMap map$ = PropertyMap.newMap(JD.class);
+
+ /**
+ * Returns the initial property map to be used.
+ * @return the initial property map.
+ */
+ public static PropertyMap getInitialMap() {
+ return map$;
+ }
+
+ /**
+ * Constructor given an initial property map
+ *
+ * @param map the property map
+ */
+ public JD(final PropertyMap map) {
+ super(map);
+ }
+
+ /**
+ * Constructor given an initial prototype and the default initial property map.
+ *
+ * @param proto the prototype object
+ */
+ public JD(final ScriptObject proto) {
+ super(proto, getInitialMap());
+ }
+
+ /**
+ * Constructor that takes a pre-initialized spill pool. Used by
+ * {@link jdk.nashorn.internal.codegen.SpillObjectCreator} and
+ * {@link jdk.nashorn.internal.parser.JSONParser} for initializing object literals
+ *
+ * @param map property map
+ * @param primitiveSpill primitive spill pool
+ * @param objectSpill reference spill pool
+ */
+ public JD(final PropertyMap map, final long[] primitiveSpill, final Object[] objectSpill) {
+ super(map, primitiveSpill, objectSpill);
+ }
+
+ /**
+ * A method handle of this method is passed to the ScriptFunction constructor.
+ *
+ * @param map the property map to use for allocatorMap
+ *
+ * @return newly allocated ScriptObject
+ */
+ public static ScriptObject allocate(final PropertyMap map) {
+ return new JD(map);
+ }
+}
+
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/scripts/JO.java Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/scripts/JO.java Tue Apr 14 12:10:00 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,11 +29,11 @@
import jdk.nashorn.internal.runtime.ScriptObject;
/**
- * Empty object class.
+ * Empty object class for object-only fields.
*/
public class JO extends ScriptObject {
- private static final PropertyMap map$ = PropertyMap.newMap();
+ private static final PropertyMap map$ = PropertyMap.newMap(JO.class);
/**
* Returns the initial property map to be used.
@@ -53,13 +53,12 @@
}
/**
- * Constructor given an initial prototype and an initial property map.
+ * Constructor given an initial prototype and the default initial property map.
*
* @param proto the prototype object
- * @param map the property map
*/
- public JO(final ScriptObject proto, final PropertyMap map) {
- super(proto, map);
+ public JO(final ScriptObject proto) {
+ super(proto, getInitialMap());
}
/**
@@ -86,3 +85,4 @@
return new JO(map);
}
}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8073868.js Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8073868: Regex matching causes java.lang.ArrayIndexOutOfBoundsException: 64
+ *
+ * @test
+ * @run
+ */
+
+function test(input) {
+ var comma = input.indexOf(",");
+ Assert.assertEquals(/([^\s]+),(.*)+/.exec(input)[0], input.trimLeft());
+ Assert.assertEquals(/([^\s]+),(.*)+/.exec(input)[1], input.substring(0, comma).trimLeft());
+ Assert.assertEquals(/([^\s]+),(.*)+/.exec(input)[2], input.substring(comma + 1));
+ Assert.assertEquals(/(.*)+/.exec(input)[0], input);
+ Assert.assertEquals(/(.*)+/.exec(input)[1], input);
+}
+
+test(" xxxx, xxx xxxxxx xxxxxxxxx xxxxxxx, xxxx xxxxx xxxxx ");
+test(" xxxx, xxx xxxxxx xxxxxxxxx xxxxxxx, xxxx xxxxx xxxxx ");
+test("x, xxxxxxxxxx xxxxxxxxx xxxxxxx, xxxx xxxxx xxxxx ");
+
+Assert.assertEquals(/(?:\1a|())*/.exec("a")[0], "a");
+Assert.assertEquals(/(?:\1a|())*/.exec("a")[1], undefined);
--- a/nashorn/test/script/basic/es6/let-eval.js Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/test/script/basic/es6/let-eval.js Tue Apr 14 12:10:00 2015 -0700
@@ -96,3 +96,9 @@
f();
print(typeof a, typeof b, typeof c, typeof x, typeof z);
+
+let v = 1;
+eval("print('v: ' + v); v = 2; print ('v: ' + v);");
+print("this.v: " + this.v);
+print("v: " + v);
+
--- a/nashorn/test/script/basic/es6/let-eval.js.EXPECTED Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/test/script/basic/es6/let-eval.js.EXPECTED Tue Apr 14 12:10:00 2015 -0700
@@ -14,3 +14,7 @@
2 1 0
2 1 0 undefined
undefined undefined undefined undefined undefined
+v: 1
+v: 2
+this.v: undefined
+v: 2
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/nosecurity/JDK-8067215.js Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8067215: Disable dual fields when not using optimistic types
+ *
+ * @test
+ * @run
+ * @option -Dnashorn.debug=true
+ * @fork
+ */
+
+var intType = Java.type("int");
+var doubleType = Java.type("double");
+var longType = Java.type("long");
+var objectType = Java.type("java.lang.Object");
+
+var Context = Java.type("jdk.nashorn.internal.runtime.Context");
+var JSType = Java.type("jdk.nashorn.internal.runtime.JSType");
+
+var context = Context.getContext();
+var dualFields = context.useDualFields();
+var optimisticTypes = context.getEnv()._optimistic_types;
+
+if (dualFields != optimisticTypes) {
+ throw new Error("Wrong dual fields setting");
+}
+
+function testMap(obj) {
+ obj.x = "foo";
+ obj["y"] = 0;
+ Object.defineProperty(obj, "z", {value: 0.5});
+ var map = Debug.map(obj);
+ for (var key in obj) {
+ var prop = map.findProperty(key);
+ if (prop.hasDualFields() !== dualFields) {
+ throw new Error("Wrong property flags: " + prop);
+ }
+ if (prop.getType() != getExpectedType(obj[key])) {
+ throw new Error("Wrong property type: " + prop.getType() + " // " + getExpectedType(obj[key]));
+
+ }
+ }
+}
+
+function getExpectedType(value) {
+ if (!dualFields) {
+ return objectType.class;
+ }
+ if (JSType.isRepresentableAsInt(value)) {
+ return intType.class;
+ }
+ if (JSType.isRepresentableAsLong(value)) {
+ return longType.class;
+ }
+ if (JSType.isNumber(value)) {
+ return doubleType.class;
+ }
+ return objectType.class;
+}
+
+var o = {
+ a: 1,
+ b: 2.5,
+ c: 0x10000000000,
+ d: true
+};
+
+function C() {
+ this.a = 1;
+ this.b = 2.5;
+ this.c = 0x10000000000;
+ this.d = true;
+}
+
+var a = 1;
+var b = 2.5;
+var c = 0x10000000000;
+var d = true;
+
+testMap(o);
+testMap(new C());
+testMap(JSON.parse('{ "a": 1, "b": 2.5, "c": 1099511627776, "d": true }'));
+testMap(this);
--- a/nashorn/test/script/sandbox/interfaceimpl.js Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/test/script/sandbox/interfaceimpl.js Tue Apr 14 12:10:00 2015 -0700
@@ -29,8 +29,8 @@
* @security
*/
-var Window = Java.type("jdk.nashorn.api.scripting.Window");
-var WindowEventHandler = Java.type("jdk.nashorn.api.scripting.WindowEventHandler");
+var Window = Java.type("jdk.nashorn.api.scripting.test.Window");
+var WindowEventHandler = Java.type("jdk.nashorn.api.scripting.test.WindowEventHandler");
var w = new Window();
--- a/nashorn/test/script/trusted/JDK-8025629.js Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/test/script/trusted/JDK-8025629.js Tue Apr 14 12:10:00 2015 -0700
@@ -28,6 +28,6 @@
* @run
*/
-load("classpath:jdk/nashorn/internal/runtime/resources/load_test.js")
+load("classpath:jdk/nashorn/internal/runtime/test/resources/load_test.js")
Assert.assertEquals(loadedFunc("hello"), "HELLO");
--- a/nashorn/test/src/META-INF/services/java.sql.Driver Mon Apr 13 17:03:11 2015 -0700
+++ b/nashorn/test/src/META-INF/services/java.sql.Driver Tue Apr 14 12:10:00 2015 -0700
@@ -1,1 +1,1 @@
-jdk.nashorn.api.NashornSQLDriver
+jdk.nashorn.api.test.NashornSQLDriver
--- a/nashorn/test/src/jdk/internal/dynalink/beans/CallerSensitiveTest.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.internal.dynalink.beans;
-
-import jdk.nashorn.test.models.ClassLoaderAware;
-import org.testng.annotations.Test;
-
-@SuppressWarnings("javadoc")
-public class CallerSensitiveTest {
- @Test
- public void testCallerSensitive() {
- BeansLinker.getLinkerForClass(ClassLoaderAware.class);
- }
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/internal/dynalink/beans/test/CallerSensitiveTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.internal.dynalink.beans.test;
+
+import jdk.internal.dynalink.beans.BeansLinker;
+import jdk.nashorn.test.models.ClassLoaderAware;
+import org.testng.annotations.Test;
+
+@SuppressWarnings("javadoc")
+public class CallerSensitiveTest {
+ @Test
+ public void testCallerSensitive() {
+ BeansLinker.getLinkerForClass(ClassLoaderAware.class);
+ }
+}
--- a/nashorn/test/src/jdk/nashorn/api/NashornSQLDriver.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api;
-
-import java.sql.Connection;
-import java.sql.Driver;
-import java.sql.DriverManager;
-import java.sql.DriverPropertyInfo;
-import java.sql.SQLException;
-import java.sql.SQLFeatureNotSupportedException;
-import java.util.Properties;
-import java.util.logging.Logger;
-
-/**
- * A dummy SQL driver for testing purpose.
- */
-public final class NashornSQLDriver implements Driver {
- static {
- try {
- DriverManager.registerDriver(new NashornSQLDriver(), null);
- } catch (final SQLException se) {
- throw new RuntimeException(se);
- }
- }
-
- @Override
- public boolean acceptsURL(final String url) {
- return url.startsWith("jdbc:nashorn:");
- }
-
- @Override
- public Connection connect(final String url, final Properties info) {
- throw new UnsupportedOperationException("I am a dummy!!");
- }
-
- @Override
- public int getMajorVersion() {
- return -1;
- }
-
- @Override
- public int getMinorVersion() {
- return -1;
- }
-
- @Override
- public DriverPropertyInfo[] getPropertyInfo(final String url, final Properties info) {
- return new DriverPropertyInfo[0];
- }
-
- @Override
- public boolean jdbcCompliant() {
- // no way!
- return false;
- }
-
- @Override
- public Logger getParentLogger() throws SQLFeatureNotSupportedException {
- throw new SQLFeatureNotSupportedException();
- }
-}
--- a/nashorn/test/src/jdk/nashorn/api/javaaccess/ArrayConversionTest.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,235 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.javaaccess;
-
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertNull;
-import static org.testng.AssertJUnit.assertTrue;
-import java.util.Arrays;
-import java.util.List;
-import javax.script.ScriptContext;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
-import javax.script.ScriptException;
-import org.testng.TestNG;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-@SuppressWarnings("javadoc")
-public class ArrayConversionTest {
- private static ScriptEngine e = null;
-
- public static void main(final String[] args) {
- TestNG.main(args);
- }
-
- @BeforeClass
- public static void setUpClass() {
- e = new ScriptEngineManager().getEngineByName("nashorn");
- }
-
- @AfterClass
- public static void tearDownClass() {
- e = null;
- }
-
- @Test
- public void testIntArrays() throws ScriptException {
- runTest("assertNullIntArray", "null");
- runTest("assertEmptyIntArray", "[]");
- runTest("assertSingle42IntArray", "[42]");
- runTest("assertSingle42IntArray", "['42']");
- runTest("assertIntArrayConversions", "[false, true, NaN, Infinity, -Infinity, 0.4, 0.6, null, undefined, [], {}, [1], [1, 2]]");
- }
-
- @Test
- public void testIntIntArrays() throws ScriptException {
- runTest("assertNullIntIntArray", "null");
- runTest("assertEmptyIntIntArray", "[]");
- runTest("assertSingleEmptyIntIntArray", "[[]]");
- runTest("assertSingleNullIntIntArray", "[null]");
- runTest("assertLargeIntIntArray", "[[false], [1], [2, 3], [4, 5, 6], ['7', {valueOf: function() { return 8 }}]]");
- }
-
- @Test
- public void testObjectObjectArrays() throws ScriptException {
- runTest("assertLargeObjectObjectArray", "[[false], [1], ['foo', 42.3], [{x: 17}]]");
- }
-
- @Test
- public void testBooleanArrays() throws ScriptException {
- runTest("assertBooleanArrayConversions", "[false, true, '', 'false', 0, 1, 0.4, 0.6, {}, [], [false], [true], NaN, Infinity, null, undefined]");
- }
-
- @Test
- public void testArrayAmbiguity() throws ScriptException {
- runTest("x", "'abc'");
- runTest("x", "['foo', 'bar']");
- }
-
- @Test
- public void testListArrays() throws ScriptException {
- runTest("assertListArray", "[['foo', 'bar'], ['apple', 'orange']]");
- }
-
- @Test
- public void testVarArgs() throws ScriptException {
- // Sole NativeArray in vararg position becomes vararg array itself
- runTest("assertVarArg_42_17", "[42, 17]");
- // NativeArray in vararg position becomes an argument if there are more arguments
- runTest("assertVarArg_array_17", "[42], 18");
- // Only NativeArray is converted to vararg array, other objects (e.g. a function) aren't
- runTest("assertVarArg_function", "function() { return 'Hello' }");
- }
-
- private static void runTest(final String testMethodName, final String argument) throws ScriptException {
- e.eval("Java.type('" + ArrayConversionTest.class.getName() + "')." + testMethodName + "(" + argument + ")");
- }
-
- public static void assertNullIntArray(final int[] array) {
- assertNull(array);
- }
-
- public static void assertNullIntIntArray(final int[][] array) {
- assertNull(array);
- }
-
- public static void assertEmptyIntArray(final int[] array) {
- assertEquals(0, array.length);
- }
-
- public static void assertSingle42IntArray(final int[] array) {
- assertEquals(1, array.length);
- assertEquals(42, array[0]);
- }
-
-
- public static void assertIntArrayConversions(final int[] array) {
- assertEquals(13, array.length);
- assertEquals(0, array[0]); // false
- assertEquals(1, array[1]); // true
- assertEquals(0, array[2]); // NaN
- assertEquals(0, array[3]); // Infinity
- assertEquals(0, array[4]); // -Infinity
- assertEquals(0, array[5]); // 0.4
- assertEquals(0, array[6]); // 0.6 - floor, not round
- assertEquals(0, array[7]); // null
- assertEquals(0, array[8]); // undefined
- assertEquals(0, array[9]); // []
- assertEquals(0, array[10]); // {}
- assertEquals(1, array[11]); // [1]
- assertEquals(0, array[12]); // [1, 2]
- }
-
- public static void assertEmptyIntIntArray(final int[][] array) {
- assertEquals(0, array.length);
- }
-
- public static void assertSingleEmptyIntIntArray(final int[][] array) {
- assertEquals(1, array.length);
- assertTrue(Arrays.equals(new int[0], array[0]));
- }
-
- public static void assertSingleNullIntIntArray(final int[][] array) {
- assertEquals(1, array.length);
- assertNull(null, array[0]);
- }
-
- public static void assertLargeIntIntArray(final int[][] array) {
- assertEquals(5, array.length);
- assertTrue(Arrays.equals(new int[] { 0 }, array[0]));
- assertTrue(Arrays.equals(new int[] { 1 }, array[1]));
- assertTrue(Arrays.equals(new int[] { 2, 3 }, array[2]));
- assertTrue(Arrays.equals(new int[] { 4, 5, 6 }, array[3]));
- assertTrue(Arrays.equals(new int[] { 7, 8 }, array[4]));
- }
-
- public static void assertLargeObjectObjectArray(final Object[][] array) throws ScriptException {
- assertEquals(4, array.length);
- assertTrue(Arrays.equals(new Object[] { Boolean.FALSE }, array[0]));
- assertTrue(Arrays.equals(new Object[] { 1 }, array[1]));
- assertTrue(Arrays.equals(new Object[] { "foo", 42.3d }, array[2]));
- assertEquals(1, array[3].length);
- e.getBindings(ScriptContext.ENGINE_SCOPE).put("obj", array[3][0]);
- assertEquals(17, e.eval("obj.x"));
- }
-
- public static void assertBooleanArrayConversions(final boolean[] array) {
- assertEquals(16, array.length);
- assertFalse(array[0]); // false
- assertTrue(array[1]); // true
- assertFalse(array[2]); // ''
- assertTrue(array[3]); // 'false' (yep, every non-empty string converts to true)
- assertFalse(array[4]); // 0
- assertTrue(array[5]); // 1
- assertTrue(array[6]); // 0.4
- assertTrue(array[7]); // 0.6
- assertTrue(array[8]); // {}
- assertTrue(array[9]); // []
- assertTrue(array[10]); // [false]
- assertTrue(array[11]); // [true]
- assertFalse(array[12]); // NaN
- assertTrue(array[13]); // Infinity
- assertFalse(array[14]); // null
- assertFalse(array[15]); // undefined
- }
-
- public static void assertListArray(final List<?>[] array) {
- assertEquals(2, array.length);
- assertEquals(Arrays.asList("foo", "bar"), array[0]);
- assertEquals(Arrays.asList("apple", "orange"), array[1]);
- }
-
- public static void assertVarArg_42_17(final Object... args) {
- assertEquals(2, args.length);
- assertEquals(42, ((Number)args[0]).intValue());
- assertEquals(17, ((Number)args[1]).intValue());
- }
-
- public static void assertVarArg_array_17(final Object... args) throws ScriptException {
- assertEquals(2, args.length);
- e.getBindings(ScriptContext.ENGINE_SCOPE).put("arr", args[0]);
- assertTrue((Boolean)e.eval("arr instanceof Array && arr.length == 1 && arr[0] == 42"));
- assertEquals(18, ((Number)args[1]).intValue());
- }
-
- public static void assertVarArg_function(final Object... args) throws ScriptException {
- assertEquals(1, args.length);
- e.getBindings(ScriptContext.ENGINE_SCOPE).put("fn", args[0]);
- assertEquals("Hello", e.eval("fn()"));
- }
-
-
-
- public static void x(final String y) {
- assertEquals("abc", y);
- }
- public static void x(final String[] y) {
- assertTrue(Arrays.equals(new String[] { "foo", "bar"}, y));
- }
-}
--- a/nashorn/test/src/jdk/nashorn/api/javaaccess/BooleanAccessTest.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,219 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.javaaccess;
-
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-import java.util.Arrays;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
-import javax.script.ScriptException;
-import org.testng.TestNG;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- * @test
- * @build jdk.nashorn.api.javaaccess.SharedObject jdk.nashorn.api.javaaccess.Person jdk.nashorn.api.javaaccess.BooleanAccessTest
- * @run testng/othervm jdk.nashorn.api.javaaccess.BooleanAccessTest
- */
-@SuppressWarnings("javadoc")
-public class BooleanAccessTest {
-
- private static ScriptEngine e = null;
- private static SharedObject o = null;
-
- public static void main(final String[] args) {
- TestNG.main(args);
- }
-
- @BeforeClass
- public static void setUpClass() throws ScriptException {
- final ScriptEngineManager m = new ScriptEngineManager();
- e = m.getEngineByName("nashorn");
- o = new SharedObject();
- e.put("o", o);
- e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.SharedObject;");
- }
-
- @AfterClass
- public static void tearDownClass() {
- e = null;
- o = null;
- }
-
- @Test
- public void accessFieldBoolean() throws ScriptException {
- e.eval("var p_boolean = o.publicBoolean;");
- assertEquals(o.publicBoolean, e.get("p_boolean"));
- assertEquals("boolean", e.eval("typeof p_boolean;"));
- e.eval("o.publicBoolean = false;");
- assertEquals(false, o.publicBoolean);
- }
-
- @Test
- public void accessFieldBooleanArray() throws ScriptException {
- e.eval("var p_boolean_array = o.publicBooleanArray;");
- assertEquals(o.publicBooleanArray[0], e.eval("o.publicBooleanArray[0]"));
- assertTrue(Arrays.equals(o.publicBooleanArray, (boolean[])e.get("p_boolean_array")));
- e.eval("var t_boolean_arr = new (Java.type(\"boolean[]\"))(3);" +
- "t_boolean_arr[0] = true;" +
- "t_boolean_arr[1] = false;" +
- "t_boolean_arr[2] = false;" +
- "o.publicBooleanArray = t_boolean_arr;");
- assertTrue(Arrays.equals(new boolean[] { true, false, false }, o.publicBooleanArray));
- e.eval("o.publicBooleanArray[0] = false;");
- assertEquals(false, o.publicBooleanArray[0]);
- }
-
- @Test
- public void accessStaticFieldBoolean() throws ScriptException {
- e.eval("var ps_boolean = SharedObject.publicStaticBoolean;");
- assertEquals(SharedObject.publicStaticBoolean, e.get("ps_boolean"));
- assertEquals("boolean", e.eval("typeof ps_boolean;"));
- e.eval("SharedObject.publicStaticBoolean = false;");
- assertEquals(false, SharedObject.publicStaticBoolean);
- }
-
- @Test
- public void accessStaticFieldBooleanArray() throws ScriptException {
- e.eval("var ps_boolean_array = SharedObject.publicStaticBooleanArray;");
- assertEquals(SharedObject.publicStaticBooleanArray[0], e.eval("SharedObject.publicStaticBooleanArray[0]"));
- assertTrue(Arrays.equals(SharedObject.publicStaticBooleanArray, (boolean[])e.get("ps_boolean_array")));
- e.eval("var ts_boolean_arr = new (Java.type(\"boolean[]\"))(3);" +
- "ts_boolean_arr[0] = true;" +
- "ts_boolean_arr[1] = false;" +
- "ts_boolean_arr[2] = true;" +
- "SharedObject.publicStaticBooleanArray = ts_boolean_arr;");
- assertTrue(Arrays.equals(new boolean[] { true, false, true }, SharedObject.publicStaticBooleanArray));
- e.eval("SharedObject.publicStaticBooleanArray[0] = false;");
- assertEquals(false, SharedObject.publicStaticBooleanArray[0]);
- }
-
- @Test
- public void accessFinalFieldBoolean() throws ScriptException {
- e.eval("var pf_boolean = o.publicFinalBoolean;");
- assertEquals(o.publicFinalBoolean, e.get("pf_boolean"));
- assertEquals("boolean", e.eval("typeof pf_boolean;"));
- e.eval("o.publicFinalBoolean = false;");
- assertEquals(true, o.publicFinalBoolean);
- }
-
- @Test
- public void accessFinalFieldBooleanArray() throws ScriptException {
- e.eval("var pf_boolean_array = o.publicFinalBooleanArray;");
- assertEquals(o.publicFinalBooleanArray[0], e.eval("o.publicFinalBooleanArray[0]"));
- assertTrue(Arrays.equals(o.publicFinalBooleanArray, (boolean[])e.get("pf_boolean_array")));
- e.eval("var tf_boolean_arr = new (Java.type(\"boolean[]\"))(3);" +
- "tf_boolean_arr[0] = false;" +
- "tf_boolean_arr[1] = false;" +
- "tf_boolean_arr[2] = true;" +
- "o.publicOFinalbjectArray = tf_boolean_arr;");
- assertTrue(Arrays.equals(new boolean[] { false, false, true, false }, o.publicFinalBooleanArray));
- e.eval("o.publicFinalBooleanArray[0] = true;");
- assertEquals(true, o.publicFinalBooleanArray[0]);
- }
-
- @Test
- public void accessStaticFinalFieldBoolean() throws ScriptException {
- e.eval("var psf_boolean = SharedObject.publicStaticFinalBoolean;");
- assertEquals(SharedObject.publicStaticFinalBoolean, e.get("psf_boolean"));
- assertEquals("boolean", e.eval("typeof psf_boolean;"));
- e.eval("SharedObject.publicStaticFinalBoolean = false;");
- assertEquals(true, SharedObject.publicStaticFinalBoolean);
- }
-
- @Test
- public void accessStaticFinalFieldBooleanArray() throws ScriptException {
- e.eval("var psf_boolean_array = SharedObject.publicStaticFinalBooleanArray;");
- assertEquals(SharedObject.publicStaticFinalBooleanArray[0], e.eval("SharedObject.publicStaticFinalBooleanArray[0]"));
- assertTrue(Arrays.equals(SharedObject.publicStaticFinalBooleanArray, (boolean[])e.get("psf_boolean_array")));
- e.eval("var tsf_boolean_arr = new (Java.type(\"boolean[]\"))(3);" +
- "tsf_boolean_arr[0] = false;" +
- "tsf_boolean_arr[1] = true;" +
- "tsf_boolean_arr[2] = false;" +
- "SharedObject.publicStaticFinalBooleanArray = tsf_boolean_arr;");
- assertTrue(Arrays.equals(new boolean[] { false, true, false, false }, SharedObject.publicStaticFinalBooleanArray));
- e.eval("SharedObject.publicStaticFinalBooleanArray[0] = true;");
- assertEquals(true, SharedObject.publicStaticFinalBooleanArray[0]);
- }
-
- @Test
- public void accessFieldBooleanBoxing() throws ScriptException {
- e.eval("var p_boolean_box = o.publicBooleanBox;");
- assertEquals(o.publicBooleanBox, e.get("p_boolean_box"));
- assertEquals("boolean", e.eval("typeof p_boolean_box;"));
- e.eval("o.publicBooleanBox = false;");
- assertEquals(false, (boolean)o.publicBooleanBox);
- }
-
- @Test
- public void accessStaticFieldBooleanBoxing() throws ScriptException {
- e.eval("var ps_boolean_box = SharedObject.publicStaticBooleanBox;");
- assertEquals(SharedObject.publicStaticBooleanBox, e.get("ps_boolean_box"));
- assertEquals("boolean", e.eval("typeof ps_boolean_box;"));
- e.eval("SharedObject.publicStaticBooleanBox = false;");
- assertEquals(false, (boolean)SharedObject.publicStaticBooleanBox);
- }
-
- @Test
- public void accessFinalFieldBooleanBoxing() throws ScriptException {
- e.eval("var pf_boolean_box = o.publicFinalBooleanBox;");
- assertEquals(o.publicFinalBooleanBox, e.get("pf_boolean_box"));
- assertEquals("boolean", e.eval("typeof pf_boolean_box;"));
- e.eval("o.publicFinalBooleanBox = false;");
- assertEquals(true, (boolean)o.publicFinalBooleanBox);
- }
-
- @Test
- public void accessStaticFinalFieldBooleanBoxing() throws ScriptException {
- e.eval("var psf_boolean_box = SharedObject.publicStaticFinalBooleanBox;");
- assertEquals(SharedObject.publicStaticFinalBooleanBox, e.get("psf_boolean_box"));
- assertEquals("boolean", e.eval("typeof psf_boolean_box;"));
- e.eval("SharedObject.publicStaticFinalBooleanBox = false;");
- assertEquals(true, (boolean)SharedObject.publicStaticFinalBooleanBox);
- }
-
- @Test
- public void accessVolatileField() throws ScriptException {
- e.eval("var pv_boolean = o.volatileBoolean;");
- assertEquals(o.volatileBoolean, e.get("pv_boolean"));
- assertEquals("boolean", e.eval("typeof pv_boolean;"));
- e.eval("o.volatileBoolean = false;");
- assertEquals(false, o.volatileBoolean);
- }
-
- @Test
- public void accessTransientField() throws ScriptException {
- e.eval("var pt_boolean = o.transientBoolean;");
- assertEquals(o.transientBoolean, e.get("pt_boolean"));
- assertEquals("boolean", e.eval("typeof pt_boolean;"));
- e.eval("o.transientBoolean = false;");
- assertEquals(false, o.transientBoolean);
- }
-
-}
--- a/nashorn/test/src/jdk/nashorn/api/javaaccess/ConsStringTest.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,99 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.javaaccess;
-
-import static org.testng.AssertJUnit.assertEquals;
-import java.util.HashMap;
-import java.util.Map;
-import javax.script.Bindings;
-import javax.script.ScriptContext;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
-import javax.script.ScriptException;
-import jdk.nashorn.api.scripting.JSObject;
-import org.testng.TestNG;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-@SuppressWarnings("javadoc")
-public class ConsStringTest {
- private static ScriptEngine e = null;
-
- public static void main(final String[] args) {
- TestNG.main(args);
- }
-
- @BeforeClass
- public static void setUpClass() {
- e = new ScriptEngineManager().getEngineByName("nashorn");
- }
-
- @AfterClass
- public static void tearDownClass() {
- e = null;
- }
-
- @Test
- public void testConsStringFlattening() throws ScriptException {
- final Bindings b = e.getBindings(ScriptContext.ENGINE_SCOPE);
- final Map<Object, Object> m = new HashMap<>();
- b.put("m", m);
- e.eval("var x = 'f'; x += 'oo'; var y = 'b'; y += 'ar'; m.put(x, y)");
- assertEquals("bar", m.get("foo"));
- }
-
- @Test
- public void testConsStringFromMirror() throws ScriptException {
- final Bindings b = e.getBindings(ScriptContext.ENGINE_SCOPE);
- //final Map<Object, Object> m = new HashMap<>();
- e.eval("var x = 'f'; x += 'oo'; var obj = {x: x};");
- assertEquals("foo", ((JSObject)b.get("obj")).getMember("x"));
- }
-
- @Test
- public void testArrayConsString() throws ScriptException {
- final Bindings b = e.getBindings(ScriptContext.ENGINE_SCOPE);
- final ArrayHolder h = new ArrayHolder();
- b.put("h", h);
- e.eval("var x = 'f'; x += 'oo'; h.array = [x];");
- assertEquals(1, h.array.length);
- assertEquals("foo", h.array[0]);
- }
-
-
- public static class ArrayHolder {
- private Object[] array;
-
- public void setArray(final Object[] array) {
- this.array = array;
- }
-
- public Object[] getArray() {
- return array;
- }
- }
-}
--- a/nashorn/test/src/jdk/nashorn/api/javaaccess/MethodAccessTest.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,466 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.javaaccess;
-
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Locale;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
-import javax.script.ScriptException;
-import org.testng.TestNG;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- * @test
- * @build jdk.nashorn.api.javaaccess.SharedObject jdk.nashorn.api.javaaccess.Person jdk.nashorn.api.javaaccess.MethodAccessTest
- * @run testng/othervm jdk.nashorn.api.javaaccess.MethodAccessTest
- */
-@SuppressWarnings("javadoc")
-public class MethodAccessTest {
-
- private static ScriptEngine e = null;
- private static SharedObject o = null;
-
- public static void main(final String[] args) {
- TestNG.main(args);
- }
-
- @BeforeClass
- public static void setUpClass() throws ScriptException {
- final ScriptEngineManager m = new ScriptEngineManager();
- e = m.getEngineByName("nashorn");
- o = new SharedObject();
- o.setEngine(e);
- e.put("o", o);
- e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.SharedObject;");
- e.eval("var Person = Packages.jdk.nashorn.api.javaaccess.Person;");
- }
-
- @AfterClass
- public static void tearDownClass() {
- e = null;
- o = null;
- }
-
- @Test
- public void accessMethodthrowsCheckedException() throws ScriptException {
- e.eval("try {" +
- " var a = java.lang.Long.parseLong('foo');" +
- "} catch(e) {" +
- " var isThrown = true;" +
- " var isNumberException = e instanceof java.lang.NumberFormatException;" +
- "} finally {" +
- " var isFinalized = true;" +
- "}");
- assertEquals("Exception thrown", true, e.get("isThrown"));
- assertEquals("Finally called", true, e.get("isFinalized"));
- assertEquals("Type is NumberFormatException", true, e.get("isNumberException"));
- }
-
- @Test
- public void accessMethodthrowsUnCheckedException() throws ScriptException {
- e.eval("try {" +
- " var a = java.lang.String.valueOf(null);" +
- "} catch(e) {" +
- " var isThrown = true;" +
- " var isNumberException = e instanceof java.lang.NullPointerException;" +
- "} finally {" +
- " var isFinalized = true;" +
- "}");
- assertEquals(true, e.get("isThrown"));
- assertEquals(true, e.get("isFinalized"));
- assertEquals(true, e.get("isNumberException"));
- }
-
- @Test
- public void accessMethodStartsThread() throws ScriptException {
- e.eval("o.methodStartsThread();");
- assertEquals(false, o.isFinished);
- }
-
- @Test
- public void accessStaticMethod() throws ScriptException {
- assertEquals(10, e.eval("java.lang.Math.abs(-10);"));
- }
-
- @Test
- public void accessSynchronousMethod() throws ScriptException {
- e.eval("var v = new java.util.Vector();" + "v.add(10);" + "v.add(20);" + "v.add(30);");
- assertEquals(10, e.eval("v[0]"));
- assertEquals(20, e.eval("v[1]"));
- assertEquals(30, e.eval("v[2]"));
- assertEquals(3, e.eval("v.size()"));
- }
-
- @Test
- public void accessStaticSynchronousMethod() throws ScriptException {
- e.eval("var locales = java.util.Calendar.getAvailableLocales();");
- final Locale[] locales = (Locale[])e.get("locales");
- assertEquals(locales.length, Calendar.getAvailableLocales().length);
- }
-
- @Test
- public void accessNativeMethod() throws ScriptException {
- assertEquals(4.0, e.eval("java.lang.StrictMath.log10(10000);"));
- }
-
- @Test
- public void accessConstructorOfAbstractClass() throws ScriptException {
- e.eval("try {" +
- " var a = new java.util.AbstractList();" +
- " print('fail');" +
- "} catch(e) {" +
- " var isThrown = true;" +
- "}");
- assertEquals(true, e.get("isThrown"));
- }
-
- @Test
- public void accessMethodVoid() throws ScriptException {
- o.isAccessed = false;
- e.eval("o.voidMethod();");
- assertTrue(o.isAccessed);
- }
-
- @Test
- public void accessMethodBoolean() throws ScriptException {
- assertEquals(true, e.eval("o.booleanMethod(false);"));
- assertEquals(false, e.eval("o.booleanMethod(true);"));
- assertEquals(false, e.eval("o.booleanMethod('false');"));
- assertEquals(true, e.eval("o.booleanMethod('');"));
- assertEquals(true, e.eval("o.booleanMethod(0);"));
- }
-
- @Test
- public void accessMethodInt() throws ScriptException {
- assertEquals(0, e.eval("o.intMethod(0);"));
- assertEquals(-200, e.eval("o.intMethod(-100);"));
- assertEquals(0, e.eval("o.intMethod('0');"));
- assertEquals(-200, e.eval("o.intMethod('-100');"));
- }
-
- @Test
- public void accessMethodLong() throws ScriptException {
- assertEquals((long)0, e.eval("o.longMethod(0);"));
- assertEquals((long)400, e.eval("o.longMethod(200);"));
- assertEquals((long) 0, e.eval("o.longMethod('0');"));
- assertEquals((long) 400, e.eval("o.longMethod('200');"));
- }
-
- @Test
- public void accessMethodByte() throws ScriptException {
- assertEquals((byte) 0, e.eval("o.byteMethod(0);"));
- assertEquals((byte) 10, e.eval("o.byteMethod(5);"));
- assertEquals((byte) 0, e.eval("o.byteMethod('0');"));
- assertEquals((byte) 10, e.eval("o.byteMethod('5');"));
- }
-
- @Test
- public void accessMethodShort() throws ScriptException {
- assertEquals((short)0, e.eval("o.shortMethod(0);"));
- assertEquals((short)8000, e.eval("o.shortMethod(4000);"));
- assertEquals((short) 0, e.eval("o.shortMethod('0');"));
- assertEquals((short) 8000, e.eval("o.shortMethod('4000');"));
- }
-
- @Test
- public void accessMethodChar() throws ScriptException {
- assertEquals('A', e.eval("o.charMethod('a');"));
- assertEquals('Z', e.eval("o.charMethod('z');"));
- assertEquals(o.charMethod((char)0), e.eval("o.charMethod(0);"));
- assertEquals(o.charMethod((char)3150), e.eval("o.charMethod(3150);"));
- }
-
- @Test
- public void accessMethodFloat() throws ScriptException {
- assertEquals(0.0f, e.eval("o.floatMethod(0.0);"));
- assertEquals(4.2f, e.eval("o.floatMethod(2.1);"));
- assertEquals(0.0f, e.eval("o.floatMethod('0.0');"));
- assertEquals(4.2f, e.eval("o.floatMethod('2.1');"));
- }
-
- @Test
- public void accessMethodDouble() throws ScriptException {
- assertEquals(0.0, e.eval("o.doubleMethod(0.0);"));
- assertEquals(14.0, e.eval("o.doubleMethod(7.0);"));
- assertEquals(0.0, e.eval("o.doubleMethod('0.0');"));
- assertEquals(14.0, e.eval("o.doubleMethod('7.0');"));
- }
-
- @Test
- public void accessMethodBooleanBoxing() throws ScriptException {
- assertEquals(Boolean.TRUE, e.eval("o.booleanBoxingMethod(java.lang.Boolean.FALSE);"));
- assertEquals(Boolean.FALSE, e.eval("o.booleanBoxingMethod(java.lang.Boolean.TRUE);"));
- assertEquals(Boolean.TRUE, e.eval("o.booleanBoxingMethod('');"));
- assertEquals(Boolean.FALSE, e.eval("o.booleanBoxingMethod('false');"));
- }
-
- @Test
- public void accessMethodIntBoxing() throws ScriptException {
- assertEquals(0, e.eval("o.intBoxingMethod(0);"));
- assertEquals(-200, e.eval("o.intBoxingMethod(-100);"));
- assertTrue((int)e.eval("(new java.lang.Integer(2)).compareTo(10.0)") < 0);
- }
-
- @Test
- public void accessMethodLongBoxing() throws ScriptException {
- assertEquals((long) 0, e.eval("o.longBoxingMethod(0);"));
- assertEquals((long) 400, e.eval("o.longBoxingMethod(200);"));
- assertTrue((int)e.eval("(new java.lang.Long(2)).compareTo(10.0)") < 0);
- }
-
- @Test
- public void accessMethodByteBoxing() throws ScriptException {
- assertEquals((byte) 0, e.eval("o.byteBoxingMethod(0);"));
- assertEquals((byte) 10, e.eval("o.byteBoxingMethod(5);"));
- assertTrue((int)e.eval("(new java.lang.Byte(2)).compareTo(10.0)") < 0);
- }
-
- @Test
- public void accessMethodShortBoxing() throws ScriptException {
- assertEquals((short) 0, e.eval("o.shortBoxingMethod(0);"));
- assertEquals((short) 8000, e.eval("o.shortBoxingMethod(4000);"));
- assertTrue((int)e.eval("(new java.lang.Short(2)).compareTo(10.0)") < 0);
- }
-
- @Test
- public void accessMethodCharBoxing() throws ScriptException {
- assertEquals('A', e.eval("o.charBoxingMethod('a');"));
- assertEquals('Z', e.eval("o.charBoxingMethod('z');"));
- assertTrue((int)e.eval("(new java.lang.Character(2)).compareTo(10)") < 0);
- }
-
- @Test
- public void accessMethodFloatBoxing() throws ScriptException {
- assertEquals(0.0f, e.eval("o.floatBoxingMethod(0.0);"));
- assertEquals(4.2f, e.eval("o.floatBoxingMethod(2.1);"));
- assertTrue((int)e.eval("(new java.lang.Float(2.0)).compareTo(10.0)") < 0);
- }
-
- @Test
- public void accessMethodDoubleBoxing() throws ScriptException {
- assertEquals(0.0, e.eval("o.doubleBoxingMethod(0.0);"));
- assertEquals(14.0, e.eval("o.doubleBoxingMethod(7.0);"));
- assertTrue((int)e.eval("(new java.lang.Double(2)).compareTo(10.0)") < 0);
- }
-
- @Test
- public void accessMethodString() throws ScriptException {
- assertEquals("", e.eval("o.stringMethod('');"));
- assertEquals("abcabc", e.eval("o.stringMethod('abc');"));
- }
-
- @Test
- public void accessMethodObject() throws ScriptException {
- e.put("so", new Person(5));
- e.eval("var rso = o.objectMethod(so);");
- assertEquals(new Person(10), e.get("rso"));
- }
-
- @Test
- public void accessMethodBooleanArray() throws ScriptException {
- assertTrue(Arrays.equals(o.booleanArrayMethod(o.publicBooleanArray), (boolean[])e.eval("o.booleanArrayMethod(o.publicBooleanArray);")));
- }
-
- @Test
- public void accessMethodIntArray() throws ScriptException {
- assertArrayEquals(o.intArrayMethod(o.publicIntArray), (int[])e.eval("o.intArrayMethod(o.publicIntArray);"));
- }
-
- @Test
- public void accessMethodLongArray() throws ScriptException {
- assertArrayEquals(o.longArrayMethod(o.publicLongArray), (long[])e.eval("o.longArrayMethod(o.publicLongArray);"));
- }
-
- @Test
- public void accessMethodByteArray() throws ScriptException {
- assertArrayEquals(o.byteArrayMethod(o.publicByteArray), (byte[])e.eval("o.byteArrayMethod(o.publicByteArray);"));
- }
-
- @Test
- public void accessMethodShortArray() throws ScriptException {
- assertArrayEquals(o.shortArrayMethod(o.publicShortArray), (short[])e.eval("o.shortArrayMethod(o.publicShortArray);"));
- }
-
- @Test
- public void accessMethodCharArray() throws ScriptException {
- assertArrayEquals(o.charArrayMethod(o.publicCharArray), (char[])e.eval("o.charArrayMethod(o.publicCharArray);"));
- }
-
- @Test
- public void accessMethodFloatArray() throws ScriptException {
- assertArrayEquals(o.floatArrayMethod(o.publicFloatArray), (float[])e.eval("o.floatArrayMethod(o.publicFloatArray);"), 1e-10f);
- }
-
- @Test
- public void accessMethodDoubleArray() throws ScriptException {
- assertArrayEquals(o.doubleArrayMethod(o.publicDoubleArray), (double[])e.eval("o.doubleArrayMethod(o.publicDoubleArray);"), 1e-10);
- }
-
- @Test
- public void accessMethodStringArray() throws ScriptException {
- assertArrayEquals(o.stringArrayMethod(o.publicStringArray), (String[])e.eval("o.stringArrayMethod(o.publicStringArray);"));
- }
-
- @Test
- public void accessMethodObjectArray() throws ScriptException {
- assertArrayEquals(o.objectArrayMethod(o.publicObjectArray), (Person[])e.eval("o.objectArrayMethod(o.publicObjectArray);"));
- }
-
- @Test
- public void accessDefaultConstructor() throws ScriptException {
- e.eval("var dc = new Packages.jdk.nashorn.api.javaaccess.Person()");
- assertEquals(new Person(), e.get("dc"));
- }
-
- @Test
- public void accessCustomConstructor() throws ScriptException {
- e.eval("var cc = new Packages.jdk.nashorn.api.javaaccess.Person(17)");
- assertEquals(new Person(17), e.get("cc"));
- }
-
- @Test
- public void accessMethod2PrimitiveParams() throws ScriptException {
- assertEquals(o.twoParamMethod(50, 40.0), e.eval("o.twoParamMethod(50,40);"));
- }
-
- @Test
- public void accessMethod3PrimitiveParams() throws ScriptException {
- assertEquals(o.threeParamMethod((short)10, 20L, 'b'), e.eval("o.threeParamMethod(10,20,'b');"));
- }
-
- @Test
- public void accessMethod2ObjectParams() throws ScriptException {
- assertArrayEquals(new Person[] { new Person(200), new Person(300) }, (Person[])e.eval("o.twoObjectParamMethod(new Person(300),new Person(200));"));
- }
-
- @Test
- public void accessMethod3ObjectParams() throws ScriptException {
- assertArrayEquals(new Person[] { new Person(3), new Person(2), new Person(1) }, (Person[])e.eval("o.threeObjectParamMethod(new Person(1),new Person(2),new Person(3));"));
- }
-
- @Test
- public void accessMethod8ObjectParams() throws ScriptException {
- assertArrayEquals(new Person[] { new Person(8), new Person(7), new Person(6), new Person(5), new Person(4), new Person(3), new Person(2), new Person(1) }, (Person[])e.eval("o.eightObjectParamMethod(new Person(1),new Person(2),new Person(3)," + "new Person(4),new Person(5),new Person(6),new Person(7),new Person(8));"));
- }
-
- @Test
- public void accessMethod9ObjectParams() throws ScriptException {
- assertArrayEquals(new Person[] { new Person(9), new Person(8), new Person(7), new Person(6), new Person(5), new Person(4), new Person(3), new Person(2), new Person(1) }, (Person[])e.eval("o.nineObjectParamMethod(new Person(1),new Person(2),new Person(3)," + "new Person(4),new Person(5),new Person(6)," + "new Person(7),new Person(8),new Person(9));"));
- }
-
- @Test
- public void accessMethodObjectEllipsis() throws ScriptException {
- assertArrayEquals(new Person[] { new Person(9), new Person(8), new Person(7), new Person(6), new Person(5), new Person(4), new Person(3), new Person(2), new Person(1) }, (Person[])e.eval("o.methodObjectEllipsis(new Person(1),new Person(2),new Person(3)," + "new Person(4),new Person(5),new Person(6)," + "new Person(7),new Person(8),new Person(9));"));
- assertArrayEquals(new Person[] {}, (Person[])e.eval("o.methodObjectEllipsis()"));
- assertArrayEquals(new Person[] { new Person(9) }, (Person[])e.eval("o.methodObjectEllipsis(new Person(9))"));
- }
-
- @Test
- public void accessMethodPrimitiveEllipsis() throws ScriptException {
- assertArrayEquals(new Person[] { new Person(1), new Person(3), new Person(2) }, (Person[])e.eval("o.methodPrimitiveEllipsis(1,3,2);"));
- assertArrayEquals(new Person[] {}, (Person[])e.eval("o.methodPrimitiveEllipsis();"));
- assertArrayEquals(o.methodPrimitiveEllipsis(9, 8, 7, 6, 5, 4, 3, 2, 1), (Person[])e.eval("o.methodPrimitiveEllipsis(9,8,7,6,5,4,3,2,1);"));
- }
-
- @Test
- public void accessMethodMixedEllipsis() throws ScriptException {
- assertArrayEquals(new Object[] { new Person(1), 12, "hello", true }, (Object[])e.eval("o.methodMixedEllipsis(new Person(1),12,'hello',true);"));
- assertArrayEquals(new Object[] {}, (Object[])e.eval("o.methodMixedEllipsis();"));
- }
-
- @Test
- public void accessMethodObjectWithEllipsis() throws ScriptException {
- assertArrayEquals(new Object[] { "hello", 12, 15, 16 }, (Object[])e.eval("o.methodObjectWithEllipsis('hello',12,15,16);"));
- assertArrayEquals(new Object[] { "hello" }, (Object[])e.eval("o.methodObjectWithEllipsis('hello');"));
- }
-
- @Test
- public void accessMethodPrimitiveWithEllipsis() throws ScriptException {
- assertArrayEquals(new Object[] { 14, 12L, 15L, 16L }, (Object[])e.eval("o.methodPrimitiveWithEllipsis(14,12,15,16);"));
- assertArrayEquals(new Object[] { 12 }, (Object[])e.eval("o.methodPrimitiveWithEllipsis(12);"));
- }
-
- @Test
- public void accessMethodMixedWithEllipsis() throws ScriptException {
- assertArrayEquals(new Object[] { "Hello", 10, true, -100500, 80d }, (Object[])e.eval("o.methodMixedWithEllipsis('Hello', 10, true, -100500,80.0);"));
- assertArrayEquals(new Object[] { "Nashorn", 15 }, (Object[])e.eval("o.methodMixedWithEllipsis('Nashorn',15);"));
- }
-
- @Test
- public void accessMethodOverloaded() throws ScriptException {
- assertEquals(0, e.eval("o.overloadedMethod(0);"));
- assertEquals(2000, e.eval("o.overloadedMethod(1000);"));
- assertEquals(2, e.eval("o.overloadedMethod('10');"));
- assertEquals(7, e.eval("o.overloadedMethod('Nashorn');"));
- assertEquals(4, e.eval("o.overloadedMethod('true');"));
- assertEquals(1, e.eval("o.overloadedMethod(true);"));
- assertEquals(0, e.eval("o.overloadedMethod(false);"));
- assertEquals(44, e.eval("o.overloadedMethod(new Person(22));"));
- assertEquals(0, e.eval("o.overloadedMethod(new Person());"));
- }
-
- @Test
- public void accessMethodDoubleVSintOverloaded() throws ScriptException {
- assertEquals("double", e.eval("o.overloadedMethodDoubleVSint(0.0);"));
- assertEquals("double", e.eval("o.overloadedMethodDoubleVSint(1000.0);"));
- assertEquals("double", e.eval("o.overloadedMethodDoubleVSint(0.01);"));
- assertEquals("double", e.eval("o.overloadedMethodDoubleVSint(100.02);"));
- assertEquals("int", e.eval("o.overloadedMethodDoubleVSint(0);"));
- assertEquals("int", e.eval("o.overloadedMethodDoubleVSint(1000);"));
- }
-
- @Test
- public void accessJavaMethodIntFromJSFromJavaFromJS() throws ScriptException {
- e.eval("function secondLevelMethodInt(a) {"
- + "return o.thirdLevelMethodInt(a);"
- + "}");
- assertEquals(50, e.eval("o.firstLevelMethodInt(10);"));
- }
-
- @Test
- public void accessJavaMethodIntegerFromJSFromJavaFromJS() throws ScriptException {
- e.eval("function secondLevelMethodInteger(a) {"
- + "return o.thirdLevelMethodInteger(a);"
- + "}");
- assertEquals(100, e.eval("o.firstLevelMethodInteger(10);"));
- }
-
- @Test
- public void accessJavaMethodObjectFromJSFromJavaFromJS() throws ScriptException {
- e.eval("function secondLevelMethodObject(p) {"
- + "return o.thirdLevelMethodObject(p);"
- + "}");
- assertEquals(new Person(100), e.eval("o.firstLevelMethodObject(new Person(10));"));
- }
-
-}
--- a/nashorn/test/src/jdk/nashorn/api/javaaccess/NumberAccessTest.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,789 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.javaaccess;
-
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
-import javax.script.ScriptException;
-import org.testng.TestNG;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- * @test
- * @build jdk.nashorn.api.javaaccess.SharedObject jdk.nashorn.api.javaaccess.Person jdk.nashorn.api.javaaccess.NumberAccessTest
- * @run testng/othervm jdk.nashorn.api.javaaccess.NumberAccessTest
- */
-@SuppressWarnings("javadoc")
-public class NumberAccessTest {
-
- private static ScriptEngine e;
- private static SharedObject o;
-
- public static void main(final String[] args) {
- TestNG.main(args);
- }
-
- @BeforeClass
- public static void setUpClass() throws ScriptException {
- final ScriptEngineManager m = new ScriptEngineManager();
- e = m.getEngineByName("nashorn");
- o = new SharedObject();
- e.put("o", o);
- e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.SharedObject;");
- }
-
- @AfterClass
- public static void tearDownClass() {
- e = null;
- o = null;
- }
-
- // --------------------------------long
- // tests------------------------------------
- @Test
- public void accessFieldLong() throws ScriptException {
- e.eval("var p_long = o.publicLong;");
- assertEquals(o.publicLong, e.get("p_long"));
- e.eval("o.publicLong = 12;");
- assertEquals(12, o.publicLong);
- }
-
- @Test
- public void accessFieldLongArray() throws ScriptException {
- e.eval("var p_long_array = o.publicLongArray;");
- assertEquals(o.publicLongArray[0], e.eval("o.publicLongArray[0];"));
- assertArrayEquals(o.publicLongArray, (long[])e.get("p_long_array"));
- e.eval("var t_long_arr = new (Java.type(\"long[]\"))(3);" +
- "t_long_arr[0] = -189009;" +
- "t_long_arr[1] = 456;" +
- "t_long_arr[2] = 600000001;" +
- "o.publicLongArray = t_long_arr;");
- // e.eval("o.publicIntArray = [-189009,456,600000001];");
- assertArrayEquals(new long[] { -189009, 456, 600000001 }, o.publicLongArray);
- e.eval("o.publicLongArray[0] = 10;");
- assertEquals(10, o.publicLongArray[0]);
- }
-
- @Test
- public void accessStaticFieldLong() throws ScriptException {
- e.eval("var ps_long = SharedObject.publicStaticLong;");
- assertEquals(SharedObject.publicStaticLong, e.get("ps_long"));
- e.eval("SharedObject.publicStaticLong = 120;");
- assertEquals(120, SharedObject.publicStaticLong);
- }
-
- @Test
- public void accessStaticFieldLongArray() throws ScriptException {
- e.eval("var ps_long_array = SharedObject.publicStaticLongArray;");
- assertEquals(SharedObject.publicStaticLongArray[0], e.eval("SharedObject.publicStaticLongArray[0];"));
- assertArrayEquals(SharedObject.publicStaticLongArray, (long[])e.get("ps_long_array"));
- e.eval("var ts_long_arr = new (Java.type(\"long[]\"))(3);" +
- "ts_long_arr[0] = -189009;" +
- "ts_long_arr[1] = 456;" +
- "ts_long_arr[2] = 600000001;" +
- "SharedObject.publicStaticLongArray = ts_long_arr;");
- // e.eval("o.publicIntArray = [-189009,456,600000001];");
- assertArrayEquals(new long[] { -189009, 456, 600000001 }, SharedObject.publicStaticLongArray);
- e.eval("SharedObject.publicStaticLongArray[0] = 10;");
- assertEquals(10, SharedObject.publicStaticLongArray[0]);
- }
-
- @Test
- public void accessFinalFieldLong() throws ScriptException {
- e.eval("var pf_long = o.publicFinalLong;");
- assertEquals(o.publicFinalLong, e.get("pf_long"));
- e.eval("o.publicFinalLong = 120;");
- assertEquals(13353333333333333L, o.publicFinalLong);
- }
-
- @Test
- public void accessFinalFieldLongArray() throws ScriptException {
- e.eval("var pf_long_array = o.publicFinalLongArray;");
- assertEquals(o.publicFinalLongArray[0], e.eval("o.publicFinalLongArray[0];"));
- assertArrayEquals(o.publicFinalLongArray, (long[])e.get("pf_long_array"));
- e.eval("var tf_long_arr = new (Java.type(\"long[]\"))(3);" +
- "tf_long_arr[0] = -189009;" +
- "tf_long_arr[1] = 456;" +
- "tf_long_arr[2] = 600000001;" +
- "o.publicFinalLongArray = tf_long_arr;");
- // e.eval("o.publicIntArray = [-189009,456,600000001];");
- assertArrayEquals(new long[] { 1901733333333L, -2247355555L, 3977377777L }, o.publicFinalLongArray);
- e.eval("o.publicFinalLongArray[0] = 10;");
- assertEquals(10, o.publicFinalLongArray[0]);
- }
-
- @Test
- public void accessStaticFinalFieldLong() throws ScriptException {
- e.eval("var psf_long = SharedObject.publicStaticFinalLong;");
- assertEquals(SharedObject.publicStaticFinalLong, e.get("psf_long"));
- e.eval("SharedObject.publicStaticFinalLong = 120;");
- assertEquals(8333333333333L, SharedObject.publicStaticFinalLong);
- }
-
- @Test
- public void accessStaticFinalFieldLongArray() throws ScriptException {
- e.eval("var psf_long_array = SharedObject.publicStaticFinalLongArray;");
- assertEquals(SharedObject.publicStaticFinalLongArray[0], e.eval("SharedObject.publicStaticFinalLongArray[0];"));
- assertArrayEquals(SharedObject.publicStaticFinalLongArray, (long[])e.get("psf_long_array"));
- e.eval("var tsf_long_arr = new (Java.type(\"long[]\"))(3);" +
- "tsf_long_arr[0] = -189009;" +
- "tsf_long_arr[1] = 456;" +
- "tsf_long_arr[2] = 600000001;" +
- "SharedObject.publicStaticFinalLongArray = tsf_long_arr;");
- // e.eval("o.publicIntArray = [-189009,456,600000001];");
- assertArrayEquals(new long[] { 19017383333L, -2247358L, 39773787L }, SharedObject.publicStaticFinalLongArray);
- e.eval("SharedObject.publicStaticFinalLongArray[0] = 10;");
- assertEquals(10, SharedObject.publicStaticFinalLongArray[0]);
- }
-
- // --------------------------------int
- // tests------------------------------------
- @Test
- public void accessFieldInt() throws ScriptException {
- e.eval("var p_int = o.publicInt;");
- assertEquals(o.publicInt, e.get("p_int"));
- e.eval("o.publicInt = 14;");
- assertEquals(14, o.publicInt);
- }
-
- @Test
- public void accessFieldIntArray() throws ScriptException {
- e.eval("var p_int_array = o.publicIntArray;");
- assertEquals(o.publicIntArray[0], e.eval("o.publicIntArray[0];"));
- assertArrayEquals(o.publicIntArray, (int[])e.get("p_int_array"));
- e.eval("var t_int_arr = new (Java.type(\"int[]\"))(3);" +
- "t_int_arr[0] = 4;" +
- "t_int_arr[1] = 5;" +
- "t_int_arr[2] = 6;" +
- "o.publicIntArray = t_int_arr;");
- assertArrayEquals(new int[] { 4, 5, 6 }, o.publicIntArray);
- e.eval("o.publicIntArray[0] = 100;");
- assertEquals(100, o.publicIntArray[0]);
- }
-
- @Test
- public void accessStaticFieldInt() throws ScriptException {
- e.eval("var ps_int = SharedObject.publicStaticInt;");
- assertEquals(SharedObject.publicStaticInt, e.get("ps_int"));
- e.eval("SharedObject.publicStaticInt = 140;");
- assertEquals(140, SharedObject.publicStaticInt);
- }
-
- @Test
- public void accessStaticFieldIntArray() throws ScriptException {
- e.eval("var ps_int_array = SharedObject.publicStaticIntArray;");
- assertEquals(SharedObject.publicStaticIntArray[0], e.eval("SharedObject.publicStaticIntArray[0];"));
- assertArrayEquals(SharedObject.publicStaticIntArray, (int[])e.get("ps_int_array"));
- e.eval("var ts_int_arr = new (Java.type(\"int[]\"))(3);" +
- "ts_int_arr[0] = 4;" +
- "ts_int_arr[1] = 5;" +
- "ts_int_arr[2] = 6;" +
- "SharedObject.publicStaticIntArray = ts_int_arr;");
- assertArrayEquals(new int[] { 4, 5, 6 }, SharedObject.publicStaticIntArray);
- e.eval("SharedObject.publicStaticIntArray[0] = 100;");
- assertEquals(100, SharedObject.publicStaticIntArray[0]);
- }
-
- @Test
- public void accessFinalFieldInt() throws ScriptException {
- e.eval("var pf_int = o.publicFinalInt;");
- assertEquals(o.publicFinalInt, e.get("pf_int"));
-
- e.eval("o.publicFinalInt = 10;");
- assertEquals(20712023, o.publicFinalInt);
- }
-
- @Test
- public void accessFinalFieldIntArray() throws ScriptException {
- e.eval("var pf_int_array = o.publicFinalIntArray;");
- assertEquals(o.publicFinalIntArray[0], e.eval("o.publicFinalIntArray[0];"));
- assertArrayEquals(o.publicFinalIntArray, (int[])e.get("pf_int_array"));
- e.eval("var tf_int_arr = new (Java.type(\"int[]\"))(3);" +
- "tf_int_arr[0] = 4;" +
- "tf_int_arr[1] = 5;" +
- "tf_int_arr[2] = 6;" +
- "o.publicFinalIntArray = tf_int_arr;");
- assertArrayEquals(new int[] { 50, 80, 130, 210, 340 }, o.publicFinalIntArray);
- e.eval("o.publicFinalIntArray[0] = 100;");
- assertEquals(100, o.publicFinalIntArray[0]);
- }
-
- @Test
- public void accessStaticFinalFieldInt() throws ScriptException {
- e.eval("var psf_int = SharedObject.publicStaticFinalInt;");
- assertEquals(SharedObject.publicStaticFinalInt, e.get("psf_int"));
- e.eval("SharedObject.publicStaticFinalInt = 140;");
- assertEquals(207182023, SharedObject.publicStaticFinalInt);
- }
-
- @Test
- public void accessStaticFinalFieldIntArray() throws ScriptException {
- e.eval("var psf_int_array = SharedObject.publicStaticFinalIntArray;");
- assertEquals(SharedObject.publicStaticFinalIntArray[0], e.eval("SharedObject.publicStaticFinalIntArray[0];"));
- assertArrayEquals(SharedObject.publicStaticFinalIntArray, (int[])e.get("psf_int_array"));
- e.eval("var tsf_int_arr = new (Java.type(\"int[]\"))(3);" +
- "tsf_int_arr[0] = 4;" +
- "tsf_int_arr[1] = 5;" +
- "tsf_int_arr[2] = 6;" +
- "SharedObject.publicStaticFinalIntArray = tsf_int_arr;");
- assertArrayEquals(new int[] { 1308, 210, 340 }, SharedObject.publicStaticFinalIntArray);
- e.eval("SharedObject.publicStaticFinalIntArray[0] = 100;");
- assertEquals(100, SharedObject.publicStaticFinalIntArray[0]);
- }
-
- // --------------------------------byte
- // tests------------------------------------
- @Test
- public void accessFieldByte() throws ScriptException {
- e.eval("var p_byte = o.publicByte;");
- assertEquals((double)o.publicByte, ((Number)e.get("p_byte")).doubleValue());
- e.eval("o.publicByte = 16;");
- assertEquals(16, o.publicByte);
- }
-
- @Test
- public void accessFieldByteArray() throws ScriptException {
- e.eval("var p_byte_array = o.publicByteArray;");
- assertEquals(o.publicByteArray[0], e.eval("o.publicByteArray[0];"));
- assertArrayEquals(o.publicByteArray, (byte[])e.get("p_byte_array"));
- e.eval("var t_byte_arr = new (Java.type(\"byte[]\"))(3);" +
- "t_byte_arr[0] = -18;" +
- "t_byte_arr[1] = 56;" +
- "t_byte_arr[2] = 60;" +
- "o.publicByteArray = t_byte_arr;");
- assertArrayEquals(new byte[] { -18, 56, 60 }, o.publicByteArray);
- e.eval("o.publicByteArray[0] = 100;");
- assertEquals(100, o.publicByteArray[0]);
- }
-
- @Test
- public void accessStaticFieldByte() throws ScriptException {
- e.eval("var ps_byte = SharedObject.publicStaticByte;");
- assertEquals((double)SharedObject.publicStaticByte, ((Number)e.get("ps_byte")).doubleValue());
- e.eval("SharedObject.publicStaticByte = 16;");
- assertEquals(16, SharedObject.publicStaticByte);
- }
-
- @Test
- public void accessStaticFieldByteArray() throws ScriptException {
- e.eval("var ps_byte_array = SharedObject.publicStaticByteArray;");
- assertEquals(SharedObject.publicStaticByteArray[0], e.eval("SharedObject.publicStaticByteArray[0];"));
- assertArrayEquals(SharedObject.publicStaticByteArray, (byte[])e.get("ps_byte_array"));
- e.eval("var ts_byte_arr = new (Java.type(\"byte[]\"))(3);" +
- "ts_byte_arr[0] = -18;" +
- "ts_byte_arr[1] = 56;" +
- "ts_byte_arr[2] = 60;" +
- "SharedObject.publicStaticByteArray = ts_byte_arr;");
- assertArrayEquals(new byte[] { -18, 56, 60 }, SharedObject.publicStaticByteArray);
- e.eval("SharedObject.publicStaticByteArray[0] = -90;");
- assertEquals(-90, SharedObject.publicStaticByteArray[0]);
- }
-
- @Test
- public void accessFinalFieldByte() throws ScriptException {
- e.eval("var pf_byte = o.publicFinalByte;");
- assertEquals((double)o.publicFinalByte, ((Number)e.get("pf_byte")).doubleValue());
- e.eval("o.publicFinalByte = 16;");
- assertEquals(-7, o.publicFinalByte);
- }
-
- @Test
- public void accessFinalFieldByteArray() throws ScriptException {
- e.eval("var pf_byte_array = o.publicFinalByteArray;");
- assertEquals(o.publicFinalByteArray[0], e.eval("o.publicFinalByteArray[0];"));
- assertArrayEquals(o.publicFinalByteArray, (byte[])e.get("pf_byte_array"));
- e.eval("var tf_byte_arr = new (Java.type(\"byte[]\"))(3);" +
- "tf_byte_arr[0] = -18;" +
- "tf_byte_arr[1] = 56;" +
- "tf_byte_arr[2] = 60;" +
- "o.publicFinalByteArray = tf_byte_arr;");
- assertArrayEquals(new byte[] { 1, 3, 6, 17, -128 }, o.publicFinalByteArray);
- e.eval("o.publicFinalByteArray[0] = -90;");
- assertEquals(-90, o.publicFinalByteArray[0]);
- }
-
- @Test
- public void accessStaticFinalFieldByte() throws ScriptException {
- e.eval("var psf_byte = SharedObject.publicStaticFinalByte;");
- assertEquals((double)SharedObject.publicStaticFinalByte, ((Number)e.get("psf_byte")).doubleValue());
- e.eval("SharedObject.publicStaticFinalByte = 16;");
- assertEquals(-70, SharedObject.publicStaticFinalByte);
- }
-
- @Test
- public void accessStaticFinalFieldByteArray() throws ScriptException {
- e.eval("var psf_byte_array = SharedObject.publicStaticFinalByteArray;");
- assertEquals(SharedObject.publicStaticFinalByteArray[0], e.eval("SharedObject.publicStaticFinalByteArray[0];"));
- assertArrayEquals(SharedObject.publicStaticFinalByteArray, (byte[])e.get("psf_byte_array"));
- e.eval("var tsf_byte_arr = new (Java.type(\"byte[]\"))(3);" +
- "tsf_byte_arr[0] = -18;" +
- "tsf_byte_arr[1] = 56;" +
- "tsf_byte_arr[2] = 60;" +
- "SharedObject.publicStaticFinalByteArray = tsf_byte_arr;");
- assertArrayEquals(new byte[] { 17, -128, 81 }, SharedObject.publicStaticFinalByteArray);
- e.eval("SharedObject.publicStaticFinalByteArray[0] = -90;");
- assertEquals(-90, SharedObject.publicStaticFinalByteArray[0]);
- }
-
- // --------------------------------short
- // tests------------------------------------
- @Test
- public void accessFieldShort() throws ScriptException {
- e.eval("var p_short = o.publicShort;");
- assertEquals((double)o.publicShort, ((Number)e.get("p_short")).doubleValue());
- e.eval("o.publicShort = 18;");
- assertEquals(18, o.publicShort);
- }
-
- @Test
- public void accessFieldShortArray() throws ScriptException {
- e.eval("var p_short_array = o.publicShortArray;");
- assertEquals(o.publicShortArray[0], e.eval("o.publicShortArray[0];"));
- assertArrayEquals(o.publicShortArray, (short[])e.get("p_short_array"));
- e.eval("var t_short_arr = new (Java.type(\"short[]\"))(3);" +
- "t_short_arr[0] = 90;" +
- "t_short_arr[1] = 5;" +
- "t_short_arr[2] = -6000;" +
- "o.publicShortArray = t_short_arr;");
- assertArrayEquals(new short[] { 90, 5, -6000 }, o.publicShortArray);
- e.eval("o.publicShortArray[0] = -1000;");
- assertEquals(-1000, o.publicShortArray[0]);
- }
-
- @Test
- public void accessStaticFieldShort() throws ScriptException {
- e.eval("var ps_short = SharedObject.publicStaticShort;");
- assertEquals((double)SharedObject.publicStaticShort, ((Number)e.get("ps_short")).doubleValue());
- e.eval("SharedObject.publicStaticShort = 180;");
- assertEquals(180, SharedObject.publicStaticShort);
- }
-
- @Test
- public void accessStaticFieldShortArray() throws ScriptException {
- e.eval("var ps_short_array = SharedObject.publicStaticShortArray;");
- assertEquals(SharedObject.publicStaticShortArray[0], e.eval("SharedObject.publicStaticShortArray[0];"));
- assertArrayEquals(SharedObject.publicStaticShortArray, (short[])e.get("ps_short_array"));
- e.eval("var ts_short_arr = new (Java.type(\"short[]\"))(3);" +
- "ts_short_arr[0] = 90;" +
- "ts_short_arr[1] = 5;" +
- "ts_short_arr[2] = -6000;" +
- "SharedObject.publicStaticShortArray = ts_short_arr;");
- assertArrayEquals(new short[] { 90, 5, -6000 }, SharedObject.publicStaticShortArray);
- e.eval("SharedObject.publicStaticShortArray[0] = -1000;");
- assertEquals(-1000, SharedObject.publicStaticShortArray[0]);
- }
-
- @Test
- public void accessFinalFieldShort() throws ScriptException {
- e.eval("var pf_short = o.publicFinalShort;");
- assertEquals((double)o.publicFinalShort, ((Number)e.get("pf_short")).doubleValue());
- e.eval("o.publicFinalShort = 180;");
- assertEquals(31220, o.publicFinalShort);
- }
-
- @Test
- public void accessFinalFieldShortArray() throws ScriptException {
- e.eval("var pf_short_array = o.publicFinalShortArray;");
- assertEquals(o.publicFinalShortArray[0], e.eval("o.publicFinalShortArray[0];"));
- assertArrayEquals(o.publicFinalShortArray, (short[])e.get("pf_short_array"));
- e.eval("var tf_short_arr = new (Java.type(\"short[]\"))(3);" +
- "tf_short_arr[0] = 90;" +
- "tf_short_arr[1] = 5;" +
- "tf_short_arr[2] = -6000;" +
- "o.publicFinalShortArray = tf_short_arr;");
- assertArrayEquals(new short[] { 12240, 9200, -17289, 1200, 12 }, o.publicFinalShortArray);
- e.eval("o.publicFinalShortArray[0] = -1000;");
- assertEquals(-1000, o.publicFinalShortArray[0]);
- }
-
- @Test
- public void accessStaticFinalFieldShort() throws ScriptException {
- e.eval("var psf_short = SharedObject.publicStaticFinalShort;");
- assertEquals((double)SharedObject.publicStaticFinalShort, ((Number)e.get("psf_short")).doubleValue());
- e.eval("SharedObject.publicStaticFinalShort = 180;");
- assertEquals(8888, SharedObject.publicStaticFinalShort);
- }
-
- @Test
- public void accessStaticFinalFieldShortArray() throws ScriptException {
- e.eval("var psf_short_array = SharedObject.publicStaticFinalShortArray;");
- assertEquals(SharedObject.publicStaticFinalShortArray[0], e.eval("SharedObject.publicStaticFinalShortArray[0];"));
- assertArrayEquals(SharedObject.publicStaticFinalShortArray, (short[])e.get("psf_short_array"));
- e.eval("var tsf_short_arr = new (Java.type(\"short[]\"))(3);" +
- "tsf_short_arr[0] = 90;" +
- "tsf_short_arr[1] = 5;" +
- "tsf_short_arr[2] = -6000;" +
- "SharedObject.publicStaticFinalShortArray = tsf_short_arr;");
- assertArrayEquals(new short[] { 8240, 9280, -1289, 120, 812 }, SharedObject.publicStaticFinalShortArray);
- e.eval("SharedObject.publicStaticFinalShortArray[0] = -1000;");
- assertEquals(-1000, SharedObject.publicStaticFinalShortArray[0]);
- }
-
- // --------------------------------char
- // tests------------------------------------
- @Test
- public void accessFieldChar() throws ScriptException {
- e.eval("var p_char = o.publicChar;");
- assertEquals(o.publicChar, e.get("p_char"));
- e.eval("o.publicChar = 'S';");
- assertEquals('S', o.publicChar);
- e.eval("o.publicChar = 10;");
- assertEquals(10, o.publicChar);
- e.eval("try {"
- + " o.publicChar = 'Big string';" +
- "} catch(e) {" +
- " var isThrown = true;" +
- "}");
- assertEquals("Exception thrown", true, e.get("isThrown"));
- assertEquals(10, o.publicChar);
- }
-
- @Test
- public void accessFieldCharArray() throws ScriptException {
- e.eval("var p_char_array = o.publicCharArray;");
- assertEquals(o.publicCharArray[0], e.eval("o.publicCharArray[0];"));
- assertArrayEquals(o.publicCharArray, (char[])e.get("p_char_array"));
- e.eval("var t_char_arr = new (Java.type(\"char[]\"))(3);" +
- "t_char_arr[0] = 'F';" +
- "t_char_arr[1] = 'o';" +
- "t_char_arr[2] = 'o';" +
- "o.publicCharArray = t_char_arr;");
- assertArrayEquals("Foo".toCharArray(), o.publicCharArray);
- e.eval("o.publicCharArray[0] = 'Z';");
- assertEquals('Z', o.publicCharArray[0]);
- }
-
- @Test
- public void accessStaticFieldChar() throws ScriptException {
- e.eval("var ps_char = SharedObject.publicStaticChar;");
- assertEquals(SharedObject.publicStaticChar, e.get("ps_char"));
- e.eval("SharedObject.publicStaticChar = 'Z';");
- assertEquals('Z', SharedObject.publicStaticChar);
- }
-
- @Test
- public void accessStaticFieldCharArray() throws ScriptException {
- e.eval("var ps_char_array = SharedObject.publicStaticCharArray;");
- assertEquals(SharedObject.publicStaticCharArray[0], e.eval("SharedObject.publicStaticCharArray[0];"));
- assertArrayEquals(SharedObject.publicStaticCharArray, (char[])e.get("ps_char_array"));
- e.eval("var ts_char_arr = new (Java.type(\"char[]\"))(3);" +
- "ts_char_arr[0] = 'G';" +
- "ts_char_arr[1] = 'o';" +
- "ts_char_arr[2] = 'o';" +
- "SharedObject.publicStaticCharArray = ts_char_arr;");
- assertArrayEquals("Goo".toCharArray(), SharedObject.publicStaticCharArray);
- e.eval("SharedObject.publicStaticCharArray[0] = 'Z';");
- assertEquals('Z', SharedObject.publicStaticCharArray[0]);
- }
-
- @Test
- public void accessFinalFieldChar() throws ScriptException {
- e.eval("var pf_char = o.publicFinalChar;");
- assertEquals(o.publicFinalChar, e.get("pf_char"));
- e.eval("o.publicFinalChar = 'S';");
- assertEquals('E', o.publicFinalChar);
- }
-
- @Test
- public void accessFinalCharArray() throws ScriptException {
- e.eval("var pf_char_array = o.publicFinalCharArray;");
- assertEquals(o.publicFinalCharArray[0], e.eval("o.publicFinalCharArray[0];"));
- assertArrayEquals(o.publicFinalCharArray, (char[])e.get("pf_char_array"));
- e.eval("var tf_char_arr = new (Java.type(\"char[]\"))(3);" +
- "tf_char_arr[0] = 'F';" +
- "tf_char_arr[1] = 'o';" +
- "tf_char_arr[2] = 'o';" +
- "o.publicFinalCharArray = tf_char_arr;");
- assertArrayEquals("Nashorn hello".toCharArray(), o.publicFinalCharArray);
- e.eval("o.publicFinalCharArray[0] = 'Z';");
- assertEquals('Z', o.publicFinalCharArray[0]);
- }
-
- @Test
- public void accessStaticFinalFieldChar() throws ScriptException {
- e.eval("var psf_char = SharedObject.publicStaticFinalChar;");
- assertEquals(SharedObject.publicStaticFinalChar, e.get("psf_char"));
- e.eval("SharedObject.publicStaticFinalChar = 'Z';");
- assertEquals('K', SharedObject.publicStaticFinalChar);
- }
-
- @Test
- public void accessStaticFinalFieldCharArray() throws ScriptException {
- e.eval("var psf_char_array = SharedObject.publicStaticFinalCharArray;");
- assertEquals(SharedObject.publicStaticFinalCharArray[0], e.eval("SharedObject.publicStaticFinalCharArray[0];"));
- assertArrayEquals(SharedObject.publicStaticFinalCharArray, (char[])e.get("psf_char_array"));
- e.eval("var tsf_char_arr = new (Java.type(\"char[]\"))(3);" +
- "tsf_char_arr[0] = 'Z';" +
- "tsf_char_arr[1] = 'o';" +
- "tsf_char_arr[2] = 'o';" +
- "SharedObject.publicStaticFinalCharArray = tsf_char_arr;");
- assertArrayEquals("StaticString".toCharArray(), SharedObject.publicStaticFinalCharArray);
- e.eval("SharedObject.publicStaticFinalCharArray[0] = 'Z';");
- assertEquals('Z', SharedObject.publicStaticFinalCharArray[0]);
- }
-
- // --------------------------------float
- // tests------------------------------------
- @Test
- public void accessFieldFloat() throws ScriptException {
- e.eval("var p_float = o.publicFloat;");
- assertEquals((double)o.publicFloat, ((Number)e.get("p_float")).doubleValue());
- o.publicFloat = 0.0f / 0.0f;
- assertEquals(true, e.eval("isNaN(o.publicFloat)"));
- o.publicFloat = 1.0f / 0.0f;
- assertEquals(true, e.eval("Number.POSITIVE_INFINITY === o.publicFloat"));
- o.publicFloat = -1.0f / 0.0f;
- assertEquals(true, e.eval("Number.NEGATIVE_INFINITY === o.publicFloat"));
- e.eval("o.publicFloat = 20;");
- assertEquals(20, o.publicFloat, 1e-10);
- e.eval("o.publicFloat = 0.0/0.0;");
- assertTrue(Float.isNaN(o.publicFloat));
- e.eval("o.publicFloat = 1.0/0.0;");
- assertEquals(Float.floatToIntBits(Float.POSITIVE_INFINITY), Float.floatToIntBits(o.publicFloat));
- e.eval("o.publicFloat = -1.0/0.0;");
- assertEquals(Float.NEGATIVE_INFINITY, o.publicFloat, 1e-10);
- }
-
- @Test
- public void accessFieldFloatArray() throws ScriptException {
- e.eval("var p_float_array = o.publicFloatArray;");
- assertEquals(o.publicFloatArray[0], e.eval("o.publicFloatArray[0];"));
- assertArrayEquals(o.publicFloatArray, (float[])e.get("p_float_array"), 1e-10f);
- e.eval("var t_float_arr = new (Java.type(\"float[]\"))(3);" +
- "t_float_arr[0] = 9.0;" +
- "t_float_arr[1] = 5.12345;" +
- "t_float_arr[2] = -60.03;" +
- "o.publicFloatArray = t_float_arr;");
- assertArrayEquals(new float[] { 9.0f, 5.12345f, -60.03f }, o.publicFloatArray, 1e-10f);
- e.eval("o.publicFloatArray[0] = -513.2;");
- assertArrayEquals(new float[] { -513.2f, 5.12345f, -60.03f }, o.publicFloatArray, 1e-10f);
- }
-
- @Test
- public void accessStaticFieldFloat() throws ScriptException {
- e.eval("var ps_float = SharedObject.publicStaticFloat;");
- assertEquals((double)SharedObject.publicStaticFloat, ((Number)e.get("ps_float")).doubleValue());
- SharedObject.publicStaticFloat = 0.0f / 0.0f;
- assertEquals(true, e.eval("isNaN(SharedObject.publicStaticFloat)"));
- SharedObject.publicStaticFloat = 1.0f / 0.0f;
- assertEquals(true, e.eval("Number.POSITIVE_INFINITY === SharedObject.publicStaticFloat"));
- SharedObject.publicStaticFloat = -1.0f / 0.0f;
- assertEquals(true, e.eval("Number.NEGATIVE_INFINITY === SharedObject.publicStaticFloat"));
- e.eval("SharedObject.publicStaticFloat = 20.0;");
- assertEquals(20.0f, SharedObject.publicStaticFloat, 1e-10);
- e.eval("SharedObject.publicStaticFloat = 0.0/0.0;");
- assertTrue(Float.isNaN(SharedObject.publicStaticFloat));
- e.eval("SharedObject.publicStaticFloat = 1.0/0.0;");
- assertEquals(Float.floatToIntBits(Float.POSITIVE_INFINITY), Float.floatToIntBits(SharedObject.publicStaticFloat));
- e.eval("SharedObject.publicStaticFloat = -1.0/0.0;");
- assertEquals(Float.floatToIntBits(Float.NEGATIVE_INFINITY), Float.floatToIntBits(SharedObject.publicStaticFloat));
- }
-
- @Test
- public void accessStaticFieldFloatArray() throws ScriptException {
- e.eval("var ps_float_array = SharedObject.publicStaticFloatArray;");
- assertEquals(SharedObject.publicStaticFloatArray[0], e.eval("SharedObject.publicStaticFloatArray[0];"));
- assertArrayEquals(SharedObject.publicStaticFloatArray, (float[])e.get("ps_float_array"), 1e-10f);
- e.eval("var ts_float_arr = new (Java.type(\"float[]\"))(3);" +
- "ts_float_arr[0] = 9.0;" +
- "ts_float_arr[1] = 5.12345;" +
- "ts_float_arr[2] = -60.03;" +
- "SharedObject.publicStaticFloatArray = ts_float_arr;");
- assertArrayEquals(new float[] { 9.0f, 5.12345f, -60.03f }, SharedObject.publicStaticFloatArray, 1e-10f);
- e.eval("SharedObject.publicStaticFloatArray[0] = -513.2;");
- assertArrayEquals(new float[] { -513.2f, 5.12345f, -60.03f }, SharedObject.publicStaticFloatArray, 1e-10f);
- }
-
- @Test
- public void accessFinalFloat() throws ScriptException {
- e.eval("var pf_float = o.publicFinalFloat;");
- assertEquals((double)o.publicFinalFloat, ((Number)e.get("pf_float")).doubleValue());
- e.eval("o.publicFinalFloat = 20.0;");
- assertEquals(7.72e8f, o.publicFinalFloat, 1e-10);
- }
-
- @Test
- public void accessFinalFloatArray() throws ScriptException {
- e.eval("var pf_float_array = o.publicFinalFloatArray;");
- assertEquals(o.publicFinalFloatArray[0], e.eval("o.publicFinalFloatArray[0];"));
- assertArrayEquals(o.publicFinalFloatArray, (float[])e.get("pf_float_array"), 1e-10f);
- e.eval("var tf_float_arr = new (Java.type(\"float[]\"))(3);" +
- "tf_float_arr[0] = 9.0;" +
- "tf_float_arr[1] = 5.12345;" +
- "tf_float_arr[2] = -60.03;" +
- "o.publicFinalFloatArray = tf_float_arr;");
- assertArrayEquals(new float[] { -131.012f, 189.32f, -31.32e8f, 3.72f }, o.publicFinalFloatArray, 1e-10f);
- e.eval("o.publicFinalFloatArray[0] = -513.2;");
- assertEquals(-513.2f, o.publicFinalFloatArray[0], 1e-10f);
- }
-
- @Test
- public void accessStaticFinalFieldFloat() throws ScriptException {
- e.eval("var psf_float = SharedObject.publicStaticFinalFloat;");
- assertEquals((double)SharedObject.publicStaticFinalFloat, ((Number)e.get("psf_float")).doubleValue());
- e.eval("SharedObject.publicStaticFinalFloat = 20.0;");
- assertEquals(0.72e8f, SharedObject.publicStaticFinalFloat, 1e-10);
- }
-
- @Test
- public void accessStaticFinalFieldFloatArray() throws ScriptException {
- e.eval("var psf_float_array = SharedObject.publicStaticFinalFloatArray;");
- assertEquals(SharedObject.publicStaticFinalFloatArray[0], e.eval("SharedObject.publicStaticFinalFloatArray[0];"));
- assertArrayEquals(SharedObject.publicStaticFinalFloatArray, (float[])e.get("psf_float_array"), 1e-10f);
- e.eval("var tsf_float_arr = new (Java.type(\"float[]\"))(3);" +
- "tsf_float_arr[0] = 9.0;" +
- "tsf_float_arr[1] = 5.12345;" +
- "tsf_float_arr[2] = -60.03;" +
- "SharedObject.publicStaticFinalFloatArray = tsf_float_arr;");
- assertArrayEquals(new float[] { -8131.012f, 9.32f, -138.32e8f, 0.72f }, SharedObject.publicStaticFinalFloatArray, 1e-10f);
- e.eval("SharedObject.publicStaticFinalFloatArray[0] = -513.2;");
- assertEquals(-513.2f, SharedObject.publicStaticFinalFloatArray[0], 1e-10f);
- }
-
- // --------------------------------double
- // tests------------------------------------
- @Test
- public void accessFieldDouble() throws ScriptException {
- e.eval("var p_double = o.publicDouble;");
- assertEquals(o.publicDouble, e.get("p_double"));
- o.publicDouble = 0.0 / 0.0;
- assertEquals(true, e.eval("isNaN(o.publicDouble)"));
- o.publicDouble = 1.0 / 0.0;
- assertEquals(true, e.eval("Number.POSITIVE_INFINITY === o.publicDouble"));
- o.publicDouble = -1.0 / 0.0;
- assertEquals(true, e.eval("Number.NEGATIVE_INFINITY === o.publicDouble"));
- e.eval("o.publicDouble = 30;");
- assertEquals(Double.doubleToLongBits(30.0), Double.doubleToLongBits(o.publicDouble));
- e.eval("o.publicDouble = 0.0/0.0;");
- assertTrue(Double.isNaN(o.publicDouble));
- e.eval("o.publicDouble = 1.0/0.0;");
- assertEquals(Double.doubleToLongBits(Double.POSITIVE_INFINITY), Double.doubleToLongBits(o.publicDouble));
- e.eval("o.publicDouble = -1.0/0.0;");
- assertEquals(Double.doubleToLongBits(Double.NEGATIVE_INFINITY), Double.doubleToLongBits(o.publicDouble));
- }
-
- @Test
- public void accessFieldDoubleArrayRead() throws ScriptException {
- e.eval("var p_double_array = o.publicDoubleArray;");
- assertEquals(o.publicDoubleArray[0], e.eval("o.publicDoubleArray[0];"));
- assertArrayEquals(o.publicDoubleArray, (double[])e.get("p_double_array"), 1e-10);
- e.eval("var t_double_arr = new (Java.type(\"double[]\"))(3);" +
- "t_double_arr[0] = 9e10;" +
- "t_double_arr[1] = 0.677777;" +
- "t_double_arr[2] = -0.0000001;" +
- "o.publicDoubleArray = t_double_arr;");
- assertArrayEquals(new double[] { 9e10, 0.677777, -0.0000001 }, o.publicDoubleArray, 1e-10f);
- e.eval("o.publicDoubleArray[0] = -5.2e10;");
- assertEquals(-5.2e10, o.publicDoubleArray[0], 1e-10f);
- }
-
- @Test
- public void accessStaticFieldDouble() throws ScriptException {
- e.eval("var ps_double = SharedObject.publicStaticDouble;");
- assertEquals(SharedObject.publicStaticDouble, e.get("ps_double"));
- SharedObject.publicStaticDouble = 0.0 / 0.0;
- assertEquals(true, e.eval("isNaN(SharedObject.publicStaticDouble)"));
- SharedObject.publicStaticDouble = 1.0 / 0.0;
- assertEquals(true, e.eval("Number.POSITIVE_INFINITY === SharedObject.publicStaticDouble"));
- SharedObject.publicStaticDouble = -1.0 / 0.0;
- assertEquals(true, e.eval("Number.NEGATIVE_INFINITY === SharedObject.publicStaticDouble"));
- e.eval("SharedObject.publicStaticDouble = 40.0;");
- assertEquals(Double.doubleToLongBits(40.0), Double.doubleToLongBits(SharedObject.publicStaticDouble));
- e.eval("SharedObject.publicStaticDouble = 0.0/0.0;");
- assertTrue(Double.isNaN(SharedObject.publicStaticDouble));
- e.eval("SharedObject.publicStaticDouble = 1.0/0.0;");
- assertEquals(Double.doubleToLongBits(Double.POSITIVE_INFINITY), Double.doubleToLongBits(SharedObject.publicStaticDouble));
- e.eval("SharedObject.publicStaticDouble = -1.0/0.0;");
- assertEquals(Double.doubleToLongBits(Double.NEGATIVE_INFINITY), Double.doubleToLongBits(SharedObject.publicStaticDouble));
- }
-
- @Test
- public void accessStaticFieldDoubleArrayRead() throws ScriptException {
- e.eval("var ps_double_array = SharedObject.publicStaticDoubleArray;");
- assertEquals(SharedObject.publicStaticDoubleArray[0], e.eval("SharedObject.publicStaticDoubleArray[0];"));
- assertArrayEquals(SharedObject.publicStaticDoubleArray, (double[])e.get("ps_double_array"), 1e-10);
- e.eval("var ts_double_arr = new (Java.type(\"double[]\"))(3);" +
- "ts_double_arr[0] = 9e10;" +
- "ts_double_arr[1] = 0.677777;" +
- "ts_double_arr[2] = -0.0000001;" +
- "SharedObject.publicStaticDoubleArray = ts_double_arr;");
- assertArrayEquals(new double[] { 9e10, 0.677777, -0.0000001 }, SharedObject.publicStaticDoubleArray, 1e-10f);
- e.eval("SharedObject.publicStaticDoubleArray[0] = -5.2e10;");
- assertEquals(-5.2e10, SharedObject.publicStaticDoubleArray[0], 1e-10f);
- }
-
- @Test
- public void accessFinalFieldDouble() throws ScriptException {
- e.eval("var pf_double = o.publicFinalDouble;");
- assertEquals(o.publicFinalDouble, e.get("pf_double"));
- e.eval("o.publicFinalDouble = 30.0;");
- assertEquals(Double.doubleToLongBits(1.3412e20), Double.doubleToLongBits(o.publicFinalDouble));
- }
-
- @Test
- public void accessFinalFieldDoubleArrayRead() throws ScriptException {
- e.eval("var pf_double_array = o.publicFinalDoubleArray;");
- assertEquals(o.publicFinalDoubleArray[0], e.eval("o.publicFinalDoubleArray[0];"));
- assertArrayEquals(o.publicFinalDoubleArray, (double[])e.get("pf_double_array"), 1e-10);
- e.eval("var tf_double_arr = new (Java.type(\"double[]\"))(3);" +
- "tf_double_arr[0] = 9e10;" +
- "tf_double_arr[1] = 0.677777;" +
- "tf_double_arr[2] = -0.0000001;" +
- "o.publicFinalDoubleArray = tf_double_arr;");
- assertArrayEquals(new double[] { 0.725e80, 0.12e10, 8e-3, 1.00077 }, o.publicFinalDoubleArray, 1e-10f);
- e.eval("o.publicFinalDoubleArray[0] = -5.2e10;");
- assertEquals(-5.2e10, o.publicFinalDoubleArray[0], 1e-10f);
- }
-
- @Test
- public void accessStaticFinalFieldDouble() throws ScriptException {
- e.eval("var psf_double = SharedObject.publicStaticFinalDouble;");
- assertEquals(SharedObject.publicStaticFinalDouble, e.get("psf_double"));
- e.eval("SharedObject.publicStaticFinalDouble = 40.0;");
- assertEquals(Double.doubleToLongBits(1.8e12), Double.doubleToLongBits(SharedObject.publicStaticFinalDouble));
- }
-
- @Test
- public void accessStaticFinalFieldDoubleArrayRead() throws ScriptException {
- e.eval("var psf_double_array = SharedObject.publicStaticFinalDoubleArray;");
- assertEquals(SharedObject.publicStaticFinalDoubleArray[0], e.eval("SharedObject.publicStaticFinalDoubleArray[0];"));
- assertArrayEquals(SharedObject.publicStaticFinalDoubleArray, (double[])e.get("psf_double_array"), 1e-10);
- e.eval("var tsf_double_arr = new (Java.type(\"double[]\"))(3);" +
- "tsf_double_arr[0] = 9e10;" +
- "tsf_double_arr[1] = 0.677777;" +
- "tsf_double_arr[2] = -0.0000001;" +
- "SharedObject.publicStaticFinalDoubleArray = tsf_double_arr;");
- assertArrayEquals(new double[] { 8.725e80, 0.82e10, 18e-3, 1.08077 }, SharedObject.publicStaticFinalDoubleArray, 1e-10f);
- e.eval("SharedObject.publicStaticFinalDoubleArray[0] = -5.2e10;");
- assertEquals(-5.2e10, SharedObject.publicStaticFinalDoubleArray[0], 1e-10f);
- }
-
-}
--- a/nashorn/test/src/jdk/nashorn/api/javaaccess/NumberBoxingTest.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,365 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.javaaccess;
-
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
-import javax.script.ScriptException;
-import org.testng.TestNG;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- * @test
- * @build jdk.nashorn.api.javaaccess.SharedObject jdk.nashorn.api.javaaccess.Person jdk.nashorn.api.javaaccess.NumberBoxingTest
- * @run testng/othervm jdk.nashorn.api.javaaccess.NumberBoxingTest
- */
-@SuppressWarnings("javadoc")
-public class NumberBoxingTest {
-
- private static ScriptEngine e;
- private static SharedObject o;
-
- public static void main(final String[] args) {
- TestNG.main(args);
- }
-
- @BeforeClass
- public static void setUpClass() throws ScriptException {
- final ScriptEngineManager m = new ScriptEngineManager();
- e = m.getEngineByName("nashorn");
- o = new SharedObject();
- e.put("o", o);
- e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.SharedObject;");
- }
-
- @AfterClass
- public static void tearDownClass() {
- e = null;
- o = null;
- }
-
- // --------------------------------long
- // tests------------------------------------
- @Test
- public void accessFieldLongBoxing() throws ScriptException {
- e.eval("var p_long = o.publicLongBox;");
- assertEquals(o.publicLongBox, e.get("p_long"));
- e.eval("o.publicLongBox = 12;");
- assertEquals(Long.valueOf(12), o.publicLongBox);
- }
-
- @Test
- public void accessStaticFieldLongBoxing() throws ScriptException {
- e.eval("var ps_long = SharedObject.publicStaticLongBox;");
- assertEquals(SharedObject.publicStaticLongBox, e.get("ps_long"));
- e.eval("SharedObject.publicStaticLongBox = 120;");
- assertEquals(120L, SharedObject.publicStaticLongBox.longValue());
- }
-
- @Test
- public void accessFinalFieldLongBoxing() throws ScriptException {
- e.eval("var pf_long = o.publicFinalLongBox;");
- assertEquals(o.publicFinalLongBox, e.get("pf_long"));
- e.eval("o.publicFinalLongBox = 120;");
- assertEquals(Long.valueOf(9377333334L), o.publicFinalLongBox);
- }
-
- @Test
- public void accessStaticFinalFieldLongBoxing() throws ScriptException {
- e.eval("var psf_long = SharedObject.publicStaticFinalLong;");
- assertEquals(SharedObject.publicStaticFinalLong, e.get("psf_long"));
- e.eval("SharedObject.publicStaticFinalLong = 120;");
- assertEquals(8333333333333L, SharedObject.publicStaticFinalLong);
- }
-
- // --------------------------------int
- // tests------------------------------------
- @Test
- public void accessFieldIntBoxing() throws ScriptException {
- e.eval("var p_int = o.publicIntBox;");
- assertEquals(o.publicIntBox, e.get("p_int"));
- e.eval("o.publicIntBox = 14;");
- assertEquals(Integer.valueOf(14), o.publicIntBox);
- }
-
- @Test
- public void accessStaticFieldIntBoxing() throws ScriptException {
- e.eval("var ps_int = SharedObject.publicStaticInt;");
- assertEquals(SharedObject.publicStaticInt, e.get("ps_int"));
- e.eval("SharedObject.publicStaticInt = 140;");
- assertEquals(140, SharedObject.publicStaticInt);
- }
-
- @Test
- public void accessFinalFieldIntBoxing() throws ScriptException {
- e.eval("var pf_int = o.publicFinalIntBox;");
- assertEquals(o.publicFinalIntBox, e.get("pf_int"));
- e.eval("o.publicFinalIntBox = 10;");
- assertEquals(Integer.valueOf(207512301), o.publicFinalIntBox);
- }
-
- @Test
- public void accessStaticFinalFieldIntBoxing() throws ScriptException {
- e.eval("var psf_int = SharedObject.publicStaticFinalInt;");
- assertEquals(SharedObject.publicStaticFinalInt, e.get("psf_int"));
- e.eval("SharedObject.publicStaticFinalInt = 140;");
- assertEquals(207182023, SharedObject.publicStaticFinalInt);
- }
-
- // --------------------------------byte
- // tests------------------------------------
- @Test
- public void accessFieldByteBoxing() throws ScriptException {
- e.eval("var p_byte = o.publicByteBox;");
- assertEqualsDouble(o.publicByteBox, "p_byte");
- e.eval("o.publicByteBox = 16;");
- assertEquals(Byte.valueOf((byte)16), o.publicByteBox);
- }
-
- @Test
- public void accessStaticFieldByteBoxing() throws ScriptException {
- e.eval("var ps_byte = SharedObject.publicStaticByte;");
- assertEqualsDouble(SharedObject.publicStaticByte, "ps_byte");
- e.eval("SharedObject.publicStaticByte = 16;");
- assertEquals(16, SharedObject.publicStaticByte);
- }
-
- @Test
- public void accessFinalFieldByteBoxing() throws ScriptException {
- e.eval("var pf_byte = o.publicFinalByteBox;");
- assertEqualsDouble(o.publicFinalByteBox, "pf_byte");
- e.eval("o.publicFinalByteBox = 16;");
- assertEquals(Byte.valueOf((byte)19), o.publicFinalByteBox);
- }
-
- @Test
- public void accessStaticFinalFieldByteBoxing() throws ScriptException {
- e.eval("var psf_byte = SharedObject.publicStaticFinalByte;");
- assertEqualsDouble(SharedObject.publicStaticFinalByte, "psf_byte");
- e.eval("SharedObject.publicStaticFinalByte = 16;");
- assertEquals(-70, SharedObject.publicStaticFinalByte);
- }
-
- // --------------------------------short
- // tests------------------------------------
- @Test
- public void accessFieldShortBoxing() throws ScriptException {
- e.eval("var p_short = o.publicShortBox;");
- assertEqualsDouble(o.publicShortBox, "p_short");
- e.eval("o.publicShortBox = 18;");
- assertEquals(Short.valueOf((short)18), o.publicShortBox);
- }
-
- private static void assertEqualsDouble(final Number n, final String name) {
- assertEquals(n.doubleValue(), ((Number)e.get(name)).doubleValue());
- }
-
- @Test
- public void accessStaticFieldShortBoxing() throws ScriptException {
- e.eval("var ps_short = SharedObject.publicStaticShort;");
- assertEqualsDouble(SharedObject.publicStaticShort, "ps_short");
- e.eval("SharedObject.publicStaticShort = 180;");
- assertEquals(180, SharedObject.publicStaticShort);
- }
-
- @Test
- public void accessFinalFieldShortBoxing() throws ScriptException {
- e.eval("var pf_short = o.publicFinalShortBox;");
- assertEqualsDouble(o.publicFinalShortBox, "pf_short");
- e.eval("o.publicFinalShortBox = 180;");
- assertEquals(Short.valueOf((short)-26777), o.publicFinalShortBox);
- }
-
- @Test
- public void accessStaticFinalFieldShortBoxing() throws ScriptException {
- e.eval("var psf_short = SharedObject.publicStaticFinalShort;");
- assertEqualsDouble(SharedObject.publicStaticFinalShort, "psf_short");
- e.eval("SharedObject.publicStaticFinalShort = 180;");
- assertEquals(8888, SharedObject.publicStaticFinalShort);
- }
-
- // --------------------------------char
- // tests------------------------------------
- @Test
- public void accessFieldCharBoxing() throws ScriptException {
- e.eval("var p_char = o.publicCharBox;");
- assertEquals(o.publicCharBox, e.get("p_char"));
- e.eval("o.publicCharBox = 'S';");
- assertEquals(Character.valueOf('S'), o.publicCharBox);
- e.eval("try {" +
- " o.publicCharBox = 'Big string';" +
- "} catch(e) {" +
- " var isThrown = true;" +
- "}");
- assertEquals("Exception thrown", true, e.get("isThrown"));
- assertEquals(Character.valueOf('S'), o.publicCharBox);
- }
-
- @Test
- public void accessStaticFieldCharBoxing() throws ScriptException {
- e.eval("var ps_char = SharedObject.publicStaticChar;");
- assertEquals(SharedObject.publicStaticChar, e.get("ps_char"));
- e.eval("SharedObject.publicStaticChar = 'Z';");
- assertEquals('Z', SharedObject.publicStaticChar);
- }
-
- @Test
- public void accessFinalFieldCharBoxing() throws ScriptException {
- e.eval("var pf_char = o.publicFinalCharBox;");
- assertEquals(o.publicFinalCharBox, e.get("pf_char"));
- e.eval("o.publicFinalCharBox = 'S';");
- assertEquals(Character.valueOf('F'), o.publicFinalCharBox);
- }
-
- @Test
- public void accessStaticFinalFieldCharBoxing() throws ScriptException {
- e.eval("var psf_char = SharedObject.publicStaticFinalChar;");
- assertEquals(SharedObject.publicStaticFinalChar, e.get("psf_char"));
- e.eval("SharedObject.publicStaticFinalChar = 'Z';");
- assertEquals('K', SharedObject.publicStaticFinalChar);
- }
-
- // --------------------------------float
- // tests------------------------------------
- @Test
- public void accessFieldFloatBoxing() throws ScriptException {
- e.eval("var p_float = o.publicFloatBox;");
- assertEqualsDouble(o.publicFloatBox, "p_float");
- o.publicFloatBox = 0.0f / 0.0f;
- assertEquals(true, e.eval("isNaN(o.publicFloatBox)"));
- o.publicFloatBox = 1.0f / 0.0f;
- assertEquals(true, e.eval("Number.POSITIVE_INFINITY === o.publicFloatBox"));
- o.publicFloatBox = -1.0f / 0.0f;
- assertEquals(true, e.eval("Number.NEGATIVE_INFINITY === o.publicFloatBox"));
- e.eval("o.publicFloatBox = 20;");
- assertEquals(20, o.publicFloatBox, 1e-10);
- e.eval("o.publicFloatBox = 0.0/0.0;");
- assertTrue(Float.isNaN(o.publicFloatBox));
- e.eval("o.publicFloatBox = 1.0/0.0;");
- assertEquals(Float.floatToIntBits(Float.POSITIVE_INFINITY), Float.floatToIntBits(o.publicFloatBox));
- e.eval("o.publicFloatBox = -1.0/0.0;");
- assertEquals(Float.NEGATIVE_INFINITY, o.publicFloatBox, 1e-10);
- }
-
- @Test
- public void accessStaticFieldFloatBoxing() throws ScriptException {
- e.eval("var ps_float = SharedObject.publicStaticFloat;");
- assertEqualsDouble(SharedObject.publicStaticFloat, "ps_float");
- SharedObject.publicStaticFloat = 0.0f / 0.0f;
- assertEquals(true, e.eval("isNaN(SharedObject.publicStaticFloat)"));
- SharedObject.publicStaticFloat = 1.0f / 0.0f;
- assertEquals(true, e.eval("Number.POSITIVE_INFINITY === SharedObject.publicStaticFloat"));
- SharedObject.publicStaticFloat = -1.0f / 0.0f;
- assertEquals(true, e.eval("Number.NEGATIVE_INFINITY === SharedObject.publicStaticFloat"));
- e.eval("SharedObject.publicStaticFloat = 20.0;");
- assertEquals(20.0f, SharedObject.publicStaticFloat, 1e-10);
- e.eval("SharedObject.publicStaticFloat = 0.0/0.0;");
- assertTrue(Float.isNaN(SharedObject.publicStaticFloat));
- e.eval("SharedObject.publicStaticFloat = 1.0/0.0;");
- assertEquals(Float.floatToIntBits(Float.POSITIVE_INFINITY), Float.floatToIntBits(SharedObject.publicStaticFloat));
- e.eval("SharedObject.publicStaticFloat = -1.0/0.0;");
- assertEquals(Float.floatToIntBits(Float.NEGATIVE_INFINITY), Float.floatToIntBits(SharedObject.publicStaticFloat));
- }
-
- @Test
- public void accessFinalFloatBoxing() throws ScriptException {
- e.eval("var pf_float = o.publicFinalFloatBox;");
- assertEqualsDouble(o.publicFinalFloatBox, "pf_float");
- e.eval("o.publicFinalFloatBox = 20.0;");
- assertEquals(1.372e4f, o.publicFinalFloatBox, 1e-10);
- }
-
- @Test
- public void accessStaticFinalFieldFloatBoxing() throws ScriptException {
- e.eval("var psf_float = SharedObject.publicStaticFinalFloat;");
- assertEqualsDouble(SharedObject.publicStaticFinalFloat, "psf_float");
- e.eval("SharedObject.publicStaticFinalFloat = 20.0;");
- assertEquals(0.72e8f, SharedObject.publicStaticFinalFloat, 1e-10);
- }
-
- // --------------------------------double
- // tests------------------------------------
- @Test
- public void accessFieldDoubleBoxing() throws ScriptException {
- e.eval("var p_double = o.publicDoubleBox;");
- assertEquals(o.publicDoubleBox, e.get("p_double"));
- o.publicDoubleBox = 0.0 / 0.0;
- assertEquals(true, e.eval("isNaN(o.publicDoubleBox)"));
- o.publicDoubleBox = 1.0 / 0.0;
- assertEquals(true, e.eval("Number.POSITIVE_INFINITY === o.publicDoubleBox"));
- o.publicDoubleBox = -1.0 / 0.0;
- assertEquals(true, e.eval("Number.NEGATIVE_INFINITY === o.publicDoubleBox"));
- e.eval("o.publicDoubleBox = 30;");
- assertEquals(Double.doubleToLongBits(30.0), Double.doubleToLongBits(o.publicDoubleBox));
- e.eval("o.publicDoubleBox = 0.0/0.0;");
- assertTrue(Double.isNaN(o.publicDoubleBox));
- e.eval("o.publicDoubleBox = 1.0/0.0;");
- assertEquals(Double.doubleToLongBits(Double.POSITIVE_INFINITY), Double.doubleToLongBits(o.publicDoubleBox));
- e.eval("o.publicDoubleBox = -1.0/0.0;");
- assertEquals(Double.doubleToLongBits(Double.NEGATIVE_INFINITY), Double.doubleToLongBits(o.publicDoubleBox));
- }
-
- @Test
- public void accessStaticFieldDoubleBoxing() throws ScriptException {
- e.eval("var ps_double = SharedObject.publicStaticDouble;");
- assertEquals(SharedObject.publicStaticDouble, e.get("ps_double"));
- SharedObject.publicStaticDouble = 0.0 / 0.0;
- assertEquals(true, e.eval("isNaN(SharedObject.publicStaticDouble)"));
- SharedObject.publicStaticDouble = 1.0 / 0.0;
- assertEquals(true, e.eval("Number.POSITIVE_INFINITY === SharedObject.publicStaticDouble"));
- SharedObject.publicStaticDouble = -1.0 / 0.0;
- assertEquals(true, e.eval("Number.NEGATIVE_INFINITY === SharedObject.publicStaticDouble"));
- e.eval("SharedObject.publicStaticDouble = 40.0;");
- assertEquals(Double.doubleToLongBits(40.0), Double.doubleToLongBits(SharedObject.publicStaticDouble));
- e.eval("SharedObject.publicStaticDouble = 0.0/0.0;");
- assertTrue(Double.isNaN(SharedObject.publicStaticDouble));
- e.eval("SharedObject.publicStaticDouble = 1.0/0.0;");
- assertEquals(Double.doubleToLongBits(Double.POSITIVE_INFINITY), Double.doubleToLongBits(SharedObject.publicStaticDouble));
- e.eval("SharedObject.publicStaticDouble = -1.0/0.0;");
- assertEquals(Double.doubleToLongBits(Double.NEGATIVE_INFINITY), Double.doubleToLongBits(SharedObject.publicStaticDouble));
- }
-
- @Test
- public void accessFinalFieldDoubleBoxing() throws ScriptException {
- e.eval("var pf_double = o.publicFinalDoubleBox;");
- assertEquals(o.publicFinalDoubleBox, e.get("pf_double"));
- e.eval("o.publicFinalDoubleBox = 30.0;");
- assertEquals(Double.doubleToLongBits(1.412e-12), Double.doubleToLongBits(o.publicFinalDoubleBox));
- }
-
- @Test
- public void accessStaticFinalFieldDoubleBoxing() throws ScriptException {
- e.eval("var psf_double = SharedObject.publicStaticFinalDouble;");
- assertEquals(SharedObject.publicStaticFinalDouble, e.get("psf_double"));
- e.eval("SharedObject.publicStaticFinalDouble = 40.0;");
- assertEquals(Double.doubleToLongBits(1.8e12), Double.doubleToLongBits(SharedObject.publicStaticFinalDouble));
- }
-
-}
--- a/nashorn/test/src/jdk/nashorn/api/javaaccess/ObjectAccessTest.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,165 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.javaaccess;
-
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
-import javax.script.ScriptException;
-import org.testng.TestNG;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- * @test
- * @build jdk.nashorn.api.javaaccess.SharedObject jdk.nashorn.api.javaaccess.Person jdk.nashorn.api.javaaccess.ObjectAccessTest
- * @run testng/othervm jdk.nashorn.api.javaaccess.ObjectAccessTest
- */
-@SuppressWarnings("javadoc")
-public class ObjectAccessTest {
-
- private static ScriptEngine e = null;
- private static SharedObject o = null;
-
- public static void main(final String[] args) {
- TestNG.main(args);
- }
-
- @BeforeClass
- public static void setUpClass() throws ScriptException {
- final ScriptEngineManager m = new ScriptEngineManager();
- e = m.getEngineByName("nashorn");
- o = new SharedObject();
- e.put("o", o);
- e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.SharedObject;");
- e.eval("var Person = Packages.jdk.nashorn.api.javaaccess.Person;");
- }
-
- @AfterClass
- public static void tearDownClass() {
- e = null;
- o = null;
- }
-
- @Test
- public void accessFieldObject() throws ScriptException {
- e.eval("var p_object = o.publicObject;");
- assertEquals(o.publicObject, e.get("p_object"));
- assertEquals("object", e.eval("typeof p_object;"));
- e.eval("o.publicObject = new Person(14);");
- assertEquals(new Person(14), o.publicObject);
- }
-
- @Test
- public void accessFieldObjectArray() throws ScriptException {
- e.eval("var p_object_array = o.publicObjectArray;");
- assertEquals(o.publicObjectArray[0], e.eval("o.publicObjectArray[0]"));
- assertArrayEquals(o.publicObjectArray, (Object[])e.get("p_object_array"));
- e.eval("var t_object_arr = new (Java.type(\"jdk.nashorn.api.javaaccess.Person[]\"))(3);" +
- "t_object_arr[0] = new Person(100);" +
- "t_object_arr[1] = new Person(120);" +
- "t_object_arr[2] = new Person(140);" +
- "o.publicObjectArray = t_object_arr;");
- assertArrayEquals(new Person[] { new Person(100), new Person(120), new Person(140) }, o.publicObjectArray);
- e.eval("o.publicObjectArray[0] = new Person(10);");
- assertEquals(new Person(10), o.publicObjectArray[0]);
- }
-
- @Test
- public void accessStaticFieldObject() throws ScriptException {
- e.eval("var ps_object = SharedObject.publicStaticObject;");
- assertEquals(SharedObject.publicStaticObject, e.get("ps_object"));
- assertEquals("object", e.eval("typeof ps_object;"));
- e.eval("SharedObject.publicStaticObject = new Person(16);");
- assertEquals(new Person(16), SharedObject.publicStaticObject);
- }
-
- @Test
- public void accessStaticFieldObjectArray() throws ScriptException {
- e.eval("var ps_object_array = SharedObject.publicStaticObjectArray;");
- assertEquals(SharedObject.publicStaticObjectArray[0], e.eval("SharedObject.publicStaticObjectArray[0]"));
- assertArrayEquals(SharedObject.publicStaticObjectArray, (Object[])e.get("ps_object_array"));
- e.eval("var ts_object_arr = new (Java.type(\"jdk.nashorn.api.javaaccess.Person[]\"))(3);" +
- "ts_object_arr[0] = new Person(100);" +
- "ts_object_arr[1] = new Person(120);" +
- "ts_object_arr[2] = new Person(140);" +
- "SharedObject.publicStaticObjectArray = ts_object_arr;");
- assertArrayEquals(new Person[] { new Person(100), new Person(120), new Person(140) }, SharedObject.publicStaticObjectArray);
- e.eval("SharedObject.publicStaticObjectArray[0] = new Person(10);");
- assertEquals(new Person(10), SharedObject.publicStaticObjectArray[0]);
- }
-
- @Test
- public void accessFinalFieldObject() throws ScriptException {
- e.eval("var pf_object = o.publicFinalObject;");
- assertEquals(o.publicFinalObject, e.get("pf_object"));
- assertEquals("object", e.eval("typeof pf_object;"));
- e.eval("o.publicFinalObject = new Person(-999);");
- assertEquals(new Person(1024), o.publicFinalObject);
- }
-
- @Test
- public void accessFinalFieldObjectArray() throws ScriptException {
- e.eval("var pf_object_array = o.publicFinalObjectArray;");
- assertEquals(o.publicFinalObjectArray[0], e.eval("o.publicFinalObjectArray[0]"));
- assertArrayEquals(o.publicFinalObjectArray, (Object[])e.get("pf_object_array"));
- e.eval("var tf_object_arr = new (Java.type(\"jdk.nashorn.api.javaaccess.Person[]\"))(3);" +
- "tf_object_arr[0] = new Person(100);" +
- "tf_object_arr[1] = new Person(120);" +
- "tf_object_arr[2] = new Person(140);" +
- "o.publicOFinalbjectArray = tf_object_arr;");
- assertArrayEquals(new Person[] { new Person(-900), new Person(1000), new Person(180) }, o.publicFinalObjectArray);
- e.eval("o.publicFinalObjectArray[0] = new Person(10);");
- assertEquals(new Person(10), o.publicFinalObjectArray[0]);
- }
-
- @Test
- public void accessStaticFinalFieldObject() throws ScriptException {
- e.eval("var psf_object = SharedObject.publicStaticFinalObject;");
- assertEquals(SharedObject.publicStaticFinalObject, e.get("psf_object"));
- assertEquals("object", e.eval("typeof psf_object;"));
- e.eval("SharedObject.publicStaticFinalObject = new Person(6);");
- assertEquals(new Person(2048), SharedObject.publicStaticFinalObject);
- }
-
- @Test
- public void accessStaticFinalFieldObjectArray() throws ScriptException {
- e.eval("var psf_object_array = SharedObject.publicStaticFinalObjectArray;");
- assertEquals(SharedObject.publicStaticFinalObjectArray[0], e.eval("SharedObject.publicStaticFinalObjectArray[0]"));
- assertArrayEquals(SharedObject.publicStaticFinalObjectArray, (Object[])e.get("psf_object_array"));
- e.eval("var tsf_object_arr = new (Java.type(\"jdk.nashorn.api.javaaccess.Person[]\"))(3);" +
- "tsf_object_arr[0] = new Person(100);" +
- "tsf_object_arr[1] = new Person(120);" +
- "tsf_object_arr[2] = new Person(140);" +
- "SharedObject.publicStaticFinalObjectArray = tsf_object_arr;");
- assertArrayEquals(new Person[] { new Person(-9), new Person(110), new Person(Integer.MAX_VALUE) }, SharedObject.publicStaticFinalObjectArray);
- e.eval("SharedObject.publicStaticFinalObjectArray[0] = new Person(90);");
- assertEquals(new Person(90), SharedObject.publicStaticFinalObjectArray[0]);
- }
-
-}
--- a/nashorn/test/src/jdk/nashorn/api/javaaccess/Person.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.javaaccess;
-
-@SuppressWarnings("javadoc")
-public class Person {
-
- public int id = 0;
-
- public Person() {
- }
-
- public Person(final int code) {
- this.id = code;
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (obj != null && obj instanceof Person) {
- final Person o = (Person)obj;
- return this.id == o.id;
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return id;
- }
-
- @Override
- public String toString() {
- return "Person(" + id + ")";
- }
-
-}
--- a/nashorn/test/src/jdk/nashorn/api/javaaccess/SharedObject.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,467 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.javaaccess;
-
-import javax.script.Invocable;
-import javax.script.ScriptEngine;
-import javax.script.ScriptException;
-
-@SuppressWarnings("javadoc")
-public class SharedObject {
-
- // Public fields
- public String publicString = "PublicString";
- public String[] publicStringArray = { "ArrayString[0]", "ArrayString[1]", "ArrayString[2]", "ArrayString[3]" };
- public Person publicObject = new Person(256);
- public Person[] publicObjectArray = { new Person(4), new Person(-422), new Person(14) };
- public boolean publicBoolean = true;
- public boolean[] publicBooleanArray = { true, false, false, true };
- public Boolean publicBooleanBox = true;
- public long publicLong = 933333333333333333L;
- public long[] publicLongArray = { 99012333333333L, -124355555L, 89777777777L };
- public Long publicLongBox = 9333333333L;
- public int publicInt = 2076543123;
- public int[] publicIntArray = { 0, 1, 1, 2, 3, 5, 8, 13, 21, 34 };
- public Integer publicIntBox = 20765123;
- public byte publicByte = -128;
- public byte[] publicByteArray = { 1, 2, 4, 8, 16, 32, 64, 127, -128 };
- public Byte publicByteBox = 127;
- public short publicShort = 32000;
- public short[] publicShortArray = { 3240, 8900, -16789, 1, 12 };
- public Short publicShortBox = Short.MIN_VALUE;
- public float publicFloat = 0.7f;
- public float[] publicFloatArray = { -32.01f, 89.3f, -1.3e8f, 3.1f };
- public Float publicFloatBox = 1.377e4f;
- public double publicDouble = 1.34e20;
- public double[] publicDoubleArray = { 0.75e80, 8e-43, 1.000077, 0.123e10 };
- public Double publicDoubleBox = 1.4e-19;
- public char publicChar = 'A';
- public char[] publicCharArray = "Hello Nashorn".toCharArray();
- public Character publicCharBox = 'B';
- // Public static fields
- public static String publicStaticString = "PublicStaticString";
- public static String[] publicStaticStringArray = { "StaticArrayString[0]", "StaticArrayString[1]", "StaticArrayString[2]", "StaticArrayString[3]" };
- public static Person publicStaticObject = new Person(512);
- public static Person[] publicStaticObjectArray = { new Person(40), new Person(-22), new Person(18) };
- public static boolean publicStaticBoolean = true;
- public static boolean[] publicStaticBooleanArray = { false, false, false, true };
- public static Boolean publicStaticBooleanBox = true;
- public static long publicStaticLong = 13333333333333333L;
- public static long[] publicStaticLongArray = { 19012333333333L, -224355555L, 39777777777L };
- public static Long publicStaticLongBox = 9333333334L;
- public static int publicStaticInt = 207654323;
- public static int[] publicStaticIntArray = { 5, 8, 13, 21, 34 };
- public static Integer publicStaticIntBox = 2075123;
- public static byte publicStaticByte = -12;
- public static byte[] publicStaticByteArray = { 16, 32, 64, 127, -128 };
- public static Byte publicStaticByteBox = 17;
- public static short publicStaticShort = 320;
- public static short[] publicStaticShortArray = { 1240, 900, -1789, 100, 12 };
- public static Short publicStaticShortBox = -16777;
- public static float publicStaticFloat = 7.7e8f;
- public static float[] publicStaticFloatArray = { -131.01f, 189.3f, -31.3e8f, 3.7f };
- public static Float publicStaticFloatBox = 1.37e4f;
- public static double publicStaticDouble = 1.341e20;
- public static double[] publicStaticDoubleArray = { 0.75e80, 0.123e10, 8e-43, 1.000077 };
- public static Double publicStaticDoubleBox = 1.41e-12;
- public static char publicStaticChar = 'C';
- public static char[] publicStaticCharArray = "Nashorn".toCharArray();
- public static Character publicStaticCharBox = 'D';
- // Public final fields
- public final String publicFinalString = "PublicFinalString";
- public final String[] publicFinalStringArray = { "FinalArrayString[0]", "FinalArrayString[1]", "FinalArrayString[2]", "FinalArrayString[3]" };
- public final Person publicFinalObject = new Person(1024);
- public final Person[] publicFinalObjectArray = { new Person(-900), new Person(1000), new Person(180) };
- public final boolean publicFinalBoolean = true;
- public final boolean[] publicFinalBooleanArray = { false, false, true, false };
- public final Boolean publicFinalBooleanBox = true;
- public final long publicFinalLong = 13353333333333333L;
- public final long[] publicFinalLongArray = { 1901733333333L, -2247355555L, 3977377777L };
- public final Long publicFinalLongBox = 9377333334L;
- public final int publicFinalInt = 20712023;
- public final int[] publicFinalIntArray = { 50, 80, 130, 210, 340 };
- public final Integer publicFinalIntBox = 207512301;
- public final byte publicFinalByte = -7;
- public final byte[] publicFinalByteArray = { 1, 3, 6, 17, -128 };
- public final Byte publicFinalByteBox = 19;
- public final short publicFinalShort = 31220;
- public final short[] publicFinalShortArray = { 12240, 9200, -17289, 1200, 12 };
- public final Short publicFinalShortBox = -26777;
- public final float publicFinalFloat = 7.72e8f;
- public final float[] publicFinalFloatArray = { -131.012f, 189.32f, -31.32e8f, 3.72f };
- public final Float publicFinalFloatBox = 1.372e4f;
- public final double publicFinalDouble = 1.3412e20;
- public final double[] publicFinalDoubleArray = { 0.725e80, 0.12e10, 8e-3, 1.00077 };
- public final Double publicFinalDoubleBox = 1.412e-12;
- public final char publicFinalChar = 'E';
- public final char[] publicFinalCharArray = "Nashorn hello".toCharArray();
- public final Character publicFinalCharBox = 'F';
- // Public static final fields
- public static final String publicStaticFinalString = "PublicStaticFinalString";
- public static final String[] publicStaticFinalStringArray = { "StaticFinalArrayString[0]", "StaticFinalArrayString[1]", "StaticFinalArrayString[2]", "StaticFinalArrayString[3]" };
- public static final Person publicStaticFinalObject = new Person(2048);
- public static final Person[] publicStaticFinalObjectArray = { new Person(-9), new Person(110), new Person(Integer.MAX_VALUE) };
- public static final boolean publicStaticFinalBoolean = true;
- public static final boolean[] publicStaticFinalBooleanArray = { false, true, false, false };
- public static final Boolean publicStaticFinalBooleanBox = true;
- public static final long publicStaticFinalLong = 8333333333333L;
- public static final long[] publicStaticFinalLongArray = { 19017383333L, -2247358L, 39773787L };
- public static final Long publicStaticFinalLongBox = 9377388334L;
- public static final int publicStaticFinalInt = 207182023;
- public static final int[] publicStaticFinalIntArray = { 1308, 210, 340 };
- public static final Integer publicStaticFinalIntBox = 2078301;
- public static final byte publicStaticFinalByte = -70;
- public static final byte[] publicStaticFinalByteArray = { 17, -128, 81 };
- public static final Byte publicStaticFinalByteBox = 91;
- public static final short publicStaticFinalShort = 8888;
- public static final short[] publicStaticFinalShortArray = { 8240, 9280, -1289, 120, 812 };
- public static final Short publicStaticFinalShortBox = -26;
- public static final float publicStaticFinalFloat = 0.72e8f;
- public static final float[] publicStaticFinalFloatArray = { -8131.012f, 9.32f, -138.32e8f, 0.72f };
- public static final Float publicStaticFinalFloatBox = 1.2e4f;
- public static final double publicStaticFinalDouble = 1.8e12;
- public static final double[] publicStaticFinalDoubleArray = { 8.725e80, 0.82e10, 18e-3, 1.08077 };
- public static final Double publicStaticFinalDoubleBox = 1.5612e-13;
- public static final char publicStaticFinalChar = 'K';
- public static final char[] publicStaticFinalCharArray = "StaticString".toCharArray();
- public static final Character publicStaticFinalCharBox = 'L';
-
- // Special vars
- public volatile boolean volatileBoolean = true;
- public transient boolean transientBoolean = true;
-
- // For methods testing
- public boolean isAccessed = false;
- public volatile boolean isFinished = false;
-
- private ScriptEngine engine;
-
- public ScriptEngine getEngine() {
- return engine;
- }
-
- public void setEngine(final ScriptEngine engine) {
- this.engine = engine;
- }
-
- public void voidMethod() {
- isAccessed = true;
- }
-
- public boolean booleanMethod(final boolean arg) {
- return !arg;
- }
-
- public Boolean booleanBoxingMethod(final Boolean arg) {
- return !arg.booleanValue();
- }
-
- public boolean[] booleanArrayMethod(final boolean arg[]) {
- final boolean[] res = new boolean[arg.length];
- for (int i = 0; i < arg.length; i++) {
- res[i] = !arg[i];
- }
- return res;
- }
-
- public int intMethod(final int arg) {
- return arg + arg;
- }
-
- public Integer intBoxingMethod(final Integer arg) {
- return arg + arg;
- }
-
- public int[] intArrayMethod(final int arg[]) {
- final int[] res = new int[arg.length];
- for (int i = 0; i < arg.length; i++) {
- res[i] = arg[i] * 2;
- }
- return res;
- }
-
- public long longMethod(final long arg) {
- return arg + arg;
- }
-
- public Long longBoxingMethod(final Long arg) {
- return arg + arg;
- }
-
- public long[] longArrayMethod(final long[] arg) {
- final long[] res = new long[arg.length];
- for (int i = 0; i < arg.length; i++) {
- res[i] = arg[i] * 2;
- }
- return res;
- }
-
- public byte byteMethod(final byte arg) {
- return (byte)(arg + arg);
- }
-
- public Byte byteBoxingMethod(final Byte arg) {
- return (byte)(arg + arg);
- }
-
- public byte[] byteArrayMethod(final byte[] arg) {
- final byte[] res = new byte[arg.length];
- for (int i = 0; i < arg.length; i++) {
- res[i] = (byte)(arg[i] * 2);
- }
- return res;
- }
-
- public char charMethod(final char arg) {
- return Character.toUpperCase(arg);
- }
-
- public Character charBoxingMethod(final Character arg) {
- return Character.toUpperCase(arg);
- }
-
- public char[] charArrayMethod(final char[] arg) {
- final char[] res = new char[arg.length];
- for (int i = 0; i < arg.length; i++) {
- res[i] = Character.toUpperCase(arg[i]);
- }
- return res;
- }
-
- public short shortMethod(final short arg) {
- return (short)(arg + arg);
- }
-
- public Short shortBoxingMethod(final Short arg) {
- return (short)(arg + arg);
- }
-
- public short[] shortArrayMethod(final short[] arg) {
- final short[] res = new short[arg.length];
- for (int i = 0; i < arg.length; i++) {
- res[i] = (short)(arg[i] * 2);
- }
- return res;
- }
-
- public float floatMethod(final float arg) {
- return arg + arg;
- }
-
- public Float floatBoxingMethod(final Float arg) {
- return arg + arg;
- }
-
- public float[] floatArrayMethod(final float[] arg) {
- final float[] res = new float[arg.length];
- for (int i = 0; i < arg.length; i++) {
- res[i] = arg[i] * 2;
- }
- return res;
- }
-
- public double doubleMethod(final double arg) {
- return arg + arg;
- }
-
- public Double doubleBoxingMethod(final Double arg) {
- return arg + arg;
- }
-
- public double[] doubleArrayMethod(final double[] arg) {
- final double[] res = new double[arg.length];
- for (int i = 0; i < arg.length; i++) {
- res[i] = arg[i] * 2;
- }
- return res;
- }
-
- public String stringMethod(final String str) {
- return str + str;
- }
-
- public String[] stringArrayMethod(final String[] arr) {
- final int l = arr.length;
- final String[] res = new String[l];
- for (int i = 0; i < l; i++) {
- res[i] = arr[l - i - 1];
- }
- return res;
- }
-
- public Person[] objectArrayMethod(final Person[] arr) {
- final Person[] res = new Person[arr.length];
- for (int i = 0; i < arr.length; i++) {
- res[i] = new Person(i + 100);
- }
- return res;
- }
-
- public Person objectMethod(final Person t) {
- t.id *= 2;
- return t;
- }
-
- public int twoParamMethod(final long l, final double d) {
- return (int)(l + d);
- }
-
- public int threeParamMethod(final short s, final long l, final char c) {
- return (int)(s + l + c);
- }
-
- public Person[] twoObjectParamMethod(final Person arg1, final Person arg2) {
- return new Person[] { arg2, arg1 };
- }
-
- public Person[] threeObjectParamMethod(final Person arg1, final Person arg2, final Person arg3) {
- return new Person[] { arg3, arg2, arg1 };
- }
-
- public Person[] eightObjectParamMethod(final Person arg1, final Person arg2, final Person arg3, final Person arg4, final Person arg5, final Person arg6, final Person arg7, final Person arg8) {
- return new Person[] { arg8, arg7, arg6, arg5, arg4, arg3, arg2, arg1 };
- }
-
- public Person[] nineObjectParamMethod(final Person arg1, final Person arg2, final Person arg3, final Person arg4, final Person arg5, final Person arg6, final Person arg7, final Person arg8, final Person arg9) {
- return new Person[] { arg9, arg8, arg7, arg6, arg5, arg4, arg3, arg2, arg1 };
- }
-
- public Person[] methodObjectEllipsis(final Person... args) {
- final int l = args.length;
- final Person[] res = new Person[l];
- for (int i = 0; i < l; i++) {
- res[i] = args[l - i - 1];
- }
- return res;
- }
-
- public Person[] methodPrimitiveEllipsis(final int... args) {
- final int l = args.length;
- final Person[] res = new Person[l];
- for (int i = 0; i < l; i++) {
- res[i] = new Person(args[i]);
- }
- return res;
- }
-
- public Object[] methodMixedEllipsis(final Object... args) {
- return args;
- }
-
- public Object[] methodObjectWithEllipsis(final String arg, final int... args) {
- final Object[] res = new Object[args.length + 1];
- res[0] = arg;
- for (int i = 0; i < args.length; i++) {
- res[i + 1] = args[i];
- }
- return res;
- }
-
- public Object[] methodPrimitiveWithEllipsis(final int arg, final long... args) {
- final Object[] res = new Object[args.length + 1];
- res[0] = arg;
- for (int i = 0; i < args.length; i++) {
- res[i + 1] = args[i];
- }
- return res;
- }
-
- public Object[] methodMixedWithEllipsis(final String arg1, final int arg2, final Object... args) {
- final Object[] res = new Object[args.length + 2];
- res[0] = arg1;
- res[1] = arg2;
- System.arraycopy(args, 0, res, 2, args.length);
- return res;
- }
-
- public void methodStartsThread() {
- isFinished = false;
-
- final Thread t = new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- Thread.sleep(1000);
- isFinished = true;
- } catch (final InterruptedException e) {
- e.printStackTrace();
- }
- }
- });
-
- t.start();
- }
-
- public String overloadedMethodDoubleVSint(final int arg) {
- return "int";
- }
-
- public String overloadedMethodDoubleVSint(final double arg) {
- return "double";
- }
-
- public int overloadedMethod(final int arg) {
- return arg*2;
- }
-
- public int overloadedMethod(final String arg) {
- return arg.length();
- }
-
- public int overloadedMethod(final boolean arg) {
- return (arg) ? 1 : 0;
- }
-
- public int overloadedMethod(final Person arg) {
- return arg.id*2;
- }
-
- public int firstLevelMethodInt(final int arg) throws ScriptException, NoSuchMethodException {
- return (int) ((Invocable)engine).invokeFunction("secondLevelMethodInt", arg);
- }
-
- public int thirdLevelMethodInt(final int arg) {
- return arg*5;
- }
-
- public int firstLevelMethodInteger(final Integer arg) throws ScriptException, NoSuchMethodException {
- return (int) ((Invocable)engine).invokeFunction("secondLevelMethodInteger", arg);
- }
-
- public int thirdLevelMethodInteger(final Integer arg) {
- return arg*10;
- }
-
- public Person firstLevelMethodObject(final Person p) throws ScriptException, NoSuchMethodException {
- return (Person) ((Invocable)engine).invokeFunction("secondLevelMethodObject", p);
- }
-
- public Person thirdLevelMethodObject(final Person p) {
- p.id *= 10;
- return p;
- }
-
-}
--- a/nashorn/test/src/jdk/nashorn/api/javaaccess/StringAccessTest.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,168 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.javaaccess;
-
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
-import javax.script.ScriptException;
-import org.testng.TestNG;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- * @test
- * @build jdk.nashorn.api.javaaccess.SharedObject jdk.nashorn.api.javaaccess.Person jdk.nashorn.api.javaaccess.StringAccessTest
- * @run testng/othervm jdk.nashorn.api.javaaccess.StringAccessTest
- */
-@SuppressWarnings("javadoc")
-public class StringAccessTest {
-
- private static ScriptEngine e = null;
- private static SharedObject o = null;
-
- public static void main(final String[] args) {
- TestNG.main(args);
- }
-
- @BeforeClass
- public static void setUpClass() throws ScriptException {
- final ScriptEngineManager m = new ScriptEngineManager();
- e = m.getEngineByName("nashorn");
- o = new SharedObject();
- e.put("o", o);
- e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.SharedObject;");
- }
-
- @AfterClass
- public static void tearDownClass() {
- e = null;
- o = null;
- }
-
- @Test
- public void accessFieldString() throws ScriptException {
- e.eval("var p_string = o.publicString;");
- assertEquals(o.publicString, e.get("p_string"));
- assertEquals("string", e.eval("typeof p_string;"));
- e.eval("o.publicString = 'changedString';");
- assertEquals("changedString", o.publicString);
- }
-
- @Test
- public void accessFieldStringArray() throws ScriptException {
- e.eval("var p_string_array = o.publicStringArray;");
- assertEquals(o.publicStringArray[0], e.eval("o.publicStringArray[0]"));
- assertArrayEquals(o.publicStringArray, (String[])e.get("p_string_array"));
- e.eval("var t_string_arr = new (Java.type(\"java.lang.String[]\"))(3);" +
- "t_string_arr[0] = 'abc';" +
- "t_string_arr[1] = '123';" +
- "t_string_arr[2] = 'xyzzzz';" +
- "o.publicStringArray = t_string_arr;");
- assertArrayEquals(new String[] { "abc", "123", "xyzzzz" }, o.publicStringArray);
- e.eval("o.publicStringArray[0] = 'nashorn';");
- assertEquals("nashorn", o.publicStringArray[0]);
- }
-
- @Test
- public void accessStaticFieldString() throws ScriptException {
- e.eval("var ps_string = SharedObject.publicStaticString;");
- assertEquals(SharedObject.publicStaticString, e.get("ps_string"));
- assertEquals("string", e.eval("typeof ps_string;"));
- e.eval("SharedObject.publicStaticString = 'changedString';");
- assertEquals("changedString", SharedObject.publicStaticString);
- }
-
- @Test
- public void accessStaticFieldStringArray() throws ScriptException {
- e.eval("var ps_string_array = SharedObject.publicStaticStringArray;");
- assertEquals(SharedObject.publicStaticStringArray[0], e.eval("SharedObject.publicStaticStringArray[0]"));
- assertArrayEquals(SharedObject.publicStaticStringArray, (String[])e.get("ps_string_array"));
- e.eval("var ts_string_arr = new (Java.type(\"java.lang.String[]\"))(3);" +
- "ts_string_arr[0] = 'abc';" +
- "ts_string_arr[1] = '123';" +
- "ts_string_arr[2] = 'xyzzzz';" +
- "SharedObject.publicStaticStringArray = ts_string_arr;");
- assertArrayEquals(new String[] { "abc", "123", "xyzzzz" }, SharedObject.publicStaticStringArray);
- e.eval("SharedObject.publicStaticStringArray[0] = 'nashorn';");
- assertEquals("nashorn", SharedObject.publicStaticStringArray[0]);
- }
-
- @Test
- public void accessFinalFieldString() throws ScriptException {
- e.eval("var pf_string = o.publicFinalString;");
- assertEquals(o.publicFinalString, e.get("pf_string"));
- assertEquals("string", e.eval("typeof pf_string;"));
- e.eval("o.publicFinalString = 'changedString';");
- assertEquals("PublicFinalString", o.publicFinalString);
- }
-
- @Test
- public void accessFinalFieldStringArray() throws ScriptException {
- e.eval("var pf_string_array = o.publicFinalStringArray;");
- assertEquals(o.publicFinalStringArray[0], e.eval("o.publicFinalStringArray[0]"));
- assertArrayEquals(o.publicFinalStringArray, (String[])e.get("pf_string_array"));
- e.eval("var tf_string_arr = new (Java.type(\"java.lang.String[]\"))(3);" +
- "tf_string_arr[0] = 'abc';" +
- "tf_string_arr[1] = '123';" +
- "tf_string_arr[2] = 'xyzzzz';" +
- "o.publicFinalStringArray = tf_string_arr;");
- assertArrayEquals(new String[] { "FinalArrayString[0]", "FinalArrayString[1]", "FinalArrayString[2]", "FinalArrayString[3]" }, o.publicFinalStringArray);
- e.eval("o.publicFinalStringArray[0] = 'nashorn';");
- assertEquals("nashorn", o.publicFinalStringArray[0]);
- }
-
- @Test
- public void accessStaticFinalFieldString() throws ScriptException {
- e.eval("var psf_string = SharedObject.publicStaticFinalString;");
- assertEquals(SharedObject.publicStaticFinalString, e.get("psf_string"));
- assertEquals("string", e.eval("typeof psf_string;"));
- e.eval("SharedObject.publicStaticFinalString = 'changedString';");
- assertEquals("PublicStaticFinalString", SharedObject.publicStaticFinalString);
- }
-
- @Test
- public void accessStaticFinalFieldStringArray() throws ScriptException {
- e.eval("var psf_string_array = SharedObject.publicStaticFinalStringArray;");
- assertEquals(SharedObject.publicStaticFinalStringArray[0], e.eval("SharedObject.publicStaticFinalStringArray[0]"));
- assertArrayEquals(SharedObject.publicStaticFinalStringArray, (String[])e.get("psf_string_array"));
- e.eval("var tsf_string_arr = new (Java.type(\"java.lang.String[]\"))(3);" +
- "tsf_string_arr[0] = 'abc';" +
- "tsf_string_arr[1] = '123';" +
- "tsf_string_arr[2] = 'xyzzzz';" +
- "SharedObject.publicStaticFinalStringArray = tsf_string_arr;");
- assertArrayEquals(new String[] { "StaticFinalArrayString[0]",
- "StaticFinalArrayString[1]",
- "StaticFinalArrayString[2]",
- "StaticFinalArrayString[3]" },
- SharedObject.publicStaticFinalStringArray);
- e.eval("SharedObject.publicStaticFinalStringArray[0] = 'nashorn';");
- assertEquals("nashorn", SharedObject.publicStaticFinalStringArray[0]);
- }
-
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/api/javaaccess/test/ArrayConversionTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,235 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.javaaccess.test;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertNull;
+import static org.testng.AssertJUnit.assertTrue;
+import java.util.Arrays;
+import java.util.List;
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import org.testng.TestNG;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+@SuppressWarnings("javadoc")
+public class ArrayConversionTest {
+ private static ScriptEngine e = null;
+
+ public static void main(final String[] args) {
+ TestNG.main(args);
+ }
+
+ @BeforeClass
+ public static void setUpClass() {
+ e = new ScriptEngineManager().getEngineByName("nashorn");
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ e = null;
+ }
+
+ @Test
+ public void testIntArrays() throws ScriptException {
+ runTest("assertNullIntArray", "null");
+ runTest("assertEmptyIntArray", "[]");
+ runTest("assertSingle42IntArray", "[42]");
+ runTest("assertSingle42IntArray", "['42']");
+ runTest("assertIntArrayConversions", "[false, true, NaN, Infinity, -Infinity, 0.4, 0.6, null, undefined, [], {}, [1], [1, 2]]");
+ }
+
+ @Test
+ public void testIntIntArrays() throws ScriptException {
+ runTest("assertNullIntIntArray", "null");
+ runTest("assertEmptyIntIntArray", "[]");
+ runTest("assertSingleEmptyIntIntArray", "[[]]");
+ runTest("assertSingleNullIntIntArray", "[null]");
+ runTest("assertLargeIntIntArray", "[[false], [1], [2, 3], [4, 5, 6], ['7', {valueOf: function() { return 8 }}]]");
+ }
+
+ @Test
+ public void testObjectObjectArrays() throws ScriptException {
+ runTest("assertLargeObjectObjectArray", "[[false], [1], ['foo', 42.3], [{x: 17}]]");
+ }
+
+ @Test
+ public void testBooleanArrays() throws ScriptException {
+ runTest("assertBooleanArrayConversions", "[false, true, '', 'false', 0, 1, 0.4, 0.6, {}, [], [false], [true], NaN, Infinity, null, undefined]");
+ }
+
+ @Test
+ public void testArrayAmbiguity() throws ScriptException {
+ runTest("x", "'abc'");
+ runTest("x", "['foo', 'bar']");
+ }
+
+ @Test
+ public void testListArrays() throws ScriptException {
+ runTest("assertListArray", "[['foo', 'bar'], ['apple', 'orange']]");
+ }
+
+ @Test
+ public void testVarArgs() throws ScriptException {
+ // Sole NativeArray in vararg position becomes vararg array itself
+ runTest("assertVarArg_42_17", "[42, 17]");
+ // NativeArray in vararg position becomes an argument if there are more arguments
+ runTest("assertVarArg_array_17", "[42], 18");
+ // Only NativeArray is converted to vararg array, other objects (e.g. a function) aren't
+ runTest("assertVarArg_function", "function() { return 'Hello' }");
+ }
+
+ private static void runTest(final String testMethodName, final String argument) throws ScriptException {
+ e.eval("Java.type('" + ArrayConversionTest.class.getName() + "')." + testMethodName + "(" + argument + ")");
+ }
+
+ public static void assertNullIntArray(final int[] array) {
+ assertNull(array);
+ }
+
+ public static void assertNullIntIntArray(final int[][] array) {
+ assertNull(array);
+ }
+
+ public static void assertEmptyIntArray(final int[] array) {
+ assertEquals(0, array.length);
+ }
+
+ public static void assertSingle42IntArray(final int[] array) {
+ assertEquals(1, array.length);
+ assertEquals(42, array[0]);
+ }
+
+
+ public static void assertIntArrayConversions(final int[] array) {
+ assertEquals(13, array.length);
+ assertEquals(0, array[0]); // false
+ assertEquals(1, array[1]); // true
+ assertEquals(0, array[2]); // NaN
+ assertEquals(0, array[3]); // Infinity
+ assertEquals(0, array[4]); // -Infinity
+ assertEquals(0, array[5]); // 0.4
+ assertEquals(0, array[6]); // 0.6 - floor, not round
+ assertEquals(0, array[7]); // null
+ assertEquals(0, array[8]); // undefined
+ assertEquals(0, array[9]); // []
+ assertEquals(0, array[10]); // {}
+ assertEquals(1, array[11]); // [1]
+ assertEquals(0, array[12]); // [1, 2]
+ }
+
+ public static void assertEmptyIntIntArray(final int[][] array) {
+ assertEquals(0, array.length);
+ }
+
+ public static void assertSingleEmptyIntIntArray(final int[][] array) {
+ assertEquals(1, array.length);
+ assertTrue(Arrays.equals(new int[0], array[0]));
+ }
+
+ public static void assertSingleNullIntIntArray(final int[][] array) {
+ assertEquals(1, array.length);
+ assertNull(null, array[0]);
+ }
+
+ public static void assertLargeIntIntArray(final int[][] array) {
+ assertEquals(5, array.length);
+ assertTrue(Arrays.equals(new int[] { 0 }, array[0]));
+ assertTrue(Arrays.equals(new int[] { 1 }, array[1]));
+ assertTrue(Arrays.equals(new int[] { 2, 3 }, array[2]));
+ assertTrue(Arrays.equals(new int[] { 4, 5, 6 }, array[3]));
+ assertTrue(Arrays.equals(new int[] { 7, 8 }, array[4]));
+ }
+
+ public static void assertLargeObjectObjectArray(final Object[][] array) throws ScriptException {
+ assertEquals(4, array.length);
+ assertTrue(Arrays.equals(new Object[] { Boolean.FALSE }, array[0]));
+ assertTrue(Arrays.equals(new Object[] { 1 }, array[1]));
+ assertTrue(Arrays.equals(new Object[] { "foo", 42.3d }, array[2]));
+ assertEquals(1, array[3].length);
+ e.getBindings(ScriptContext.ENGINE_SCOPE).put("obj", array[3][0]);
+ assertEquals(17, e.eval("obj.x"));
+ }
+
+ public static void assertBooleanArrayConversions(final boolean[] array) {
+ assertEquals(16, array.length);
+ assertFalse(array[0]); // false
+ assertTrue(array[1]); // true
+ assertFalse(array[2]); // ''
+ assertTrue(array[3]); // 'false' (yep, every non-empty string converts to true)
+ assertFalse(array[4]); // 0
+ assertTrue(array[5]); // 1
+ assertTrue(array[6]); // 0.4
+ assertTrue(array[7]); // 0.6
+ assertTrue(array[8]); // {}
+ assertTrue(array[9]); // []
+ assertTrue(array[10]); // [false]
+ assertTrue(array[11]); // [true]
+ assertFalse(array[12]); // NaN
+ assertTrue(array[13]); // Infinity
+ assertFalse(array[14]); // null
+ assertFalse(array[15]); // undefined
+ }
+
+ public static void assertListArray(final List<?>[] array) {
+ assertEquals(2, array.length);
+ assertEquals(Arrays.asList("foo", "bar"), array[0]);
+ assertEquals(Arrays.asList("apple", "orange"), array[1]);
+ }
+
+ public static void assertVarArg_42_17(final Object... args) {
+ assertEquals(2, args.length);
+ assertEquals(42, ((Number)args[0]).intValue());
+ assertEquals(17, ((Number)args[1]).intValue());
+ }
+
+ public static void assertVarArg_array_17(final Object... args) throws ScriptException {
+ assertEquals(2, args.length);
+ e.getBindings(ScriptContext.ENGINE_SCOPE).put("arr", args[0]);
+ assertTrue((Boolean)e.eval("arr instanceof Array && arr.length == 1 && arr[0] == 42"));
+ assertEquals(18, ((Number)args[1]).intValue());
+ }
+
+ public static void assertVarArg_function(final Object... args) throws ScriptException {
+ assertEquals(1, args.length);
+ e.getBindings(ScriptContext.ENGINE_SCOPE).put("fn", args[0]);
+ assertEquals("Hello", e.eval("fn()"));
+ }
+
+
+
+ public static void x(final String y) {
+ assertEquals("abc", y);
+ }
+ public static void x(final String[] y) {
+ assertTrue(Arrays.equals(new String[] { "foo", "bar"}, y));
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/api/javaaccess/test/BooleanAccessTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,219 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.javaaccess.test;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
+import java.util.Arrays;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import org.testng.TestNG;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * @test
+ * @build jdk.nashorn.api.javaaccess.test.SharedObject jdk.nashorn.api.javaaccess.test.Person jdk.nashorn.api.javaaccess.test.BooleanAccessTest
+ * @run testng/othervm jdk.nashorn.api.javaaccess.test.BooleanAccessTest
+ */
+@SuppressWarnings("javadoc")
+public class BooleanAccessTest {
+
+ private static ScriptEngine e = null;
+ private static SharedObject o = null;
+
+ public static void main(final String[] args) {
+ TestNG.main(args);
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws ScriptException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ e = m.getEngineByName("nashorn");
+ o = new SharedObject();
+ e.put("o", o);
+ e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.test.SharedObject;");
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ e = null;
+ o = null;
+ }
+
+ @Test
+ public void accessFieldBoolean() throws ScriptException {
+ e.eval("var p_boolean = o.publicBoolean;");
+ assertEquals(o.publicBoolean, e.get("p_boolean"));
+ assertEquals("boolean", e.eval("typeof p_boolean;"));
+ e.eval("o.publicBoolean = false;");
+ assertEquals(false, o.publicBoolean);
+ }
+
+ @Test
+ public void accessFieldBooleanArray() throws ScriptException {
+ e.eval("var p_boolean_array = o.publicBooleanArray;");
+ assertEquals(o.publicBooleanArray[0], e.eval("o.publicBooleanArray[0]"));
+ assertTrue(Arrays.equals(o.publicBooleanArray, (boolean[])e.get("p_boolean_array")));
+ e.eval("var t_boolean_arr = new (Java.type(\"boolean[]\"))(3);" +
+ "t_boolean_arr[0] = true;" +
+ "t_boolean_arr[1] = false;" +
+ "t_boolean_arr[2] = false;" +
+ "o.publicBooleanArray = t_boolean_arr;");
+ assertTrue(Arrays.equals(new boolean[] { true, false, false }, o.publicBooleanArray));
+ e.eval("o.publicBooleanArray[0] = false;");
+ assertEquals(false, o.publicBooleanArray[0]);
+ }
+
+ @Test
+ public void accessStaticFieldBoolean() throws ScriptException {
+ e.eval("var ps_boolean = SharedObject.publicStaticBoolean;");
+ assertEquals(SharedObject.publicStaticBoolean, e.get("ps_boolean"));
+ assertEquals("boolean", e.eval("typeof ps_boolean;"));
+ e.eval("SharedObject.publicStaticBoolean = false;");
+ assertEquals(false, SharedObject.publicStaticBoolean);
+ }
+
+ @Test
+ public void accessStaticFieldBooleanArray() throws ScriptException {
+ e.eval("var ps_boolean_array = SharedObject.publicStaticBooleanArray;");
+ assertEquals(SharedObject.publicStaticBooleanArray[0], e.eval("SharedObject.publicStaticBooleanArray[0]"));
+ assertTrue(Arrays.equals(SharedObject.publicStaticBooleanArray, (boolean[])e.get("ps_boolean_array")));
+ e.eval("var ts_boolean_arr = new (Java.type(\"boolean[]\"))(3);" +
+ "ts_boolean_arr[0] = true;" +
+ "ts_boolean_arr[1] = false;" +
+ "ts_boolean_arr[2] = true;" +
+ "SharedObject.publicStaticBooleanArray = ts_boolean_arr;");
+ assertTrue(Arrays.equals(new boolean[] { true, false, true }, SharedObject.publicStaticBooleanArray));
+ e.eval("SharedObject.publicStaticBooleanArray[0] = false;");
+ assertEquals(false, SharedObject.publicStaticBooleanArray[0]);
+ }
+
+ @Test
+ public void accessFinalFieldBoolean() throws ScriptException {
+ e.eval("var pf_boolean = o.publicFinalBoolean;");
+ assertEquals(o.publicFinalBoolean, e.get("pf_boolean"));
+ assertEquals("boolean", e.eval("typeof pf_boolean;"));
+ e.eval("o.publicFinalBoolean = false;");
+ assertEquals(true, o.publicFinalBoolean);
+ }
+
+ @Test
+ public void accessFinalFieldBooleanArray() throws ScriptException {
+ e.eval("var pf_boolean_array = o.publicFinalBooleanArray;");
+ assertEquals(o.publicFinalBooleanArray[0], e.eval("o.publicFinalBooleanArray[0]"));
+ assertTrue(Arrays.equals(o.publicFinalBooleanArray, (boolean[])e.get("pf_boolean_array")));
+ e.eval("var tf_boolean_arr = new (Java.type(\"boolean[]\"))(3);" +
+ "tf_boolean_arr[0] = false;" +
+ "tf_boolean_arr[1] = false;" +
+ "tf_boolean_arr[2] = true;" +
+ "o.publicOFinalbjectArray = tf_boolean_arr;");
+ assertTrue(Arrays.equals(new boolean[] { false, false, true, false }, o.publicFinalBooleanArray));
+ e.eval("o.publicFinalBooleanArray[0] = true;");
+ assertEquals(true, o.publicFinalBooleanArray[0]);
+ }
+
+ @Test
+ public void accessStaticFinalFieldBoolean() throws ScriptException {
+ e.eval("var psf_boolean = SharedObject.publicStaticFinalBoolean;");
+ assertEquals(SharedObject.publicStaticFinalBoolean, e.get("psf_boolean"));
+ assertEquals("boolean", e.eval("typeof psf_boolean;"));
+ e.eval("SharedObject.publicStaticFinalBoolean = false;");
+ assertEquals(true, SharedObject.publicStaticFinalBoolean);
+ }
+
+ @Test
+ public void accessStaticFinalFieldBooleanArray() throws ScriptException {
+ e.eval("var psf_boolean_array = SharedObject.publicStaticFinalBooleanArray;");
+ assertEquals(SharedObject.publicStaticFinalBooleanArray[0], e.eval("SharedObject.publicStaticFinalBooleanArray[0]"));
+ assertTrue(Arrays.equals(SharedObject.publicStaticFinalBooleanArray, (boolean[])e.get("psf_boolean_array")));
+ e.eval("var tsf_boolean_arr = new (Java.type(\"boolean[]\"))(3);" +
+ "tsf_boolean_arr[0] = false;" +
+ "tsf_boolean_arr[1] = true;" +
+ "tsf_boolean_arr[2] = false;" +
+ "SharedObject.publicStaticFinalBooleanArray = tsf_boolean_arr;");
+ assertTrue(Arrays.equals(new boolean[] { false, true, false, false }, SharedObject.publicStaticFinalBooleanArray));
+ e.eval("SharedObject.publicStaticFinalBooleanArray[0] = true;");
+ assertEquals(true, SharedObject.publicStaticFinalBooleanArray[0]);
+ }
+
+ @Test
+ public void accessFieldBooleanBoxing() throws ScriptException {
+ e.eval("var p_boolean_box = o.publicBooleanBox;");
+ assertEquals(o.publicBooleanBox, e.get("p_boolean_box"));
+ assertEquals("boolean", e.eval("typeof p_boolean_box;"));
+ e.eval("o.publicBooleanBox = false;");
+ assertEquals(false, (boolean)o.publicBooleanBox);
+ }
+
+ @Test
+ public void accessStaticFieldBooleanBoxing() throws ScriptException {
+ e.eval("var ps_boolean_box = SharedObject.publicStaticBooleanBox;");
+ assertEquals(SharedObject.publicStaticBooleanBox, e.get("ps_boolean_box"));
+ assertEquals("boolean", e.eval("typeof ps_boolean_box;"));
+ e.eval("SharedObject.publicStaticBooleanBox = false;");
+ assertEquals(false, (boolean)SharedObject.publicStaticBooleanBox);
+ }
+
+ @Test
+ public void accessFinalFieldBooleanBoxing() throws ScriptException {
+ e.eval("var pf_boolean_box = o.publicFinalBooleanBox;");
+ assertEquals(o.publicFinalBooleanBox, e.get("pf_boolean_box"));
+ assertEquals("boolean", e.eval("typeof pf_boolean_box;"));
+ e.eval("o.publicFinalBooleanBox = false;");
+ assertEquals(true, (boolean)o.publicFinalBooleanBox);
+ }
+
+ @Test
+ public void accessStaticFinalFieldBooleanBoxing() throws ScriptException {
+ e.eval("var psf_boolean_box = SharedObject.publicStaticFinalBooleanBox;");
+ assertEquals(SharedObject.publicStaticFinalBooleanBox, e.get("psf_boolean_box"));
+ assertEquals("boolean", e.eval("typeof psf_boolean_box;"));
+ e.eval("SharedObject.publicStaticFinalBooleanBox = false;");
+ assertEquals(true, (boolean)SharedObject.publicStaticFinalBooleanBox);
+ }
+
+ @Test
+ public void accessVolatileField() throws ScriptException {
+ e.eval("var pv_boolean = o.volatileBoolean;");
+ assertEquals(o.volatileBoolean, e.get("pv_boolean"));
+ assertEquals("boolean", e.eval("typeof pv_boolean;"));
+ e.eval("o.volatileBoolean = false;");
+ assertEquals(false, o.volatileBoolean);
+ }
+
+ @Test
+ public void accessTransientField() throws ScriptException {
+ e.eval("var pt_boolean = o.transientBoolean;");
+ assertEquals(o.transientBoolean, e.get("pt_boolean"));
+ assertEquals("boolean", e.eval("typeof pt_boolean;"));
+ e.eval("o.transientBoolean = false;");
+ assertEquals(false, o.transientBoolean);
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/api/javaaccess/test/ConsStringTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.javaaccess.test;
+
+import static org.testng.AssertJUnit.assertEquals;
+import java.util.HashMap;
+import java.util.Map;
+import javax.script.Bindings;
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import jdk.nashorn.api.scripting.JSObject;
+import org.testng.TestNG;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+@SuppressWarnings("javadoc")
+public class ConsStringTest {
+ private static ScriptEngine e = null;
+
+ public static void main(final String[] args) {
+ TestNG.main(args);
+ }
+
+ @BeforeClass
+ public static void setUpClass() {
+ e = new ScriptEngineManager().getEngineByName("nashorn");
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ e = null;
+ }
+
+ @Test
+ public void testConsStringFlattening() throws ScriptException {
+ final Bindings b = e.getBindings(ScriptContext.ENGINE_SCOPE);
+ final Map<Object, Object> m = new HashMap<>();
+ b.put("m", m);
+ e.eval("var x = 'f'; x += 'oo'; var y = 'b'; y += 'ar'; m.put(x, y)");
+ assertEquals("bar", m.get("foo"));
+ }
+
+ @Test
+ public void testConsStringFromMirror() throws ScriptException {
+ final Bindings b = e.getBindings(ScriptContext.ENGINE_SCOPE);
+ //final Map<Object, Object> m = new HashMap<>();
+ e.eval("var x = 'f'; x += 'oo'; var obj = {x: x};");
+ assertEquals("foo", ((JSObject)b.get("obj")).getMember("x"));
+ }
+
+ @Test
+ public void testArrayConsString() throws ScriptException {
+ final Bindings b = e.getBindings(ScriptContext.ENGINE_SCOPE);
+ final ArrayHolder h = new ArrayHolder();
+ b.put("h", h);
+ e.eval("var x = 'f'; x += 'oo'; h.array = [x];");
+ assertEquals(1, h.array.length);
+ assertEquals("foo", h.array[0]);
+ }
+
+
+ public static class ArrayHolder {
+ private Object[] array;
+
+ public void setArray(final Object[] array) {
+ this.array = array;
+ }
+
+ public Object[] getArray() {
+ return array;
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/api/javaaccess/test/MethodAccessTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,466 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.javaaccess.test;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
+import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Locale;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import org.testng.TestNG;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * @test
+ * @build jdk.nashorn.api.javaaccess.test.SharedObject jdk.nashorn.api.javaaccess.test.Person jdk.nashorn.api.javaaccess.test.MethodAccessTest
+ * @run testng/othervm jdk.nashorn.api.javaaccess.test.MethodAccessTest
+ */
+@SuppressWarnings("javadoc")
+public class MethodAccessTest {
+
+ private static ScriptEngine e = null;
+ private static SharedObject o = null;
+
+ public static void main(final String[] args) {
+ TestNG.main(args);
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws ScriptException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ e = m.getEngineByName("nashorn");
+ o = new SharedObject();
+ o.setEngine(e);
+ e.put("o", o);
+ e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.test.SharedObject;");
+ e.eval("var Person = Packages.jdk.nashorn.api.javaaccess.test.Person;");
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ e = null;
+ o = null;
+ }
+
+ @Test
+ public void accessMethodthrowsCheckedException() throws ScriptException {
+ e.eval("try {" +
+ " var a = java.lang.Long.parseLong('foo');" +
+ "} catch(e) {" +
+ " var isThrown = true;" +
+ " var isNumberException = e instanceof java.lang.NumberFormatException;" +
+ "} finally {" +
+ " var isFinalized = true;" +
+ "}");
+ assertEquals("Exception thrown", true, e.get("isThrown"));
+ assertEquals("Finally called", true, e.get("isFinalized"));
+ assertEquals("Type is NumberFormatException", true, e.get("isNumberException"));
+ }
+
+ @Test
+ public void accessMethodthrowsUnCheckedException() throws ScriptException {
+ e.eval("try {" +
+ " var a = java.lang.String.valueOf(null);" +
+ "} catch(e) {" +
+ " var isThrown = true;" +
+ " var isNumberException = e instanceof java.lang.NullPointerException;" +
+ "} finally {" +
+ " var isFinalized = true;" +
+ "}");
+ assertEquals(true, e.get("isThrown"));
+ assertEquals(true, e.get("isFinalized"));
+ assertEquals(true, e.get("isNumberException"));
+ }
+
+ @Test
+ public void accessMethodStartsThread() throws ScriptException {
+ e.eval("o.methodStartsThread();");
+ assertEquals(false, o.isFinished);
+ }
+
+ @Test
+ public void accessStaticMethod() throws ScriptException {
+ assertEquals(10, e.eval("java.lang.Math.abs(-10);"));
+ }
+
+ @Test
+ public void accessSynchronousMethod() throws ScriptException {
+ e.eval("var v = new java.util.Vector();" + "v.add(10);" + "v.add(20);" + "v.add(30);");
+ assertEquals(10, e.eval("v[0]"));
+ assertEquals(20, e.eval("v[1]"));
+ assertEquals(30, e.eval("v[2]"));
+ assertEquals(3, e.eval("v.size()"));
+ }
+
+ @Test
+ public void accessStaticSynchronousMethod() throws ScriptException {
+ e.eval("var locales = java.util.Calendar.getAvailableLocales();");
+ final Locale[] locales = (Locale[])e.get("locales");
+ assertEquals(locales.length, Calendar.getAvailableLocales().length);
+ }
+
+ @Test
+ public void accessNativeMethod() throws ScriptException {
+ assertEquals(4.0, e.eval("java.lang.StrictMath.log10(10000);"));
+ }
+
+ @Test
+ public void accessConstructorOfAbstractClass() throws ScriptException {
+ e.eval("try {" +
+ " var a = new java.util.AbstractList();" +
+ " print('fail');" +
+ "} catch(e) {" +
+ " var isThrown = true;" +
+ "}");
+ assertEquals(true, e.get("isThrown"));
+ }
+
+ @Test
+ public void accessMethodVoid() throws ScriptException {
+ o.isAccessed = false;
+ e.eval("o.voidMethod();");
+ assertTrue(o.isAccessed);
+ }
+
+ @Test
+ public void accessMethodBoolean() throws ScriptException {
+ assertEquals(true, e.eval("o.booleanMethod(false);"));
+ assertEquals(false, e.eval("o.booleanMethod(true);"));
+ assertEquals(false, e.eval("o.booleanMethod('false');"));
+ assertEquals(true, e.eval("o.booleanMethod('');"));
+ assertEquals(true, e.eval("o.booleanMethod(0);"));
+ }
+
+ @Test
+ public void accessMethodInt() throws ScriptException {
+ assertEquals(0, e.eval("o.intMethod(0);"));
+ assertEquals(-200, e.eval("o.intMethod(-100);"));
+ assertEquals(0, e.eval("o.intMethod('0');"));
+ assertEquals(-200, e.eval("o.intMethod('-100');"));
+ }
+
+ @Test
+ public void accessMethodLong() throws ScriptException {
+ assertEquals((long)0, e.eval("o.longMethod(0);"));
+ assertEquals((long)400, e.eval("o.longMethod(200);"));
+ assertEquals((long) 0, e.eval("o.longMethod('0');"));
+ assertEquals((long) 400, e.eval("o.longMethod('200');"));
+ }
+
+ @Test
+ public void accessMethodByte() throws ScriptException {
+ assertEquals((byte) 0, e.eval("o.byteMethod(0);"));
+ assertEquals((byte) 10, e.eval("o.byteMethod(5);"));
+ assertEquals((byte) 0, e.eval("o.byteMethod('0');"));
+ assertEquals((byte) 10, e.eval("o.byteMethod('5');"));
+ }
+
+ @Test
+ public void accessMethodShort() throws ScriptException {
+ assertEquals((short)0, e.eval("o.shortMethod(0);"));
+ assertEquals((short)8000, e.eval("o.shortMethod(4000);"));
+ assertEquals((short) 0, e.eval("o.shortMethod('0');"));
+ assertEquals((short) 8000, e.eval("o.shortMethod('4000');"));
+ }
+
+ @Test
+ public void accessMethodChar() throws ScriptException {
+ assertEquals('A', e.eval("o.charMethod('a');"));
+ assertEquals('Z', e.eval("o.charMethod('z');"));
+ assertEquals(o.charMethod((char)0), e.eval("o.charMethod(0);"));
+ assertEquals(o.charMethod((char)3150), e.eval("o.charMethod(3150);"));
+ }
+
+ @Test
+ public void accessMethodFloat() throws ScriptException {
+ assertEquals(0.0f, e.eval("o.floatMethod(0.0);"));
+ assertEquals(4.2f, e.eval("o.floatMethod(2.1);"));
+ assertEquals(0.0f, e.eval("o.floatMethod('0.0');"));
+ assertEquals(4.2f, e.eval("o.floatMethod('2.1');"));
+ }
+
+ @Test
+ public void accessMethodDouble() throws ScriptException {
+ assertEquals(0.0, e.eval("o.doubleMethod(0.0);"));
+ assertEquals(14.0, e.eval("o.doubleMethod(7.0);"));
+ assertEquals(0.0, e.eval("o.doubleMethod('0.0');"));
+ assertEquals(14.0, e.eval("o.doubleMethod('7.0');"));
+ }
+
+ @Test
+ public void accessMethodBooleanBoxing() throws ScriptException {
+ assertEquals(Boolean.TRUE, e.eval("o.booleanBoxingMethod(java.lang.Boolean.FALSE);"));
+ assertEquals(Boolean.FALSE, e.eval("o.booleanBoxingMethod(java.lang.Boolean.TRUE);"));
+ assertEquals(Boolean.TRUE, e.eval("o.booleanBoxingMethod('');"));
+ assertEquals(Boolean.FALSE, e.eval("o.booleanBoxingMethod('false');"));
+ }
+
+ @Test
+ public void accessMethodIntBoxing() throws ScriptException {
+ assertEquals(0, e.eval("o.intBoxingMethod(0);"));
+ assertEquals(-200, e.eval("o.intBoxingMethod(-100);"));
+ assertTrue((int)e.eval("(new java.lang.Integer(2)).compareTo(10.0)") < 0);
+ }
+
+ @Test
+ public void accessMethodLongBoxing() throws ScriptException {
+ assertEquals((long) 0, e.eval("o.longBoxingMethod(0);"));
+ assertEquals((long) 400, e.eval("o.longBoxingMethod(200);"));
+ assertTrue((int)e.eval("(new java.lang.Long(2)).compareTo(10.0)") < 0);
+ }
+
+ @Test
+ public void accessMethodByteBoxing() throws ScriptException {
+ assertEquals((byte) 0, e.eval("o.byteBoxingMethod(0);"));
+ assertEquals((byte) 10, e.eval("o.byteBoxingMethod(5);"));
+ assertTrue((int)e.eval("(new java.lang.Byte(2)).compareTo(10.0)") < 0);
+ }
+
+ @Test
+ public void accessMethodShortBoxing() throws ScriptException {
+ assertEquals((short) 0, e.eval("o.shortBoxingMethod(0);"));
+ assertEquals((short) 8000, e.eval("o.shortBoxingMethod(4000);"));
+ assertTrue((int)e.eval("(new java.lang.Short(2)).compareTo(10.0)") < 0);
+ }
+
+ @Test
+ public void accessMethodCharBoxing() throws ScriptException {
+ assertEquals('A', e.eval("o.charBoxingMethod('a');"));
+ assertEquals('Z', e.eval("o.charBoxingMethod('z');"));
+ assertTrue((int)e.eval("(new java.lang.Character(2)).compareTo(10)") < 0);
+ }
+
+ @Test
+ public void accessMethodFloatBoxing() throws ScriptException {
+ assertEquals(0.0f, e.eval("o.floatBoxingMethod(0.0);"));
+ assertEquals(4.2f, e.eval("o.floatBoxingMethod(2.1);"));
+ assertTrue((int)e.eval("(new java.lang.Float(2.0)).compareTo(10.0)") < 0);
+ }
+
+ @Test
+ public void accessMethodDoubleBoxing() throws ScriptException {
+ assertEquals(0.0, e.eval("o.doubleBoxingMethod(0.0);"));
+ assertEquals(14.0, e.eval("o.doubleBoxingMethod(7.0);"));
+ assertTrue((int)e.eval("(new java.lang.Double(2)).compareTo(10.0)") < 0);
+ }
+
+ @Test
+ public void accessMethodString() throws ScriptException {
+ assertEquals("", e.eval("o.stringMethod('');"));
+ assertEquals("abcabc", e.eval("o.stringMethod('abc');"));
+ }
+
+ @Test
+ public void accessMethodObject() throws ScriptException {
+ e.put("so", new Person(5));
+ e.eval("var rso = o.objectMethod(so);");
+ assertEquals(new Person(10), e.get("rso"));
+ }
+
+ @Test
+ public void accessMethodBooleanArray() throws ScriptException {
+ assertTrue(Arrays.equals(o.booleanArrayMethod(o.publicBooleanArray), (boolean[])e.eval("o.booleanArrayMethod(o.publicBooleanArray);")));
+ }
+
+ @Test
+ public void accessMethodIntArray() throws ScriptException {
+ assertArrayEquals(o.intArrayMethod(o.publicIntArray), (int[])e.eval("o.intArrayMethod(o.publicIntArray);"));
+ }
+
+ @Test
+ public void accessMethodLongArray() throws ScriptException {
+ assertArrayEquals(o.longArrayMethod(o.publicLongArray), (long[])e.eval("o.longArrayMethod(o.publicLongArray);"));
+ }
+
+ @Test
+ public void accessMethodByteArray() throws ScriptException {
+ assertArrayEquals(o.byteArrayMethod(o.publicByteArray), (byte[])e.eval("o.byteArrayMethod(o.publicByteArray);"));
+ }
+
+ @Test
+ public void accessMethodShortArray() throws ScriptException {
+ assertArrayEquals(o.shortArrayMethod(o.publicShortArray), (short[])e.eval("o.shortArrayMethod(o.publicShortArray);"));
+ }
+
+ @Test
+ public void accessMethodCharArray() throws ScriptException {
+ assertArrayEquals(o.charArrayMethod(o.publicCharArray), (char[])e.eval("o.charArrayMethod(o.publicCharArray);"));
+ }
+
+ @Test
+ public void accessMethodFloatArray() throws ScriptException {
+ assertArrayEquals(o.floatArrayMethod(o.publicFloatArray), (float[])e.eval("o.floatArrayMethod(o.publicFloatArray);"), 1e-10f);
+ }
+
+ @Test
+ public void accessMethodDoubleArray() throws ScriptException {
+ assertArrayEquals(o.doubleArrayMethod(o.publicDoubleArray), (double[])e.eval("o.doubleArrayMethod(o.publicDoubleArray);"), 1e-10);
+ }
+
+ @Test
+ public void accessMethodStringArray() throws ScriptException {
+ assertArrayEquals(o.stringArrayMethod(o.publicStringArray), (String[])e.eval("o.stringArrayMethod(o.publicStringArray);"));
+ }
+
+ @Test
+ public void accessMethodObjectArray() throws ScriptException {
+ assertArrayEquals(o.objectArrayMethod(o.publicObjectArray), (Person[])e.eval("o.objectArrayMethod(o.publicObjectArray);"));
+ }
+
+ @Test
+ public void accessDefaultConstructor() throws ScriptException {
+ e.eval("var dc = new Packages.jdk.nashorn.api.javaaccess.test.Person()");
+ assertEquals(new Person(), e.get("dc"));
+ }
+
+ @Test
+ public void accessCustomConstructor() throws ScriptException {
+ e.eval("var cc = new Packages.jdk.nashorn.api.javaaccess.test.Person(17)");
+ assertEquals(new Person(17), e.get("cc"));
+ }
+
+ @Test
+ public void accessMethod2PrimitiveParams() throws ScriptException {
+ assertEquals(o.twoParamMethod(50, 40.0), e.eval("o.twoParamMethod(50,40);"));
+ }
+
+ @Test
+ public void accessMethod3PrimitiveParams() throws ScriptException {
+ assertEquals(o.threeParamMethod((short)10, 20L, 'b'), e.eval("o.threeParamMethod(10,20,'b');"));
+ }
+
+ @Test
+ public void accessMethod2ObjectParams() throws ScriptException {
+ assertArrayEquals(new Person[] { new Person(200), new Person(300) }, (Person[])e.eval("o.twoObjectParamMethod(new Person(300),new Person(200));"));
+ }
+
+ @Test
+ public void accessMethod3ObjectParams() throws ScriptException {
+ assertArrayEquals(new Person[] { new Person(3), new Person(2), new Person(1) }, (Person[])e.eval("o.threeObjectParamMethod(new Person(1),new Person(2),new Person(3));"));
+ }
+
+ @Test
+ public void accessMethod8ObjectParams() throws ScriptException {
+ assertArrayEquals(new Person[] { new Person(8), new Person(7), new Person(6), new Person(5), new Person(4), new Person(3), new Person(2), new Person(1) }, (Person[])e.eval("o.eightObjectParamMethod(new Person(1),new Person(2),new Person(3)," + "new Person(4),new Person(5),new Person(6),new Person(7),new Person(8));"));
+ }
+
+ @Test
+ public void accessMethod9ObjectParams() throws ScriptException {
+ assertArrayEquals(new Person[] { new Person(9), new Person(8), new Person(7), new Person(6), new Person(5), new Person(4), new Person(3), new Person(2), new Person(1) }, (Person[])e.eval("o.nineObjectParamMethod(new Person(1),new Person(2),new Person(3)," + "new Person(4),new Person(5),new Person(6)," + "new Person(7),new Person(8),new Person(9));"));
+ }
+
+ @Test
+ public void accessMethodObjectEllipsis() throws ScriptException {
+ assertArrayEquals(new Person[] { new Person(9), new Person(8), new Person(7), new Person(6), new Person(5), new Person(4), new Person(3), new Person(2), new Person(1) }, (Person[])e.eval("o.methodObjectEllipsis(new Person(1),new Person(2),new Person(3)," + "new Person(4),new Person(5),new Person(6)," + "new Person(7),new Person(8),new Person(9));"));
+ assertArrayEquals(new Person[] {}, (Person[])e.eval("o.methodObjectEllipsis()"));
+ assertArrayEquals(new Person[] { new Person(9) }, (Person[])e.eval("o.methodObjectEllipsis(new Person(9))"));
+ }
+
+ @Test
+ public void accessMethodPrimitiveEllipsis() throws ScriptException {
+ assertArrayEquals(new Person[] { new Person(1), new Person(3), new Person(2) }, (Person[])e.eval("o.methodPrimitiveEllipsis(1,3,2);"));
+ assertArrayEquals(new Person[] {}, (Person[])e.eval("o.methodPrimitiveEllipsis();"));
+ assertArrayEquals(o.methodPrimitiveEllipsis(9, 8, 7, 6, 5, 4, 3, 2, 1), (Person[])e.eval("o.methodPrimitiveEllipsis(9,8,7,6,5,4,3,2,1);"));
+ }
+
+ @Test
+ public void accessMethodMixedEllipsis() throws ScriptException {
+ assertArrayEquals(new Object[] { new Person(1), 12, "hello", true }, (Object[])e.eval("o.methodMixedEllipsis(new Person(1),12,'hello',true);"));
+ assertArrayEquals(new Object[] {}, (Object[])e.eval("o.methodMixedEllipsis();"));
+ }
+
+ @Test
+ public void accessMethodObjectWithEllipsis() throws ScriptException {
+ assertArrayEquals(new Object[] { "hello", 12, 15, 16 }, (Object[])e.eval("o.methodObjectWithEllipsis('hello',12,15,16);"));
+ assertArrayEquals(new Object[] { "hello" }, (Object[])e.eval("o.methodObjectWithEllipsis('hello');"));
+ }
+
+ @Test
+ public void accessMethodPrimitiveWithEllipsis() throws ScriptException {
+ assertArrayEquals(new Object[] { 14, 12L, 15L, 16L }, (Object[])e.eval("o.methodPrimitiveWithEllipsis(14,12,15,16);"));
+ assertArrayEquals(new Object[] { 12 }, (Object[])e.eval("o.methodPrimitiveWithEllipsis(12);"));
+ }
+
+ @Test
+ public void accessMethodMixedWithEllipsis() throws ScriptException {
+ assertArrayEquals(new Object[] { "Hello", 10, true, -100500, 80d }, (Object[])e.eval("o.methodMixedWithEllipsis('Hello', 10, true, -100500,80.0);"));
+ assertArrayEquals(new Object[] { "Nashorn", 15 }, (Object[])e.eval("o.methodMixedWithEllipsis('Nashorn',15);"));
+ }
+
+ @Test
+ public void accessMethodOverloaded() throws ScriptException {
+ assertEquals(0, e.eval("o.overloadedMethod(0);"));
+ assertEquals(2000, e.eval("o.overloadedMethod(1000);"));
+ assertEquals(2, e.eval("o.overloadedMethod('10');"));
+ assertEquals(7, e.eval("o.overloadedMethod('Nashorn');"));
+ assertEquals(4, e.eval("o.overloadedMethod('true');"));
+ assertEquals(1, e.eval("o.overloadedMethod(true);"));
+ assertEquals(0, e.eval("o.overloadedMethod(false);"));
+ assertEquals(44, e.eval("o.overloadedMethod(new Person(22));"));
+ assertEquals(0, e.eval("o.overloadedMethod(new Person());"));
+ }
+
+ @Test
+ public void accessMethodDoubleVSintOverloaded() throws ScriptException {
+ assertEquals("double", e.eval("o.overloadedMethodDoubleVSint(0.0);"));
+ assertEquals("double", e.eval("o.overloadedMethodDoubleVSint(1000.0);"));
+ assertEquals("double", e.eval("o.overloadedMethodDoubleVSint(0.01);"));
+ assertEquals("double", e.eval("o.overloadedMethodDoubleVSint(100.02);"));
+ assertEquals("int", e.eval("o.overloadedMethodDoubleVSint(0);"));
+ assertEquals("int", e.eval("o.overloadedMethodDoubleVSint(1000);"));
+ }
+
+ @Test
+ public void accessJavaMethodIntFromJSFromJavaFromJS() throws ScriptException {
+ e.eval("function secondLevelMethodInt(a) {"
+ + "return o.thirdLevelMethodInt(a);"
+ + "}");
+ assertEquals(50, e.eval("o.firstLevelMethodInt(10);"));
+ }
+
+ @Test
+ public void accessJavaMethodIntegerFromJSFromJavaFromJS() throws ScriptException {
+ e.eval("function secondLevelMethodInteger(a) {"
+ + "return o.thirdLevelMethodInteger(a);"
+ + "}");
+ assertEquals(100, e.eval("o.firstLevelMethodInteger(10);"));
+ }
+
+ @Test
+ public void accessJavaMethodObjectFromJSFromJavaFromJS() throws ScriptException {
+ e.eval("function secondLevelMethodObject(p) {"
+ + "return o.thirdLevelMethodObject(p);"
+ + "}");
+ assertEquals(new Person(100), e.eval("o.firstLevelMethodObject(new Person(10));"));
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/api/javaaccess/test/NumberAccessTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,789 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.javaaccess.test;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
+import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import org.testng.TestNG;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * @test
+ * @build jdk.nashorn.api.javaaccess.test.SharedObject jdk.nashorn.api.javaaccess.test.Person jdk.nashorn.api.javaaccess.test.NumberAccessTest
+ * @run testng/othervm jdk.nashorn.api.javaaccess.test.NumberAccessTest
+ */
+@SuppressWarnings("javadoc")
+public class NumberAccessTest {
+
+ private static ScriptEngine e;
+ private static SharedObject o;
+
+ public static void main(final String[] args) {
+ TestNG.main(args);
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws ScriptException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ e = m.getEngineByName("nashorn");
+ o = new SharedObject();
+ e.put("o", o);
+ e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.test.SharedObject;");
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ e = null;
+ o = null;
+ }
+
+ // --------------------------------long
+ // tests------------------------------------
+ @Test
+ public void accessFieldLong() throws ScriptException {
+ e.eval("var p_long = o.publicLong;");
+ assertEquals(o.publicLong, e.get("p_long"));
+ e.eval("o.publicLong = 12;");
+ assertEquals(12, o.publicLong);
+ }
+
+ @Test
+ public void accessFieldLongArray() throws ScriptException {
+ e.eval("var p_long_array = o.publicLongArray;");
+ assertEquals(o.publicLongArray[0], e.eval("o.publicLongArray[0];"));
+ assertArrayEquals(o.publicLongArray, (long[])e.get("p_long_array"));
+ e.eval("var t_long_arr = new (Java.type(\"long[]\"))(3);" +
+ "t_long_arr[0] = -189009;" +
+ "t_long_arr[1] = 456;" +
+ "t_long_arr[2] = 600000001;" +
+ "o.publicLongArray = t_long_arr;");
+ // e.eval("o.publicIntArray = [-189009,456,600000001];");
+ assertArrayEquals(new long[] { -189009, 456, 600000001 }, o.publicLongArray);
+ e.eval("o.publicLongArray[0] = 10;");
+ assertEquals(10, o.publicLongArray[0]);
+ }
+
+ @Test
+ public void accessStaticFieldLong() throws ScriptException {
+ e.eval("var ps_long = SharedObject.publicStaticLong;");
+ assertEquals(SharedObject.publicStaticLong, e.get("ps_long"));
+ e.eval("SharedObject.publicStaticLong = 120;");
+ assertEquals(120, SharedObject.publicStaticLong);
+ }
+
+ @Test
+ public void accessStaticFieldLongArray() throws ScriptException {
+ e.eval("var ps_long_array = SharedObject.publicStaticLongArray;");
+ assertEquals(SharedObject.publicStaticLongArray[0], e.eval("SharedObject.publicStaticLongArray[0];"));
+ assertArrayEquals(SharedObject.publicStaticLongArray, (long[])e.get("ps_long_array"));
+ e.eval("var ts_long_arr = new (Java.type(\"long[]\"))(3);" +
+ "ts_long_arr[0] = -189009;" +
+ "ts_long_arr[1] = 456;" +
+ "ts_long_arr[2] = 600000001;" +
+ "SharedObject.publicStaticLongArray = ts_long_arr;");
+ // e.eval("o.publicIntArray = [-189009,456,600000001];");
+ assertArrayEquals(new long[] { -189009, 456, 600000001 }, SharedObject.publicStaticLongArray);
+ e.eval("SharedObject.publicStaticLongArray[0] = 10;");
+ assertEquals(10, SharedObject.publicStaticLongArray[0]);
+ }
+
+ @Test
+ public void accessFinalFieldLong() throws ScriptException {
+ e.eval("var pf_long = o.publicFinalLong;");
+ assertEquals(o.publicFinalLong, e.get("pf_long"));
+ e.eval("o.publicFinalLong = 120;");
+ assertEquals(13353333333333333L, o.publicFinalLong);
+ }
+
+ @Test
+ public void accessFinalFieldLongArray() throws ScriptException {
+ e.eval("var pf_long_array = o.publicFinalLongArray;");
+ assertEquals(o.publicFinalLongArray[0], e.eval("o.publicFinalLongArray[0];"));
+ assertArrayEquals(o.publicFinalLongArray, (long[])e.get("pf_long_array"));
+ e.eval("var tf_long_arr = new (Java.type(\"long[]\"))(3);" +
+ "tf_long_arr[0] = -189009;" +
+ "tf_long_arr[1] = 456;" +
+ "tf_long_arr[2] = 600000001;" +
+ "o.publicFinalLongArray = tf_long_arr;");
+ // e.eval("o.publicIntArray = [-189009,456,600000001];");
+ assertArrayEquals(new long[] { 1901733333333L, -2247355555L, 3977377777L }, o.publicFinalLongArray);
+ e.eval("o.publicFinalLongArray[0] = 10;");
+ assertEquals(10, o.publicFinalLongArray[0]);
+ }
+
+ @Test
+ public void accessStaticFinalFieldLong() throws ScriptException {
+ e.eval("var psf_long = SharedObject.publicStaticFinalLong;");
+ assertEquals(SharedObject.publicStaticFinalLong, e.get("psf_long"));
+ e.eval("SharedObject.publicStaticFinalLong = 120;");
+ assertEquals(8333333333333L, SharedObject.publicStaticFinalLong);
+ }
+
+ @Test
+ public void accessStaticFinalFieldLongArray() throws ScriptException {
+ e.eval("var psf_long_array = SharedObject.publicStaticFinalLongArray;");
+ assertEquals(SharedObject.publicStaticFinalLongArray[0], e.eval("SharedObject.publicStaticFinalLongArray[0];"));
+ assertArrayEquals(SharedObject.publicStaticFinalLongArray, (long[])e.get("psf_long_array"));
+ e.eval("var tsf_long_arr = new (Java.type(\"long[]\"))(3);" +
+ "tsf_long_arr[0] = -189009;" +
+ "tsf_long_arr[1] = 456;" +
+ "tsf_long_arr[2] = 600000001;" +
+ "SharedObject.publicStaticFinalLongArray = tsf_long_arr;");
+ // e.eval("o.publicIntArray = [-189009,456,600000001];");
+ assertArrayEquals(new long[] { 19017383333L, -2247358L, 39773787L }, SharedObject.publicStaticFinalLongArray);
+ e.eval("SharedObject.publicStaticFinalLongArray[0] = 10;");
+ assertEquals(10, SharedObject.publicStaticFinalLongArray[0]);
+ }
+
+ // --------------------------------int
+ // tests------------------------------------
+ @Test
+ public void accessFieldInt() throws ScriptException {
+ e.eval("var p_int = o.publicInt;");
+ assertEquals(o.publicInt, e.get("p_int"));
+ e.eval("o.publicInt = 14;");
+ assertEquals(14, o.publicInt);
+ }
+
+ @Test
+ public void accessFieldIntArray() throws ScriptException {
+ e.eval("var p_int_array = o.publicIntArray;");
+ assertEquals(o.publicIntArray[0], e.eval("o.publicIntArray[0];"));
+ assertArrayEquals(o.publicIntArray, (int[])e.get("p_int_array"));
+ e.eval("var t_int_arr = new (Java.type(\"int[]\"))(3);" +
+ "t_int_arr[0] = 4;" +
+ "t_int_arr[1] = 5;" +
+ "t_int_arr[2] = 6;" +
+ "o.publicIntArray = t_int_arr;");
+ assertArrayEquals(new int[] { 4, 5, 6 }, o.publicIntArray);
+ e.eval("o.publicIntArray[0] = 100;");
+ assertEquals(100, o.publicIntArray[0]);
+ }
+
+ @Test
+ public void accessStaticFieldInt() throws ScriptException {
+ e.eval("var ps_int = SharedObject.publicStaticInt;");
+ assertEquals(SharedObject.publicStaticInt, e.get("ps_int"));
+ e.eval("SharedObject.publicStaticInt = 140;");
+ assertEquals(140, SharedObject.publicStaticInt);
+ }
+
+ @Test
+ public void accessStaticFieldIntArray() throws ScriptException {
+ e.eval("var ps_int_array = SharedObject.publicStaticIntArray;");
+ assertEquals(SharedObject.publicStaticIntArray[0], e.eval("SharedObject.publicStaticIntArray[0];"));
+ assertArrayEquals(SharedObject.publicStaticIntArray, (int[])e.get("ps_int_array"));
+ e.eval("var ts_int_arr = new (Java.type(\"int[]\"))(3);" +
+ "ts_int_arr[0] = 4;" +
+ "ts_int_arr[1] = 5;" +
+ "ts_int_arr[2] = 6;" +
+ "SharedObject.publicStaticIntArray = ts_int_arr;");
+ assertArrayEquals(new int[] { 4, 5, 6 }, SharedObject.publicStaticIntArray);
+ e.eval("SharedObject.publicStaticIntArray[0] = 100;");
+ assertEquals(100, SharedObject.publicStaticIntArray[0]);
+ }
+
+ @Test
+ public void accessFinalFieldInt() throws ScriptException {
+ e.eval("var pf_int = o.publicFinalInt;");
+ assertEquals(o.publicFinalInt, e.get("pf_int"));
+
+ e.eval("o.publicFinalInt = 10;");
+ assertEquals(20712023, o.publicFinalInt);
+ }
+
+ @Test
+ public void accessFinalFieldIntArray() throws ScriptException {
+ e.eval("var pf_int_array = o.publicFinalIntArray;");
+ assertEquals(o.publicFinalIntArray[0], e.eval("o.publicFinalIntArray[0];"));
+ assertArrayEquals(o.publicFinalIntArray, (int[])e.get("pf_int_array"));
+ e.eval("var tf_int_arr = new (Java.type(\"int[]\"))(3);" +
+ "tf_int_arr[0] = 4;" +
+ "tf_int_arr[1] = 5;" +
+ "tf_int_arr[2] = 6;" +
+ "o.publicFinalIntArray = tf_int_arr;");
+ assertArrayEquals(new int[] { 50, 80, 130, 210, 340 }, o.publicFinalIntArray);
+ e.eval("o.publicFinalIntArray[0] = 100;");
+ assertEquals(100, o.publicFinalIntArray[0]);
+ }
+
+ @Test
+ public void accessStaticFinalFieldInt() throws ScriptException {
+ e.eval("var psf_int = SharedObject.publicStaticFinalInt;");
+ assertEquals(SharedObject.publicStaticFinalInt, e.get("psf_int"));
+ e.eval("SharedObject.publicStaticFinalInt = 140;");
+ assertEquals(207182023, SharedObject.publicStaticFinalInt);
+ }
+
+ @Test
+ public void accessStaticFinalFieldIntArray() throws ScriptException {
+ e.eval("var psf_int_array = SharedObject.publicStaticFinalIntArray;");
+ assertEquals(SharedObject.publicStaticFinalIntArray[0], e.eval("SharedObject.publicStaticFinalIntArray[0];"));
+ assertArrayEquals(SharedObject.publicStaticFinalIntArray, (int[])e.get("psf_int_array"));
+ e.eval("var tsf_int_arr = new (Java.type(\"int[]\"))(3);" +
+ "tsf_int_arr[0] = 4;" +
+ "tsf_int_arr[1] = 5;" +
+ "tsf_int_arr[2] = 6;" +
+ "SharedObject.publicStaticFinalIntArray = tsf_int_arr;");
+ assertArrayEquals(new int[] { 1308, 210, 340 }, SharedObject.publicStaticFinalIntArray);
+ e.eval("SharedObject.publicStaticFinalIntArray[0] = 100;");
+ assertEquals(100, SharedObject.publicStaticFinalIntArray[0]);
+ }
+
+ // --------------------------------byte
+ // tests------------------------------------
+ @Test
+ public void accessFieldByte() throws ScriptException {
+ e.eval("var p_byte = o.publicByte;");
+ assertEquals((double)o.publicByte, ((Number)e.get("p_byte")).doubleValue());
+ e.eval("o.publicByte = 16;");
+ assertEquals(16, o.publicByte);
+ }
+
+ @Test
+ public void accessFieldByteArray() throws ScriptException {
+ e.eval("var p_byte_array = o.publicByteArray;");
+ assertEquals(o.publicByteArray[0], e.eval("o.publicByteArray[0];"));
+ assertArrayEquals(o.publicByteArray, (byte[])e.get("p_byte_array"));
+ e.eval("var t_byte_arr = new (Java.type(\"byte[]\"))(3);" +
+ "t_byte_arr[0] = -18;" +
+ "t_byte_arr[1] = 56;" +
+ "t_byte_arr[2] = 60;" +
+ "o.publicByteArray = t_byte_arr;");
+ assertArrayEquals(new byte[] { -18, 56, 60 }, o.publicByteArray);
+ e.eval("o.publicByteArray[0] = 100;");
+ assertEquals(100, o.publicByteArray[0]);
+ }
+
+ @Test
+ public void accessStaticFieldByte() throws ScriptException {
+ e.eval("var ps_byte = SharedObject.publicStaticByte;");
+ assertEquals((double)SharedObject.publicStaticByte, ((Number)e.get("ps_byte")).doubleValue());
+ e.eval("SharedObject.publicStaticByte = 16;");
+ assertEquals(16, SharedObject.publicStaticByte);
+ }
+
+ @Test
+ public void accessStaticFieldByteArray() throws ScriptException {
+ e.eval("var ps_byte_array = SharedObject.publicStaticByteArray;");
+ assertEquals(SharedObject.publicStaticByteArray[0], e.eval("SharedObject.publicStaticByteArray[0];"));
+ assertArrayEquals(SharedObject.publicStaticByteArray, (byte[])e.get("ps_byte_array"));
+ e.eval("var ts_byte_arr = new (Java.type(\"byte[]\"))(3);" +
+ "ts_byte_arr[0] = -18;" +
+ "ts_byte_arr[1] = 56;" +
+ "ts_byte_arr[2] = 60;" +
+ "SharedObject.publicStaticByteArray = ts_byte_arr;");
+ assertArrayEquals(new byte[] { -18, 56, 60 }, SharedObject.publicStaticByteArray);
+ e.eval("SharedObject.publicStaticByteArray[0] = -90;");
+ assertEquals(-90, SharedObject.publicStaticByteArray[0]);
+ }
+
+ @Test
+ public void accessFinalFieldByte() throws ScriptException {
+ e.eval("var pf_byte = o.publicFinalByte;");
+ assertEquals((double)o.publicFinalByte, ((Number)e.get("pf_byte")).doubleValue());
+ e.eval("o.publicFinalByte = 16;");
+ assertEquals(-7, o.publicFinalByte);
+ }
+
+ @Test
+ public void accessFinalFieldByteArray() throws ScriptException {
+ e.eval("var pf_byte_array = o.publicFinalByteArray;");
+ assertEquals(o.publicFinalByteArray[0], e.eval("o.publicFinalByteArray[0];"));
+ assertArrayEquals(o.publicFinalByteArray, (byte[])e.get("pf_byte_array"));
+ e.eval("var tf_byte_arr = new (Java.type(\"byte[]\"))(3);" +
+ "tf_byte_arr[0] = -18;" +
+ "tf_byte_arr[1] = 56;" +
+ "tf_byte_arr[2] = 60;" +
+ "o.publicFinalByteArray = tf_byte_arr;");
+ assertArrayEquals(new byte[] { 1, 3, 6, 17, -128 }, o.publicFinalByteArray);
+ e.eval("o.publicFinalByteArray[0] = -90;");
+ assertEquals(-90, o.publicFinalByteArray[0]);
+ }
+
+ @Test
+ public void accessStaticFinalFieldByte() throws ScriptException {
+ e.eval("var psf_byte = SharedObject.publicStaticFinalByte;");
+ assertEquals((double)SharedObject.publicStaticFinalByte, ((Number)e.get("psf_byte")).doubleValue());
+ e.eval("SharedObject.publicStaticFinalByte = 16;");
+ assertEquals(-70, SharedObject.publicStaticFinalByte);
+ }
+
+ @Test
+ public void accessStaticFinalFieldByteArray() throws ScriptException {
+ e.eval("var psf_byte_array = SharedObject.publicStaticFinalByteArray;");
+ assertEquals(SharedObject.publicStaticFinalByteArray[0], e.eval("SharedObject.publicStaticFinalByteArray[0];"));
+ assertArrayEquals(SharedObject.publicStaticFinalByteArray, (byte[])e.get("psf_byte_array"));
+ e.eval("var tsf_byte_arr = new (Java.type(\"byte[]\"))(3);" +
+ "tsf_byte_arr[0] = -18;" +
+ "tsf_byte_arr[1] = 56;" +
+ "tsf_byte_arr[2] = 60;" +
+ "SharedObject.publicStaticFinalByteArray = tsf_byte_arr;");
+ assertArrayEquals(new byte[] { 17, -128, 81 }, SharedObject.publicStaticFinalByteArray);
+ e.eval("SharedObject.publicStaticFinalByteArray[0] = -90;");
+ assertEquals(-90, SharedObject.publicStaticFinalByteArray[0]);
+ }
+
+ // --------------------------------short
+ // tests------------------------------------
+ @Test
+ public void accessFieldShort() throws ScriptException {
+ e.eval("var p_short = o.publicShort;");
+ assertEquals((double)o.publicShort, ((Number)e.get("p_short")).doubleValue());
+ e.eval("o.publicShort = 18;");
+ assertEquals(18, o.publicShort);
+ }
+
+ @Test
+ public void accessFieldShortArray() throws ScriptException {
+ e.eval("var p_short_array = o.publicShortArray;");
+ assertEquals(o.publicShortArray[0], e.eval("o.publicShortArray[0];"));
+ assertArrayEquals(o.publicShortArray, (short[])e.get("p_short_array"));
+ e.eval("var t_short_arr = new (Java.type(\"short[]\"))(3);" +
+ "t_short_arr[0] = 90;" +
+ "t_short_arr[1] = 5;" +
+ "t_short_arr[2] = -6000;" +
+ "o.publicShortArray = t_short_arr;");
+ assertArrayEquals(new short[] { 90, 5, -6000 }, o.publicShortArray);
+ e.eval("o.publicShortArray[0] = -1000;");
+ assertEquals(-1000, o.publicShortArray[0]);
+ }
+
+ @Test
+ public void accessStaticFieldShort() throws ScriptException {
+ e.eval("var ps_short = SharedObject.publicStaticShort;");
+ assertEquals((double)SharedObject.publicStaticShort, ((Number)e.get("ps_short")).doubleValue());
+ e.eval("SharedObject.publicStaticShort = 180;");
+ assertEquals(180, SharedObject.publicStaticShort);
+ }
+
+ @Test
+ public void accessStaticFieldShortArray() throws ScriptException {
+ e.eval("var ps_short_array = SharedObject.publicStaticShortArray;");
+ assertEquals(SharedObject.publicStaticShortArray[0], e.eval("SharedObject.publicStaticShortArray[0];"));
+ assertArrayEquals(SharedObject.publicStaticShortArray, (short[])e.get("ps_short_array"));
+ e.eval("var ts_short_arr = new (Java.type(\"short[]\"))(3);" +
+ "ts_short_arr[0] = 90;" +
+ "ts_short_arr[1] = 5;" +
+ "ts_short_arr[2] = -6000;" +
+ "SharedObject.publicStaticShortArray = ts_short_arr;");
+ assertArrayEquals(new short[] { 90, 5, -6000 }, SharedObject.publicStaticShortArray);
+ e.eval("SharedObject.publicStaticShortArray[0] = -1000;");
+ assertEquals(-1000, SharedObject.publicStaticShortArray[0]);
+ }
+
+ @Test
+ public void accessFinalFieldShort() throws ScriptException {
+ e.eval("var pf_short = o.publicFinalShort;");
+ assertEquals((double)o.publicFinalShort, ((Number)e.get("pf_short")).doubleValue());
+ e.eval("o.publicFinalShort = 180;");
+ assertEquals(31220, o.publicFinalShort);
+ }
+
+ @Test
+ public void accessFinalFieldShortArray() throws ScriptException {
+ e.eval("var pf_short_array = o.publicFinalShortArray;");
+ assertEquals(o.publicFinalShortArray[0], e.eval("o.publicFinalShortArray[0];"));
+ assertArrayEquals(o.publicFinalShortArray, (short[])e.get("pf_short_array"));
+ e.eval("var tf_short_arr = new (Java.type(\"short[]\"))(3);" +
+ "tf_short_arr[0] = 90;" +
+ "tf_short_arr[1] = 5;" +
+ "tf_short_arr[2] = -6000;" +
+ "o.publicFinalShortArray = tf_short_arr;");
+ assertArrayEquals(new short[] { 12240, 9200, -17289, 1200, 12 }, o.publicFinalShortArray);
+ e.eval("o.publicFinalShortArray[0] = -1000;");
+ assertEquals(-1000, o.publicFinalShortArray[0]);
+ }
+
+ @Test
+ public void accessStaticFinalFieldShort() throws ScriptException {
+ e.eval("var psf_short = SharedObject.publicStaticFinalShort;");
+ assertEquals((double)SharedObject.publicStaticFinalShort, ((Number)e.get("psf_short")).doubleValue());
+ e.eval("SharedObject.publicStaticFinalShort = 180;");
+ assertEquals(8888, SharedObject.publicStaticFinalShort);
+ }
+
+ @Test
+ public void accessStaticFinalFieldShortArray() throws ScriptException {
+ e.eval("var psf_short_array = SharedObject.publicStaticFinalShortArray;");
+ assertEquals(SharedObject.publicStaticFinalShortArray[0], e.eval("SharedObject.publicStaticFinalShortArray[0];"));
+ assertArrayEquals(SharedObject.publicStaticFinalShortArray, (short[])e.get("psf_short_array"));
+ e.eval("var tsf_short_arr = new (Java.type(\"short[]\"))(3);" +
+ "tsf_short_arr[0] = 90;" +
+ "tsf_short_arr[1] = 5;" +
+ "tsf_short_arr[2] = -6000;" +
+ "SharedObject.publicStaticFinalShortArray = tsf_short_arr;");
+ assertArrayEquals(new short[] { 8240, 9280, -1289, 120, 812 }, SharedObject.publicStaticFinalShortArray);
+ e.eval("SharedObject.publicStaticFinalShortArray[0] = -1000;");
+ assertEquals(-1000, SharedObject.publicStaticFinalShortArray[0]);
+ }
+
+ // --------------------------------char
+ // tests------------------------------------
+ @Test
+ public void accessFieldChar() throws ScriptException {
+ e.eval("var p_char = o.publicChar;");
+ assertEquals(o.publicChar, e.get("p_char"));
+ e.eval("o.publicChar = 'S';");
+ assertEquals('S', o.publicChar);
+ e.eval("o.publicChar = 10;");
+ assertEquals(10, o.publicChar);
+ e.eval("try {"
+ + " o.publicChar = 'Big string';" +
+ "} catch(e) {" +
+ " var isThrown = true;" +
+ "}");
+ assertEquals("Exception thrown", true, e.get("isThrown"));
+ assertEquals(10, o.publicChar);
+ }
+
+ @Test
+ public void accessFieldCharArray() throws ScriptException {
+ e.eval("var p_char_array = o.publicCharArray;");
+ assertEquals(o.publicCharArray[0], e.eval("o.publicCharArray[0];"));
+ assertArrayEquals(o.publicCharArray, (char[])e.get("p_char_array"));
+ e.eval("var t_char_arr = new (Java.type(\"char[]\"))(3);" +
+ "t_char_arr[0] = 'F';" +
+ "t_char_arr[1] = 'o';" +
+ "t_char_arr[2] = 'o';" +
+ "o.publicCharArray = t_char_arr;");
+ assertArrayEquals("Foo".toCharArray(), o.publicCharArray);
+ e.eval("o.publicCharArray[0] = 'Z';");
+ assertEquals('Z', o.publicCharArray[0]);
+ }
+
+ @Test
+ public void accessStaticFieldChar() throws ScriptException {
+ e.eval("var ps_char = SharedObject.publicStaticChar;");
+ assertEquals(SharedObject.publicStaticChar, e.get("ps_char"));
+ e.eval("SharedObject.publicStaticChar = 'Z';");
+ assertEquals('Z', SharedObject.publicStaticChar);
+ }
+
+ @Test
+ public void accessStaticFieldCharArray() throws ScriptException {
+ e.eval("var ps_char_array = SharedObject.publicStaticCharArray;");
+ assertEquals(SharedObject.publicStaticCharArray[0], e.eval("SharedObject.publicStaticCharArray[0];"));
+ assertArrayEquals(SharedObject.publicStaticCharArray, (char[])e.get("ps_char_array"));
+ e.eval("var ts_char_arr = new (Java.type(\"char[]\"))(3);" +
+ "ts_char_arr[0] = 'G';" +
+ "ts_char_arr[1] = 'o';" +
+ "ts_char_arr[2] = 'o';" +
+ "SharedObject.publicStaticCharArray = ts_char_arr;");
+ assertArrayEquals("Goo".toCharArray(), SharedObject.publicStaticCharArray);
+ e.eval("SharedObject.publicStaticCharArray[0] = 'Z';");
+ assertEquals('Z', SharedObject.publicStaticCharArray[0]);
+ }
+
+ @Test
+ public void accessFinalFieldChar() throws ScriptException {
+ e.eval("var pf_char = o.publicFinalChar;");
+ assertEquals(o.publicFinalChar, e.get("pf_char"));
+ e.eval("o.publicFinalChar = 'S';");
+ assertEquals('E', o.publicFinalChar);
+ }
+
+ @Test
+ public void accessFinalCharArray() throws ScriptException {
+ e.eval("var pf_char_array = o.publicFinalCharArray;");
+ assertEquals(o.publicFinalCharArray[0], e.eval("o.publicFinalCharArray[0];"));
+ assertArrayEquals(o.publicFinalCharArray, (char[])e.get("pf_char_array"));
+ e.eval("var tf_char_arr = new (Java.type(\"char[]\"))(3);" +
+ "tf_char_arr[0] = 'F';" +
+ "tf_char_arr[1] = 'o';" +
+ "tf_char_arr[2] = 'o';" +
+ "o.publicFinalCharArray = tf_char_arr;");
+ assertArrayEquals("Nashorn hello".toCharArray(), o.publicFinalCharArray);
+ e.eval("o.publicFinalCharArray[0] = 'Z';");
+ assertEquals('Z', o.publicFinalCharArray[0]);
+ }
+
+ @Test
+ public void accessStaticFinalFieldChar() throws ScriptException {
+ e.eval("var psf_char = SharedObject.publicStaticFinalChar;");
+ assertEquals(SharedObject.publicStaticFinalChar, e.get("psf_char"));
+ e.eval("SharedObject.publicStaticFinalChar = 'Z';");
+ assertEquals('K', SharedObject.publicStaticFinalChar);
+ }
+
+ @Test
+ public void accessStaticFinalFieldCharArray() throws ScriptException {
+ e.eval("var psf_char_array = SharedObject.publicStaticFinalCharArray;");
+ assertEquals(SharedObject.publicStaticFinalCharArray[0], e.eval("SharedObject.publicStaticFinalCharArray[0];"));
+ assertArrayEquals(SharedObject.publicStaticFinalCharArray, (char[])e.get("psf_char_array"));
+ e.eval("var tsf_char_arr = new (Java.type(\"char[]\"))(3);" +
+ "tsf_char_arr[0] = 'Z';" +
+ "tsf_char_arr[1] = 'o';" +
+ "tsf_char_arr[2] = 'o';" +
+ "SharedObject.publicStaticFinalCharArray = tsf_char_arr;");
+ assertArrayEquals("StaticString".toCharArray(), SharedObject.publicStaticFinalCharArray);
+ e.eval("SharedObject.publicStaticFinalCharArray[0] = 'Z';");
+ assertEquals('Z', SharedObject.publicStaticFinalCharArray[0]);
+ }
+
+ // --------------------------------float
+ // tests------------------------------------
+ @Test
+ public void accessFieldFloat() throws ScriptException {
+ e.eval("var p_float = o.publicFloat;");
+ assertEquals((double)o.publicFloat, ((Number)e.get("p_float")).doubleValue());
+ o.publicFloat = 0.0f / 0.0f;
+ assertEquals(true, e.eval("isNaN(o.publicFloat)"));
+ o.publicFloat = 1.0f / 0.0f;
+ assertEquals(true, e.eval("Number.POSITIVE_INFINITY === o.publicFloat"));
+ o.publicFloat = -1.0f / 0.0f;
+ assertEquals(true, e.eval("Number.NEGATIVE_INFINITY === o.publicFloat"));
+ e.eval("o.publicFloat = 20;");
+ assertEquals(20, o.publicFloat, 1e-10);
+ e.eval("o.publicFloat = 0.0/0.0;");
+ assertTrue(Float.isNaN(o.publicFloat));
+ e.eval("o.publicFloat = 1.0/0.0;");
+ assertEquals(Float.floatToIntBits(Float.POSITIVE_INFINITY), Float.floatToIntBits(o.publicFloat));
+ e.eval("o.publicFloat = -1.0/0.0;");
+ assertEquals(Float.NEGATIVE_INFINITY, o.publicFloat, 1e-10);
+ }
+
+ @Test
+ public void accessFieldFloatArray() throws ScriptException {
+ e.eval("var p_float_array = o.publicFloatArray;");
+ assertEquals(o.publicFloatArray[0], e.eval("o.publicFloatArray[0];"));
+ assertArrayEquals(o.publicFloatArray, (float[])e.get("p_float_array"), 1e-10f);
+ e.eval("var t_float_arr = new (Java.type(\"float[]\"))(3);" +
+ "t_float_arr[0] = 9.0;" +
+ "t_float_arr[1] = 5.12345;" +
+ "t_float_arr[2] = -60.03;" +
+ "o.publicFloatArray = t_float_arr;");
+ assertArrayEquals(new float[] { 9.0f, 5.12345f, -60.03f }, o.publicFloatArray, 1e-10f);
+ e.eval("o.publicFloatArray[0] = -513.2;");
+ assertArrayEquals(new float[] { -513.2f, 5.12345f, -60.03f }, o.publicFloatArray, 1e-10f);
+ }
+
+ @Test
+ public void accessStaticFieldFloat() throws ScriptException {
+ e.eval("var ps_float = SharedObject.publicStaticFloat;");
+ assertEquals((double)SharedObject.publicStaticFloat, ((Number)e.get("ps_float")).doubleValue());
+ SharedObject.publicStaticFloat = 0.0f / 0.0f;
+ assertEquals(true, e.eval("isNaN(SharedObject.publicStaticFloat)"));
+ SharedObject.publicStaticFloat = 1.0f / 0.0f;
+ assertEquals(true, e.eval("Number.POSITIVE_INFINITY === SharedObject.publicStaticFloat"));
+ SharedObject.publicStaticFloat = -1.0f / 0.0f;
+ assertEquals(true, e.eval("Number.NEGATIVE_INFINITY === SharedObject.publicStaticFloat"));
+ e.eval("SharedObject.publicStaticFloat = 20.0;");
+ assertEquals(20.0f, SharedObject.publicStaticFloat, 1e-10);
+ e.eval("SharedObject.publicStaticFloat = 0.0/0.0;");
+ assertTrue(Float.isNaN(SharedObject.publicStaticFloat));
+ e.eval("SharedObject.publicStaticFloat = 1.0/0.0;");
+ assertEquals(Float.floatToIntBits(Float.POSITIVE_INFINITY), Float.floatToIntBits(SharedObject.publicStaticFloat));
+ e.eval("SharedObject.publicStaticFloat = -1.0/0.0;");
+ assertEquals(Float.floatToIntBits(Float.NEGATIVE_INFINITY), Float.floatToIntBits(SharedObject.publicStaticFloat));
+ }
+
+ @Test
+ public void accessStaticFieldFloatArray() throws ScriptException {
+ e.eval("var ps_float_array = SharedObject.publicStaticFloatArray;");
+ assertEquals(SharedObject.publicStaticFloatArray[0], e.eval("SharedObject.publicStaticFloatArray[0];"));
+ assertArrayEquals(SharedObject.publicStaticFloatArray, (float[])e.get("ps_float_array"), 1e-10f);
+ e.eval("var ts_float_arr = new (Java.type(\"float[]\"))(3);" +
+ "ts_float_arr[0] = 9.0;" +
+ "ts_float_arr[1] = 5.12345;" +
+ "ts_float_arr[2] = -60.03;" +
+ "SharedObject.publicStaticFloatArray = ts_float_arr;");
+ assertArrayEquals(new float[] { 9.0f, 5.12345f, -60.03f }, SharedObject.publicStaticFloatArray, 1e-10f);
+ e.eval("SharedObject.publicStaticFloatArray[0] = -513.2;");
+ assertArrayEquals(new float[] { -513.2f, 5.12345f, -60.03f }, SharedObject.publicStaticFloatArray, 1e-10f);
+ }
+
+ @Test
+ public void accessFinalFloat() throws ScriptException {
+ e.eval("var pf_float = o.publicFinalFloat;");
+ assertEquals((double)o.publicFinalFloat, ((Number)e.get("pf_float")).doubleValue());
+ e.eval("o.publicFinalFloat = 20.0;");
+ assertEquals(7.72e8f, o.publicFinalFloat, 1e-10);
+ }
+
+ @Test
+ public void accessFinalFloatArray() throws ScriptException {
+ e.eval("var pf_float_array = o.publicFinalFloatArray;");
+ assertEquals(o.publicFinalFloatArray[0], e.eval("o.publicFinalFloatArray[0];"));
+ assertArrayEquals(o.publicFinalFloatArray, (float[])e.get("pf_float_array"), 1e-10f);
+ e.eval("var tf_float_arr = new (Java.type(\"float[]\"))(3);" +
+ "tf_float_arr[0] = 9.0;" +
+ "tf_float_arr[1] = 5.12345;" +
+ "tf_float_arr[2] = -60.03;" +
+ "o.publicFinalFloatArray = tf_float_arr;");
+ assertArrayEquals(new float[] { -131.012f, 189.32f, -31.32e8f, 3.72f }, o.publicFinalFloatArray, 1e-10f);
+ e.eval("o.publicFinalFloatArray[0] = -513.2;");
+ assertEquals(-513.2f, o.publicFinalFloatArray[0], 1e-10f);
+ }
+
+ @Test
+ public void accessStaticFinalFieldFloat() throws ScriptException {
+ e.eval("var psf_float = SharedObject.publicStaticFinalFloat;");
+ assertEquals((double)SharedObject.publicStaticFinalFloat, ((Number)e.get("psf_float")).doubleValue());
+ e.eval("SharedObject.publicStaticFinalFloat = 20.0;");
+ assertEquals(0.72e8f, SharedObject.publicStaticFinalFloat, 1e-10);
+ }
+
+ @Test
+ public void accessStaticFinalFieldFloatArray() throws ScriptException {
+ e.eval("var psf_float_array = SharedObject.publicStaticFinalFloatArray;");
+ assertEquals(SharedObject.publicStaticFinalFloatArray[0], e.eval("SharedObject.publicStaticFinalFloatArray[0];"));
+ assertArrayEquals(SharedObject.publicStaticFinalFloatArray, (float[])e.get("psf_float_array"), 1e-10f);
+ e.eval("var tsf_float_arr = new (Java.type(\"float[]\"))(3);" +
+ "tsf_float_arr[0] = 9.0;" +
+ "tsf_float_arr[1] = 5.12345;" +
+ "tsf_float_arr[2] = -60.03;" +
+ "SharedObject.publicStaticFinalFloatArray = tsf_float_arr;");
+ assertArrayEquals(new float[] { -8131.012f, 9.32f, -138.32e8f, 0.72f }, SharedObject.publicStaticFinalFloatArray, 1e-10f);
+ e.eval("SharedObject.publicStaticFinalFloatArray[0] = -513.2;");
+ assertEquals(-513.2f, SharedObject.publicStaticFinalFloatArray[0], 1e-10f);
+ }
+
+ // --------------------------------double
+ // tests------------------------------------
+ @Test
+ public void accessFieldDouble() throws ScriptException {
+ e.eval("var p_double = o.publicDouble;");
+ assertEquals(o.publicDouble, e.get("p_double"));
+ o.publicDouble = 0.0 / 0.0;
+ assertEquals(true, e.eval("isNaN(o.publicDouble)"));
+ o.publicDouble = 1.0 / 0.0;
+ assertEquals(true, e.eval("Number.POSITIVE_INFINITY === o.publicDouble"));
+ o.publicDouble = -1.0 / 0.0;
+ assertEquals(true, e.eval("Number.NEGATIVE_INFINITY === o.publicDouble"));
+ e.eval("o.publicDouble = 30;");
+ assertEquals(Double.doubleToLongBits(30.0), Double.doubleToLongBits(o.publicDouble));
+ e.eval("o.publicDouble = 0.0/0.0;");
+ assertTrue(Double.isNaN(o.publicDouble));
+ e.eval("o.publicDouble = 1.0/0.0;");
+ assertEquals(Double.doubleToLongBits(Double.POSITIVE_INFINITY), Double.doubleToLongBits(o.publicDouble));
+ e.eval("o.publicDouble = -1.0/0.0;");
+ assertEquals(Double.doubleToLongBits(Double.NEGATIVE_INFINITY), Double.doubleToLongBits(o.publicDouble));
+ }
+
+ @Test
+ public void accessFieldDoubleArrayRead() throws ScriptException {
+ e.eval("var p_double_array = o.publicDoubleArray;");
+ assertEquals(o.publicDoubleArray[0], e.eval("o.publicDoubleArray[0];"));
+ assertArrayEquals(o.publicDoubleArray, (double[])e.get("p_double_array"), 1e-10);
+ e.eval("var t_double_arr = new (Java.type(\"double[]\"))(3);" +
+ "t_double_arr[0] = 9e10;" +
+ "t_double_arr[1] = 0.677777;" +
+ "t_double_arr[2] = -0.0000001;" +
+ "o.publicDoubleArray = t_double_arr;");
+ assertArrayEquals(new double[] { 9e10, 0.677777, -0.0000001 }, o.publicDoubleArray, 1e-10f);
+ e.eval("o.publicDoubleArray[0] = -5.2e10;");
+ assertEquals(-5.2e10, o.publicDoubleArray[0], 1e-10f);
+ }
+
+ @Test
+ public void accessStaticFieldDouble() throws ScriptException {
+ e.eval("var ps_double = SharedObject.publicStaticDouble;");
+ assertEquals(SharedObject.publicStaticDouble, e.get("ps_double"));
+ SharedObject.publicStaticDouble = 0.0 / 0.0;
+ assertEquals(true, e.eval("isNaN(SharedObject.publicStaticDouble)"));
+ SharedObject.publicStaticDouble = 1.0 / 0.0;
+ assertEquals(true, e.eval("Number.POSITIVE_INFINITY === SharedObject.publicStaticDouble"));
+ SharedObject.publicStaticDouble = -1.0 / 0.0;
+ assertEquals(true, e.eval("Number.NEGATIVE_INFINITY === SharedObject.publicStaticDouble"));
+ e.eval("SharedObject.publicStaticDouble = 40.0;");
+ assertEquals(Double.doubleToLongBits(40.0), Double.doubleToLongBits(SharedObject.publicStaticDouble));
+ e.eval("SharedObject.publicStaticDouble = 0.0/0.0;");
+ assertTrue(Double.isNaN(SharedObject.publicStaticDouble));
+ e.eval("SharedObject.publicStaticDouble = 1.0/0.0;");
+ assertEquals(Double.doubleToLongBits(Double.POSITIVE_INFINITY), Double.doubleToLongBits(SharedObject.publicStaticDouble));
+ e.eval("SharedObject.publicStaticDouble = -1.0/0.0;");
+ assertEquals(Double.doubleToLongBits(Double.NEGATIVE_INFINITY), Double.doubleToLongBits(SharedObject.publicStaticDouble));
+ }
+
+ @Test
+ public void accessStaticFieldDoubleArrayRead() throws ScriptException {
+ e.eval("var ps_double_array = SharedObject.publicStaticDoubleArray;");
+ assertEquals(SharedObject.publicStaticDoubleArray[0], e.eval("SharedObject.publicStaticDoubleArray[0];"));
+ assertArrayEquals(SharedObject.publicStaticDoubleArray, (double[])e.get("ps_double_array"), 1e-10);
+ e.eval("var ts_double_arr = new (Java.type(\"double[]\"))(3);" +
+ "ts_double_arr[0] = 9e10;" +
+ "ts_double_arr[1] = 0.677777;" +
+ "ts_double_arr[2] = -0.0000001;" +
+ "SharedObject.publicStaticDoubleArray = ts_double_arr;");
+ assertArrayEquals(new double[] { 9e10, 0.677777, -0.0000001 }, SharedObject.publicStaticDoubleArray, 1e-10f);
+ e.eval("SharedObject.publicStaticDoubleArray[0] = -5.2e10;");
+ assertEquals(-5.2e10, SharedObject.publicStaticDoubleArray[0], 1e-10f);
+ }
+
+ @Test
+ public void accessFinalFieldDouble() throws ScriptException {
+ e.eval("var pf_double = o.publicFinalDouble;");
+ assertEquals(o.publicFinalDouble, e.get("pf_double"));
+ e.eval("o.publicFinalDouble = 30.0;");
+ assertEquals(Double.doubleToLongBits(1.3412e20), Double.doubleToLongBits(o.publicFinalDouble));
+ }
+
+ @Test
+ public void accessFinalFieldDoubleArrayRead() throws ScriptException {
+ e.eval("var pf_double_array = o.publicFinalDoubleArray;");
+ assertEquals(o.publicFinalDoubleArray[0], e.eval("o.publicFinalDoubleArray[0];"));
+ assertArrayEquals(o.publicFinalDoubleArray, (double[])e.get("pf_double_array"), 1e-10);
+ e.eval("var tf_double_arr = new (Java.type(\"double[]\"))(3);" +
+ "tf_double_arr[0] = 9e10;" +
+ "tf_double_arr[1] = 0.677777;" +
+ "tf_double_arr[2] = -0.0000001;" +
+ "o.publicFinalDoubleArray = tf_double_arr;");
+ assertArrayEquals(new double[] { 0.725e80, 0.12e10, 8e-3, 1.00077 }, o.publicFinalDoubleArray, 1e-10f);
+ e.eval("o.publicFinalDoubleArray[0] = -5.2e10;");
+ assertEquals(-5.2e10, o.publicFinalDoubleArray[0], 1e-10f);
+ }
+
+ @Test
+ public void accessStaticFinalFieldDouble() throws ScriptException {
+ e.eval("var psf_double = SharedObject.publicStaticFinalDouble;");
+ assertEquals(SharedObject.publicStaticFinalDouble, e.get("psf_double"));
+ e.eval("SharedObject.publicStaticFinalDouble = 40.0;");
+ assertEquals(Double.doubleToLongBits(1.8e12), Double.doubleToLongBits(SharedObject.publicStaticFinalDouble));
+ }
+
+ @Test
+ public void accessStaticFinalFieldDoubleArrayRead() throws ScriptException {
+ e.eval("var psf_double_array = SharedObject.publicStaticFinalDoubleArray;");
+ assertEquals(SharedObject.publicStaticFinalDoubleArray[0], e.eval("SharedObject.publicStaticFinalDoubleArray[0];"));
+ assertArrayEquals(SharedObject.publicStaticFinalDoubleArray, (double[])e.get("psf_double_array"), 1e-10);
+ e.eval("var tsf_double_arr = new (Java.type(\"double[]\"))(3);" +
+ "tsf_double_arr[0] = 9e10;" +
+ "tsf_double_arr[1] = 0.677777;" +
+ "tsf_double_arr[2] = -0.0000001;" +
+ "SharedObject.publicStaticFinalDoubleArray = tsf_double_arr;");
+ assertArrayEquals(new double[] { 8.725e80, 0.82e10, 18e-3, 1.08077 }, SharedObject.publicStaticFinalDoubleArray, 1e-10f);
+ e.eval("SharedObject.publicStaticFinalDoubleArray[0] = -5.2e10;");
+ assertEquals(-5.2e10, SharedObject.publicStaticFinalDoubleArray[0], 1e-10f);
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/api/javaaccess/test/NumberBoxingTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,365 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.javaaccess.test;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import org.testng.TestNG;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * @test
+ * @build jdk.nashorn.api.javaaccess.test.SharedObject jdk.nashorn.api.javaaccess.test.Person jdk.nashorn.api.javaaccess.test.NumberBoxingTest
+ * @run testng/othervm jdk.nashorn.api.javaaccess.test.NumberBoxingTest
+ */
+@SuppressWarnings("javadoc")
+public class NumberBoxingTest {
+
+ private static ScriptEngine e;
+ private static SharedObject o;
+
+ public static void main(final String[] args) {
+ TestNG.main(args);
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws ScriptException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ e = m.getEngineByName("nashorn");
+ o = new SharedObject();
+ e.put("o", o);
+ e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.test.SharedObject;");
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ e = null;
+ o = null;
+ }
+
+ // --------------------------------long
+ // tests------------------------------------
+ @Test
+ public void accessFieldLongBoxing() throws ScriptException {
+ e.eval("var p_long = o.publicLongBox;");
+ assertEquals(o.publicLongBox, e.get("p_long"));
+ e.eval("o.publicLongBox = 12;");
+ assertEquals(Long.valueOf(12), o.publicLongBox);
+ }
+
+ @Test
+ public void accessStaticFieldLongBoxing() throws ScriptException {
+ e.eval("var ps_long = SharedObject.publicStaticLongBox;");
+ assertEquals(SharedObject.publicStaticLongBox, e.get("ps_long"));
+ e.eval("SharedObject.publicStaticLongBox = 120;");
+ assertEquals(120L, SharedObject.publicStaticLongBox.longValue());
+ }
+
+ @Test
+ public void accessFinalFieldLongBoxing() throws ScriptException {
+ e.eval("var pf_long = o.publicFinalLongBox;");
+ assertEquals(o.publicFinalLongBox, e.get("pf_long"));
+ e.eval("o.publicFinalLongBox = 120;");
+ assertEquals(Long.valueOf(9377333334L), o.publicFinalLongBox);
+ }
+
+ @Test
+ public void accessStaticFinalFieldLongBoxing() throws ScriptException {
+ e.eval("var psf_long = SharedObject.publicStaticFinalLong;");
+ assertEquals(SharedObject.publicStaticFinalLong, e.get("psf_long"));
+ e.eval("SharedObject.publicStaticFinalLong = 120;");
+ assertEquals(8333333333333L, SharedObject.publicStaticFinalLong);
+ }
+
+ // --------------------------------int
+ // tests------------------------------------
+ @Test
+ public void accessFieldIntBoxing() throws ScriptException {
+ e.eval("var p_int = o.publicIntBox;");
+ assertEquals(o.publicIntBox, e.get("p_int"));
+ e.eval("o.publicIntBox = 14;");
+ assertEquals(Integer.valueOf(14), o.publicIntBox);
+ }
+
+ @Test
+ public void accessStaticFieldIntBoxing() throws ScriptException {
+ e.eval("var ps_int = SharedObject.publicStaticInt;");
+ assertEquals(SharedObject.publicStaticInt, e.get("ps_int"));
+ e.eval("SharedObject.publicStaticInt = 140;");
+ assertEquals(140, SharedObject.publicStaticInt);
+ }
+
+ @Test
+ public void accessFinalFieldIntBoxing() throws ScriptException {
+ e.eval("var pf_int = o.publicFinalIntBox;");
+ assertEquals(o.publicFinalIntBox, e.get("pf_int"));
+ e.eval("o.publicFinalIntBox = 10;");
+ assertEquals(Integer.valueOf(207512301), o.publicFinalIntBox);
+ }
+
+ @Test
+ public void accessStaticFinalFieldIntBoxing() throws ScriptException {
+ e.eval("var psf_int = SharedObject.publicStaticFinalInt;");
+ assertEquals(SharedObject.publicStaticFinalInt, e.get("psf_int"));
+ e.eval("SharedObject.publicStaticFinalInt = 140;");
+ assertEquals(207182023, SharedObject.publicStaticFinalInt);
+ }
+
+ // --------------------------------byte
+ // tests------------------------------------
+ @Test
+ public void accessFieldByteBoxing() throws ScriptException {
+ e.eval("var p_byte = o.publicByteBox;");
+ assertEqualsDouble(o.publicByteBox, "p_byte");
+ e.eval("o.publicByteBox = 16;");
+ assertEquals(Byte.valueOf((byte)16), o.publicByteBox);
+ }
+
+ @Test
+ public void accessStaticFieldByteBoxing() throws ScriptException {
+ e.eval("var ps_byte = SharedObject.publicStaticByte;");
+ assertEqualsDouble(SharedObject.publicStaticByte, "ps_byte");
+ e.eval("SharedObject.publicStaticByte = 16;");
+ assertEquals(16, SharedObject.publicStaticByte);
+ }
+
+ @Test
+ public void accessFinalFieldByteBoxing() throws ScriptException {
+ e.eval("var pf_byte = o.publicFinalByteBox;");
+ assertEqualsDouble(o.publicFinalByteBox, "pf_byte");
+ e.eval("o.publicFinalByteBox = 16;");
+ assertEquals(Byte.valueOf((byte)19), o.publicFinalByteBox);
+ }
+
+ @Test
+ public void accessStaticFinalFieldByteBoxing() throws ScriptException {
+ e.eval("var psf_byte = SharedObject.publicStaticFinalByte;");
+ assertEqualsDouble(SharedObject.publicStaticFinalByte, "psf_byte");
+ e.eval("SharedObject.publicStaticFinalByte = 16;");
+ assertEquals(-70, SharedObject.publicStaticFinalByte);
+ }
+
+ // --------------------------------short
+ // tests------------------------------------
+ @Test
+ public void accessFieldShortBoxing() throws ScriptException {
+ e.eval("var p_short = o.publicShortBox;");
+ assertEqualsDouble(o.publicShortBox, "p_short");
+ e.eval("o.publicShortBox = 18;");
+ assertEquals(Short.valueOf((short)18), o.publicShortBox);
+ }
+
+ private static void assertEqualsDouble(final Number n, final String name) {
+ assertEquals(n.doubleValue(), ((Number)e.get(name)).doubleValue());
+ }
+
+ @Test
+ public void accessStaticFieldShortBoxing() throws ScriptException {
+ e.eval("var ps_short = SharedObject.publicStaticShort;");
+ assertEqualsDouble(SharedObject.publicStaticShort, "ps_short");
+ e.eval("SharedObject.publicStaticShort = 180;");
+ assertEquals(180, SharedObject.publicStaticShort);
+ }
+
+ @Test
+ public void accessFinalFieldShortBoxing() throws ScriptException {
+ e.eval("var pf_short = o.publicFinalShortBox;");
+ assertEqualsDouble(o.publicFinalShortBox, "pf_short");
+ e.eval("o.publicFinalShortBox = 180;");
+ assertEquals(Short.valueOf((short)-26777), o.publicFinalShortBox);
+ }
+
+ @Test
+ public void accessStaticFinalFieldShortBoxing() throws ScriptException {
+ e.eval("var psf_short = SharedObject.publicStaticFinalShort;");
+ assertEqualsDouble(SharedObject.publicStaticFinalShort, "psf_short");
+ e.eval("SharedObject.publicStaticFinalShort = 180;");
+ assertEquals(8888, SharedObject.publicStaticFinalShort);
+ }
+
+ // --------------------------------char
+ // tests------------------------------------
+ @Test
+ public void accessFieldCharBoxing() throws ScriptException {
+ e.eval("var p_char = o.publicCharBox;");
+ assertEquals(o.publicCharBox, e.get("p_char"));
+ e.eval("o.publicCharBox = 'S';");
+ assertEquals(Character.valueOf('S'), o.publicCharBox);
+ e.eval("try {" +
+ " o.publicCharBox = 'Big string';" +
+ "} catch(e) {" +
+ " var isThrown = true;" +
+ "}");
+ assertEquals("Exception thrown", true, e.get("isThrown"));
+ assertEquals(Character.valueOf('S'), o.publicCharBox);
+ }
+
+ @Test
+ public void accessStaticFieldCharBoxing() throws ScriptException {
+ e.eval("var ps_char = SharedObject.publicStaticChar;");
+ assertEquals(SharedObject.publicStaticChar, e.get("ps_char"));
+ e.eval("SharedObject.publicStaticChar = 'Z';");
+ assertEquals('Z', SharedObject.publicStaticChar);
+ }
+
+ @Test
+ public void accessFinalFieldCharBoxing() throws ScriptException {
+ e.eval("var pf_char = o.publicFinalCharBox;");
+ assertEquals(o.publicFinalCharBox, e.get("pf_char"));
+ e.eval("o.publicFinalCharBox = 'S';");
+ assertEquals(Character.valueOf('F'), o.publicFinalCharBox);
+ }
+
+ @Test
+ public void accessStaticFinalFieldCharBoxing() throws ScriptException {
+ e.eval("var psf_char = SharedObject.publicStaticFinalChar;");
+ assertEquals(SharedObject.publicStaticFinalChar, e.get("psf_char"));
+ e.eval("SharedObject.publicStaticFinalChar = 'Z';");
+ assertEquals('K', SharedObject.publicStaticFinalChar);
+ }
+
+ // --------------------------------float
+ // tests------------------------------------
+ @Test
+ public void accessFieldFloatBoxing() throws ScriptException {
+ e.eval("var p_float = o.publicFloatBox;");
+ assertEqualsDouble(o.publicFloatBox, "p_float");
+ o.publicFloatBox = 0.0f / 0.0f;
+ assertEquals(true, e.eval("isNaN(o.publicFloatBox)"));
+ o.publicFloatBox = 1.0f / 0.0f;
+ assertEquals(true, e.eval("Number.POSITIVE_INFINITY === o.publicFloatBox"));
+ o.publicFloatBox = -1.0f / 0.0f;
+ assertEquals(true, e.eval("Number.NEGATIVE_INFINITY === o.publicFloatBox"));
+ e.eval("o.publicFloatBox = 20;");
+ assertEquals(20, o.publicFloatBox, 1e-10);
+ e.eval("o.publicFloatBox = 0.0/0.0;");
+ assertTrue(Float.isNaN(o.publicFloatBox));
+ e.eval("o.publicFloatBox = 1.0/0.0;");
+ assertEquals(Float.floatToIntBits(Float.POSITIVE_INFINITY), Float.floatToIntBits(o.publicFloatBox));
+ e.eval("o.publicFloatBox = -1.0/0.0;");
+ assertEquals(Float.NEGATIVE_INFINITY, o.publicFloatBox, 1e-10);
+ }
+
+ @Test
+ public void accessStaticFieldFloatBoxing() throws ScriptException {
+ e.eval("var ps_float = SharedObject.publicStaticFloat;");
+ assertEqualsDouble(SharedObject.publicStaticFloat, "ps_float");
+ SharedObject.publicStaticFloat = 0.0f / 0.0f;
+ assertEquals(true, e.eval("isNaN(SharedObject.publicStaticFloat)"));
+ SharedObject.publicStaticFloat = 1.0f / 0.0f;
+ assertEquals(true, e.eval("Number.POSITIVE_INFINITY === SharedObject.publicStaticFloat"));
+ SharedObject.publicStaticFloat = -1.0f / 0.0f;
+ assertEquals(true, e.eval("Number.NEGATIVE_INFINITY === SharedObject.publicStaticFloat"));
+ e.eval("SharedObject.publicStaticFloat = 20.0;");
+ assertEquals(20.0f, SharedObject.publicStaticFloat, 1e-10);
+ e.eval("SharedObject.publicStaticFloat = 0.0/0.0;");
+ assertTrue(Float.isNaN(SharedObject.publicStaticFloat));
+ e.eval("SharedObject.publicStaticFloat = 1.0/0.0;");
+ assertEquals(Float.floatToIntBits(Float.POSITIVE_INFINITY), Float.floatToIntBits(SharedObject.publicStaticFloat));
+ e.eval("SharedObject.publicStaticFloat = -1.0/0.0;");
+ assertEquals(Float.floatToIntBits(Float.NEGATIVE_INFINITY), Float.floatToIntBits(SharedObject.publicStaticFloat));
+ }
+
+ @Test
+ public void accessFinalFloatBoxing() throws ScriptException {
+ e.eval("var pf_float = o.publicFinalFloatBox;");
+ assertEqualsDouble(o.publicFinalFloatBox, "pf_float");
+ e.eval("o.publicFinalFloatBox = 20.0;");
+ assertEquals(1.372e4f, o.publicFinalFloatBox, 1e-10);
+ }
+
+ @Test
+ public void accessStaticFinalFieldFloatBoxing() throws ScriptException {
+ e.eval("var psf_float = SharedObject.publicStaticFinalFloat;");
+ assertEqualsDouble(SharedObject.publicStaticFinalFloat, "psf_float");
+ e.eval("SharedObject.publicStaticFinalFloat = 20.0;");
+ assertEquals(0.72e8f, SharedObject.publicStaticFinalFloat, 1e-10);
+ }
+
+ // --------------------------------double
+ // tests------------------------------------
+ @Test
+ public void accessFieldDoubleBoxing() throws ScriptException {
+ e.eval("var p_double = o.publicDoubleBox;");
+ assertEquals(o.publicDoubleBox, e.get("p_double"));
+ o.publicDoubleBox = 0.0 / 0.0;
+ assertEquals(true, e.eval("isNaN(o.publicDoubleBox)"));
+ o.publicDoubleBox = 1.0 / 0.0;
+ assertEquals(true, e.eval("Number.POSITIVE_INFINITY === o.publicDoubleBox"));
+ o.publicDoubleBox = -1.0 / 0.0;
+ assertEquals(true, e.eval("Number.NEGATIVE_INFINITY === o.publicDoubleBox"));
+ e.eval("o.publicDoubleBox = 30;");
+ assertEquals(Double.doubleToLongBits(30.0), Double.doubleToLongBits(o.publicDoubleBox));
+ e.eval("o.publicDoubleBox = 0.0/0.0;");
+ assertTrue(Double.isNaN(o.publicDoubleBox));
+ e.eval("o.publicDoubleBox = 1.0/0.0;");
+ assertEquals(Double.doubleToLongBits(Double.POSITIVE_INFINITY), Double.doubleToLongBits(o.publicDoubleBox));
+ e.eval("o.publicDoubleBox = -1.0/0.0;");
+ assertEquals(Double.doubleToLongBits(Double.NEGATIVE_INFINITY), Double.doubleToLongBits(o.publicDoubleBox));
+ }
+
+ @Test
+ public void accessStaticFieldDoubleBoxing() throws ScriptException {
+ e.eval("var ps_double = SharedObject.publicStaticDouble;");
+ assertEquals(SharedObject.publicStaticDouble, e.get("ps_double"));
+ SharedObject.publicStaticDouble = 0.0 / 0.0;
+ assertEquals(true, e.eval("isNaN(SharedObject.publicStaticDouble)"));
+ SharedObject.publicStaticDouble = 1.0 / 0.0;
+ assertEquals(true, e.eval("Number.POSITIVE_INFINITY === SharedObject.publicStaticDouble"));
+ SharedObject.publicStaticDouble = -1.0 / 0.0;
+ assertEquals(true, e.eval("Number.NEGATIVE_INFINITY === SharedObject.publicStaticDouble"));
+ e.eval("SharedObject.publicStaticDouble = 40.0;");
+ assertEquals(Double.doubleToLongBits(40.0), Double.doubleToLongBits(SharedObject.publicStaticDouble));
+ e.eval("SharedObject.publicStaticDouble = 0.0/0.0;");
+ assertTrue(Double.isNaN(SharedObject.publicStaticDouble));
+ e.eval("SharedObject.publicStaticDouble = 1.0/0.0;");
+ assertEquals(Double.doubleToLongBits(Double.POSITIVE_INFINITY), Double.doubleToLongBits(SharedObject.publicStaticDouble));
+ e.eval("SharedObject.publicStaticDouble = -1.0/0.0;");
+ assertEquals(Double.doubleToLongBits(Double.NEGATIVE_INFINITY), Double.doubleToLongBits(SharedObject.publicStaticDouble));
+ }
+
+ @Test
+ public void accessFinalFieldDoubleBoxing() throws ScriptException {
+ e.eval("var pf_double = o.publicFinalDoubleBox;");
+ assertEquals(o.publicFinalDoubleBox, e.get("pf_double"));
+ e.eval("o.publicFinalDoubleBox = 30.0;");
+ assertEquals(Double.doubleToLongBits(1.412e-12), Double.doubleToLongBits(o.publicFinalDoubleBox));
+ }
+
+ @Test
+ public void accessStaticFinalFieldDoubleBoxing() throws ScriptException {
+ e.eval("var psf_double = SharedObject.publicStaticFinalDouble;");
+ assertEquals(SharedObject.publicStaticFinalDouble, e.get("psf_double"));
+ e.eval("SharedObject.publicStaticFinalDouble = 40.0;");
+ assertEquals(Double.doubleToLongBits(1.8e12), Double.doubleToLongBits(SharedObject.publicStaticFinalDouble));
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/api/javaaccess/test/ObjectAccessTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,165 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.javaaccess.test;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import org.testng.TestNG;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * @test
+ * @build jdk.nashorn.api.javaaccess.test.SharedObject jdk.nashorn.api.javaaccess.test.Person jdk.nashorn.api.javaaccess.test.ObjectAccessTest
+ * @run testng/othervm jdk.nashorn.api.javaaccess.test.ObjectAccessTest
+ */
+@SuppressWarnings("javadoc")
+public class ObjectAccessTest {
+
+ private static ScriptEngine e = null;
+ private static SharedObject o = null;
+
+ public static void main(final String[] args) {
+ TestNG.main(args);
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws ScriptException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ e = m.getEngineByName("nashorn");
+ o = new SharedObject();
+ e.put("o", o);
+ e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.test.SharedObject;");
+ e.eval("var Person = Packages.jdk.nashorn.api.javaaccess.test.Person;");
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ e = null;
+ o = null;
+ }
+
+ @Test
+ public void accessFieldObject() throws ScriptException {
+ e.eval("var p_object = o.publicObject;");
+ assertEquals(o.publicObject, e.get("p_object"));
+ assertEquals("object", e.eval("typeof p_object;"));
+ e.eval("o.publicObject = new Person(14);");
+ assertEquals(new Person(14), o.publicObject);
+ }
+
+ @Test
+ public void accessFieldObjectArray() throws ScriptException {
+ e.eval("var p_object_array = o.publicObjectArray;");
+ assertEquals(o.publicObjectArray[0], e.eval("o.publicObjectArray[0]"));
+ assertArrayEquals(o.publicObjectArray, (Object[])e.get("p_object_array"));
+ e.eval("var t_object_arr = new (Java.type(\"jdk.nashorn.api.javaaccess.test.Person[]\"))(3);" +
+ "t_object_arr[0] = new Person(100);" +
+ "t_object_arr[1] = new Person(120);" +
+ "t_object_arr[2] = new Person(140);" +
+ "o.publicObjectArray = t_object_arr;");
+ assertArrayEquals(new Person[] { new Person(100), new Person(120), new Person(140) }, o.publicObjectArray);
+ e.eval("o.publicObjectArray[0] = new Person(10);");
+ assertEquals(new Person(10), o.publicObjectArray[0]);
+ }
+
+ @Test
+ public void accessStaticFieldObject() throws ScriptException {
+ e.eval("var ps_object = SharedObject.publicStaticObject;");
+ assertEquals(SharedObject.publicStaticObject, e.get("ps_object"));
+ assertEquals("object", e.eval("typeof ps_object;"));
+ e.eval("SharedObject.publicStaticObject = new Person(16);");
+ assertEquals(new Person(16), SharedObject.publicStaticObject);
+ }
+
+ @Test
+ public void accessStaticFieldObjectArray() throws ScriptException {
+ e.eval("var ps_object_array = SharedObject.publicStaticObjectArray;");
+ assertEquals(SharedObject.publicStaticObjectArray[0], e.eval("SharedObject.publicStaticObjectArray[0]"));
+ assertArrayEquals(SharedObject.publicStaticObjectArray, (Object[])e.get("ps_object_array"));
+ e.eval("var ts_object_arr = new (Java.type(\"jdk.nashorn.api.javaaccess.test.Person[]\"))(3);" +
+ "ts_object_arr[0] = new Person(100);" +
+ "ts_object_arr[1] = new Person(120);" +
+ "ts_object_arr[2] = new Person(140);" +
+ "SharedObject.publicStaticObjectArray = ts_object_arr;");
+ assertArrayEquals(new Person[] { new Person(100), new Person(120), new Person(140) }, SharedObject.publicStaticObjectArray);
+ e.eval("SharedObject.publicStaticObjectArray[0] = new Person(10);");
+ assertEquals(new Person(10), SharedObject.publicStaticObjectArray[0]);
+ }
+
+ @Test
+ public void accessFinalFieldObject() throws ScriptException {
+ e.eval("var pf_object = o.publicFinalObject;");
+ assertEquals(o.publicFinalObject, e.get("pf_object"));
+ assertEquals("object", e.eval("typeof pf_object;"));
+ e.eval("o.publicFinalObject = new Person(-999);");
+ assertEquals(new Person(1024), o.publicFinalObject);
+ }
+
+ @Test
+ public void accessFinalFieldObjectArray() throws ScriptException {
+ e.eval("var pf_object_array = o.publicFinalObjectArray;");
+ assertEquals(o.publicFinalObjectArray[0], e.eval("o.publicFinalObjectArray[0]"));
+ assertArrayEquals(o.publicFinalObjectArray, (Object[])e.get("pf_object_array"));
+ e.eval("var tf_object_arr = new (Java.type(\"jdk.nashorn.api.javaaccess.test.Person[]\"))(3);" +
+ "tf_object_arr[0] = new Person(100);" +
+ "tf_object_arr[1] = new Person(120);" +
+ "tf_object_arr[2] = new Person(140);" +
+ "o.publicOFinalbjectArray = tf_object_arr;");
+ assertArrayEquals(new Person[] { new Person(-900), new Person(1000), new Person(180) }, o.publicFinalObjectArray);
+ e.eval("o.publicFinalObjectArray[0] = new Person(10);");
+ assertEquals(new Person(10), o.publicFinalObjectArray[0]);
+ }
+
+ @Test
+ public void accessStaticFinalFieldObject() throws ScriptException {
+ e.eval("var psf_object = SharedObject.publicStaticFinalObject;");
+ assertEquals(SharedObject.publicStaticFinalObject, e.get("psf_object"));
+ assertEquals("object", e.eval("typeof psf_object;"));
+ e.eval("SharedObject.publicStaticFinalObject = new Person(6);");
+ assertEquals(new Person(2048), SharedObject.publicStaticFinalObject);
+ }
+
+ @Test
+ public void accessStaticFinalFieldObjectArray() throws ScriptException {
+ e.eval("var psf_object_array = SharedObject.publicStaticFinalObjectArray;");
+ assertEquals(SharedObject.publicStaticFinalObjectArray[0], e.eval("SharedObject.publicStaticFinalObjectArray[0]"));
+ assertArrayEquals(SharedObject.publicStaticFinalObjectArray, (Object[])e.get("psf_object_array"));
+ e.eval("var tsf_object_arr = new (Java.type(\"jdk.nashorn.api.javaaccess.test.Person[]\"))(3);" +
+ "tsf_object_arr[0] = new Person(100);" +
+ "tsf_object_arr[1] = new Person(120);" +
+ "tsf_object_arr[2] = new Person(140);" +
+ "SharedObject.publicStaticFinalObjectArray = tsf_object_arr;");
+ assertArrayEquals(new Person[] { new Person(-9), new Person(110), new Person(Integer.MAX_VALUE) }, SharedObject.publicStaticFinalObjectArray);
+ e.eval("SharedObject.publicStaticFinalObjectArray[0] = new Person(90);");
+ assertEquals(new Person(90), SharedObject.publicStaticFinalObjectArray[0]);
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/api/javaaccess/test/Person.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.javaaccess.test;
+
+@SuppressWarnings("javadoc")
+public class Person {
+
+ public int id = 0;
+
+ public Person() {
+ }
+
+ public Person(final int code) {
+ this.id = code;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj != null && obj instanceof Person) {
+ final Person o = (Person)obj;
+ return this.id == o.id;
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return id;
+ }
+
+ @Override
+ public String toString() {
+ return "Person(" + id + ")";
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/api/javaaccess/test/SharedObject.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,467 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.javaaccess.test;
+
+import javax.script.Invocable;
+import javax.script.ScriptEngine;
+import javax.script.ScriptException;
+
+@SuppressWarnings("javadoc")
+public class SharedObject {
+
+ // Public fields
+ public String publicString = "PublicString";
+ public String[] publicStringArray = { "ArrayString[0]", "ArrayString[1]", "ArrayString[2]", "ArrayString[3]" };
+ public Person publicObject = new Person(256);
+ public Person[] publicObjectArray = { new Person(4), new Person(-422), new Person(14) };
+ public boolean publicBoolean = true;
+ public boolean[] publicBooleanArray = { true, false, false, true };
+ public Boolean publicBooleanBox = true;
+ public long publicLong = 933333333333333333L;
+ public long[] publicLongArray = { 99012333333333L, -124355555L, 89777777777L };
+ public Long publicLongBox = 9333333333L;
+ public int publicInt = 2076543123;
+ public int[] publicIntArray = { 0, 1, 1, 2, 3, 5, 8, 13, 21, 34 };
+ public Integer publicIntBox = 20765123;
+ public byte publicByte = -128;
+ public byte[] publicByteArray = { 1, 2, 4, 8, 16, 32, 64, 127, -128 };
+ public Byte publicByteBox = 127;
+ public short publicShort = 32000;
+ public short[] publicShortArray = { 3240, 8900, -16789, 1, 12 };
+ public Short publicShortBox = Short.MIN_VALUE;
+ public float publicFloat = 0.7f;
+ public float[] publicFloatArray = { -32.01f, 89.3f, -1.3e8f, 3.1f };
+ public Float publicFloatBox = 1.377e4f;
+ public double publicDouble = 1.34e20;
+ public double[] publicDoubleArray = { 0.75e80, 8e-43, 1.000077, 0.123e10 };
+ public Double publicDoubleBox = 1.4e-19;
+ public char publicChar = 'A';
+ public char[] publicCharArray = "Hello Nashorn".toCharArray();
+ public Character publicCharBox = 'B';
+ // Public static fields
+ public static String publicStaticString = "PublicStaticString";
+ public static String[] publicStaticStringArray = { "StaticArrayString[0]", "StaticArrayString[1]", "StaticArrayString[2]", "StaticArrayString[3]" };
+ public static Person publicStaticObject = new Person(512);
+ public static Person[] publicStaticObjectArray = { new Person(40), new Person(-22), new Person(18) };
+ public static boolean publicStaticBoolean = true;
+ public static boolean[] publicStaticBooleanArray = { false, false, false, true };
+ public static Boolean publicStaticBooleanBox = true;
+ public static long publicStaticLong = 13333333333333333L;
+ public static long[] publicStaticLongArray = { 19012333333333L, -224355555L, 39777777777L };
+ public static Long publicStaticLongBox = 9333333334L;
+ public static int publicStaticInt = 207654323;
+ public static int[] publicStaticIntArray = { 5, 8, 13, 21, 34 };
+ public static Integer publicStaticIntBox = 2075123;
+ public static byte publicStaticByte = -12;
+ public static byte[] publicStaticByteArray = { 16, 32, 64, 127, -128 };
+ public static Byte publicStaticByteBox = 17;
+ public static short publicStaticShort = 320;
+ public static short[] publicStaticShortArray = { 1240, 900, -1789, 100, 12 };
+ public static Short publicStaticShortBox = -16777;
+ public static float publicStaticFloat = 7.7e8f;
+ public static float[] publicStaticFloatArray = { -131.01f, 189.3f, -31.3e8f, 3.7f };
+ public static Float publicStaticFloatBox = 1.37e4f;
+ public static double publicStaticDouble = 1.341e20;
+ public static double[] publicStaticDoubleArray = { 0.75e80, 0.123e10, 8e-43, 1.000077 };
+ public static Double publicStaticDoubleBox = 1.41e-12;
+ public static char publicStaticChar = 'C';
+ public static char[] publicStaticCharArray = "Nashorn".toCharArray();
+ public static Character publicStaticCharBox = 'D';
+ // Public final fields
+ public final String publicFinalString = "PublicFinalString";
+ public final String[] publicFinalStringArray = { "FinalArrayString[0]", "FinalArrayString[1]", "FinalArrayString[2]", "FinalArrayString[3]" };
+ public final Person publicFinalObject = new Person(1024);
+ public final Person[] publicFinalObjectArray = { new Person(-900), new Person(1000), new Person(180) };
+ public final boolean publicFinalBoolean = true;
+ public final boolean[] publicFinalBooleanArray = { false, false, true, false };
+ public final Boolean publicFinalBooleanBox = true;
+ public final long publicFinalLong = 13353333333333333L;
+ public final long[] publicFinalLongArray = { 1901733333333L, -2247355555L, 3977377777L };
+ public final Long publicFinalLongBox = 9377333334L;
+ public final int publicFinalInt = 20712023;
+ public final int[] publicFinalIntArray = { 50, 80, 130, 210, 340 };
+ public final Integer publicFinalIntBox = 207512301;
+ public final byte publicFinalByte = -7;
+ public final byte[] publicFinalByteArray = { 1, 3, 6, 17, -128 };
+ public final Byte publicFinalByteBox = 19;
+ public final short publicFinalShort = 31220;
+ public final short[] publicFinalShortArray = { 12240, 9200, -17289, 1200, 12 };
+ public final Short publicFinalShortBox = -26777;
+ public final float publicFinalFloat = 7.72e8f;
+ public final float[] publicFinalFloatArray = { -131.012f, 189.32f, -31.32e8f, 3.72f };
+ public final Float publicFinalFloatBox = 1.372e4f;
+ public final double publicFinalDouble = 1.3412e20;
+ public final double[] publicFinalDoubleArray = { 0.725e80, 0.12e10, 8e-3, 1.00077 };
+ public final Double publicFinalDoubleBox = 1.412e-12;
+ public final char publicFinalChar = 'E';
+ public final char[] publicFinalCharArray = "Nashorn hello".toCharArray();
+ public final Character publicFinalCharBox = 'F';
+ // Public static final fields
+ public static final String publicStaticFinalString = "PublicStaticFinalString";
+ public static final String[] publicStaticFinalStringArray = { "StaticFinalArrayString[0]", "StaticFinalArrayString[1]", "StaticFinalArrayString[2]", "StaticFinalArrayString[3]" };
+ public static final Person publicStaticFinalObject = new Person(2048);
+ public static final Person[] publicStaticFinalObjectArray = { new Person(-9), new Person(110), new Person(Integer.MAX_VALUE) };
+ public static final boolean publicStaticFinalBoolean = true;
+ public static final boolean[] publicStaticFinalBooleanArray = { false, true, false, false };
+ public static final Boolean publicStaticFinalBooleanBox = true;
+ public static final long publicStaticFinalLong = 8333333333333L;
+ public static final long[] publicStaticFinalLongArray = { 19017383333L, -2247358L, 39773787L };
+ public static final Long publicStaticFinalLongBox = 9377388334L;
+ public static final int publicStaticFinalInt = 207182023;
+ public static final int[] publicStaticFinalIntArray = { 1308, 210, 340 };
+ public static final Integer publicStaticFinalIntBox = 2078301;
+ public static final byte publicStaticFinalByte = -70;
+ public static final byte[] publicStaticFinalByteArray = { 17, -128, 81 };
+ public static final Byte publicStaticFinalByteBox = 91;
+ public static final short publicStaticFinalShort = 8888;
+ public static final short[] publicStaticFinalShortArray = { 8240, 9280, -1289, 120, 812 };
+ public static final Short publicStaticFinalShortBox = -26;
+ public static final float publicStaticFinalFloat = 0.72e8f;
+ public static final float[] publicStaticFinalFloatArray = { -8131.012f, 9.32f, -138.32e8f, 0.72f };
+ public static final Float publicStaticFinalFloatBox = 1.2e4f;
+ public static final double publicStaticFinalDouble = 1.8e12;
+ public static final double[] publicStaticFinalDoubleArray = { 8.725e80, 0.82e10, 18e-3, 1.08077 };
+ public static final Double publicStaticFinalDoubleBox = 1.5612e-13;
+ public static final char publicStaticFinalChar = 'K';
+ public static final char[] publicStaticFinalCharArray = "StaticString".toCharArray();
+ public static final Character publicStaticFinalCharBox = 'L';
+
+ // Special vars
+ public volatile boolean volatileBoolean = true;
+ public transient boolean transientBoolean = true;
+
+ // For methods testing
+ public boolean isAccessed = false;
+ public volatile boolean isFinished = false;
+
+ private ScriptEngine engine;
+
+ public ScriptEngine getEngine() {
+ return engine;
+ }
+
+ public void setEngine(final ScriptEngine engine) {
+ this.engine = engine;
+ }
+
+ public void voidMethod() {
+ isAccessed = true;
+ }
+
+ public boolean booleanMethod(final boolean arg) {
+ return !arg;
+ }
+
+ public Boolean booleanBoxingMethod(final Boolean arg) {
+ return !arg.booleanValue();
+ }
+
+ public boolean[] booleanArrayMethod(final boolean arg[]) {
+ final boolean[] res = new boolean[arg.length];
+ for (int i = 0; i < arg.length; i++) {
+ res[i] = !arg[i];
+ }
+ return res;
+ }
+
+ public int intMethod(final int arg) {
+ return arg + arg;
+ }
+
+ public Integer intBoxingMethod(final Integer arg) {
+ return arg + arg;
+ }
+
+ public int[] intArrayMethod(final int arg[]) {
+ final int[] res = new int[arg.length];
+ for (int i = 0; i < arg.length; i++) {
+ res[i] = arg[i] * 2;
+ }
+ return res;
+ }
+
+ public long longMethod(final long arg) {
+ return arg + arg;
+ }
+
+ public Long longBoxingMethod(final Long arg) {
+ return arg + arg;
+ }
+
+ public long[] longArrayMethod(final long[] arg) {
+ final long[] res = new long[arg.length];
+ for (int i = 0; i < arg.length; i++) {
+ res[i] = arg[i] * 2;
+ }
+ return res;
+ }
+
+ public byte byteMethod(final byte arg) {
+ return (byte)(arg + arg);
+ }
+
+ public Byte byteBoxingMethod(final Byte arg) {
+ return (byte)(arg + arg);
+ }
+
+ public byte[] byteArrayMethod(final byte[] arg) {
+ final byte[] res = new byte[arg.length];
+ for (int i = 0; i < arg.length; i++) {
+ res[i] = (byte)(arg[i] * 2);
+ }
+ return res;
+ }
+
+ public char charMethod(final char arg) {
+ return Character.toUpperCase(arg);
+ }
+
+ public Character charBoxingMethod(final Character arg) {
+ return Character.toUpperCase(arg);
+ }
+
+ public char[] charArrayMethod(final char[] arg) {
+ final char[] res = new char[arg.length];
+ for (int i = 0; i < arg.length; i++) {
+ res[i] = Character.toUpperCase(arg[i]);
+ }
+ return res;
+ }
+
+ public short shortMethod(final short arg) {
+ return (short)(arg + arg);
+ }
+
+ public Short shortBoxingMethod(final Short arg) {
+ return (short)(arg + arg);
+ }
+
+ public short[] shortArrayMethod(final short[] arg) {
+ final short[] res = new short[arg.length];
+ for (int i = 0; i < arg.length; i++) {
+ res[i] = (short)(arg[i] * 2);
+ }
+ return res;
+ }
+
+ public float floatMethod(final float arg) {
+ return arg + arg;
+ }
+
+ public Float floatBoxingMethod(final Float arg) {
+ return arg + arg;
+ }
+
+ public float[] floatArrayMethod(final float[] arg) {
+ final float[] res = new float[arg.length];
+ for (int i = 0; i < arg.length; i++) {
+ res[i] = arg[i] * 2;
+ }
+ return res;
+ }
+
+ public double doubleMethod(final double arg) {
+ return arg + arg;
+ }
+
+ public Double doubleBoxingMethod(final Double arg) {
+ return arg + arg;
+ }
+
+ public double[] doubleArrayMethod(final double[] arg) {
+ final double[] res = new double[arg.length];
+ for (int i = 0; i < arg.length; i++) {
+ res[i] = arg[i] * 2;
+ }
+ return res;
+ }
+
+ public String stringMethod(final String str) {
+ return str + str;
+ }
+
+ public String[] stringArrayMethod(final String[] arr) {
+ final int l = arr.length;
+ final String[] res = new String[l];
+ for (int i = 0; i < l; i++) {
+ res[i] = arr[l - i - 1];
+ }
+ return res;
+ }
+
+ public Person[] objectArrayMethod(final Person[] arr) {
+ final Person[] res = new Person[arr.length];
+ for (int i = 0; i < arr.length; i++) {
+ res[i] = new Person(i + 100);
+ }
+ return res;
+ }
+
+ public Person objectMethod(final Person t) {
+ t.id *= 2;
+ return t;
+ }
+
+ public int twoParamMethod(final long l, final double d) {
+ return (int)(l + d);
+ }
+
+ public int threeParamMethod(final short s, final long l, final char c) {
+ return (int)(s + l + c);
+ }
+
+ public Person[] twoObjectParamMethod(final Person arg1, final Person arg2) {
+ return new Person[] { arg2, arg1 };
+ }
+
+ public Person[] threeObjectParamMethod(final Person arg1, final Person arg2, final Person arg3) {
+ return new Person[] { arg3, arg2, arg1 };
+ }
+
+ public Person[] eightObjectParamMethod(final Person arg1, final Person arg2, final Person arg3, final Person arg4, final Person arg5, final Person arg6, final Person arg7, final Person arg8) {
+ return new Person[] { arg8, arg7, arg6, arg5, arg4, arg3, arg2, arg1 };
+ }
+
+ public Person[] nineObjectParamMethod(final Person arg1, final Person arg2, final Person arg3, final Person arg4, final Person arg5, final Person arg6, final Person arg7, final Person arg8, final Person arg9) {
+ return new Person[] { arg9, arg8, arg7, arg6, arg5, arg4, arg3, arg2, arg1 };
+ }
+
+ public Person[] methodObjectEllipsis(final Person... args) {
+ final int l = args.length;
+ final Person[] res = new Person[l];
+ for (int i = 0; i < l; i++) {
+ res[i] = args[l - i - 1];
+ }
+ return res;
+ }
+
+ public Person[] methodPrimitiveEllipsis(final int... args) {
+ final int l = args.length;
+ final Person[] res = new Person[l];
+ for (int i = 0; i < l; i++) {
+ res[i] = new Person(args[i]);
+ }
+ return res;
+ }
+
+ public Object[] methodMixedEllipsis(final Object... args) {
+ return args;
+ }
+
+ public Object[] methodObjectWithEllipsis(final String arg, final int... args) {
+ final Object[] res = new Object[args.length + 1];
+ res[0] = arg;
+ for (int i = 0; i < args.length; i++) {
+ res[i + 1] = args[i];
+ }
+ return res;
+ }
+
+ public Object[] methodPrimitiveWithEllipsis(final int arg, final long... args) {
+ final Object[] res = new Object[args.length + 1];
+ res[0] = arg;
+ for (int i = 0; i < args.length; i++) {
+ res[i + 1] = args[i];
+ }
+ return res;
+ }
+
+ public Object[] methodMixedWithEllipsis(final String arg1, final int arg2, final Object... args) {
+ final Object[] res = new Object[args.length + 2];
+ res[0] = arg1;
+ res[1] = arg2;
+ System.arraycopy(args, 0, res, 2, args.length);
+ return res;
+ }
+
+ public void methodStartsThread() {
+ isFinished = false;
+
+ final Thread t = new Thread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ Thread.sleep(1000);
+ isFinished = true;
+ } catch (final InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ });
+
+ t.start();
+ }
+
+ public String overloadedMethodDoubleVSint(final int arg) {
+ return "int";
+ }
+
+ public String overloadedMethodDoubleVSint(final double arg) {
+ return "double";
+ }
+
+ public int overloadedMethod(final int arg) {
+ return arg*2;
+ }
+
+ public int overloadedMethod(final String arg) {
+ return arg.length();
+ }
+
+ public int overloadedMethod(final boolean arg) {
+ return (arg) ? 1 : 0;
+ }
+
+ public int overloadedMethod(final Person arg) {
+ return arg.id*2;
+ }
+
+ public int firstLevelMethodInt(final int arg) throws ScriptException, NoSuchMethodException {
+ return (int) ((Invocable)engine).invokeFunction("secondLevelMethodInt", arg);
+ }
+
+ public int thirdLevelMethodInt(final int arg) {
+ return arg*5;
+ }
+
+ public int firstLevelMethodInteger(final Integer arg) throws ScriptException, NoSuchMethodException {
+ return (int) ((Invocable)engine).invokeFunction("secondLevelMethodInteger", arg);
+ }
+
+ public int thirdLevelMethodInteger(final Integer arg) {
+ return arg*10;
+ }
+
+ public Person firstLevelMethodObject(final Person p) throws ScriptException, NoSuchMethodException {
+ return (Person) ((Invocable)engine).invokeFunction("secondLevelMethodObject", p);
+ }
+
+ public Person thirdLevelMethodObject(final Person p) {
+ p.id *= 10;
+ return p;
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/api/javaaccess/test/StringAccessTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.javaaccess.test;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import org.testng.TestNG;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * @test
+ * @build jdk.nashorn.api.javaaccess.test.SharedObject jdk.nashorn.api.javaaccess.test.Person jdk.nashorn.api.javaaccess.test.StringAccessTest
+ * @run testng/othervm jdk.nashorn.api.javaaccess.test.StringAccessTest
+ */
+@SuppressWarnings("javadoc")
+public class StringAccessTest {
+
+ private static ScriptEngine e = null;
+ private static SharedObject o = null;
+
+ public static void main(final String[] args) {
+ TestNG.main(args);
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws ScriptException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ e = m.getEngineByName("nashorn");
+ o = new SharedObject();
+ e.put("o", o);
+ e.eval("var SharedObject = Packages.jdk.nashorn.api.javaaccess.test.SharedObject;");
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ e = null;
+ o = null;
+ }
+
+ @Test
+ public void accessFieldString() throws ScriptException {
+ e.eval("var p_string = o.publicString;");
+ assertEquals(o.publicString, e.get("p_string"));
+ assertEquals("string", e.eval("typeof p_string;"));
+ e.eval("o.publicString = 'changedString';");
+ assertEquals("changedString", o.publicString);
+ }
+
+ @Test
+ public void accessFieldStringArray() throws ScriptException {
+ e.eval("var p_string_array = o.publicStringArray;");
+ assertEquals(o.publicStringArray[0], e.eval("o.publicStringArray[0]"));
+ assertArrayEquals(o.publicStringArray, (String[])e.get("p_string_array"));
+ e.eval("var t_string_arr = new (Java.type(\"java.lang.String[]\"))(3);" +
+ "t_string_arr[0] = 'abc';" +
+ "t_string_arr[1] = '123';" +
+ "t_string_arr[2] = 'xyzzzz';" +
+ "o.publicStringArray = t_string_arr;");
+ assertArrayEquals(new String[] { "abc", "123", "xyzzzz" }, o.publicStringArray);
+ e.eval("o.publicStringArray[0] = 'nashorn';");
+ assertEquals("nashorn", o.publicStringArray[0]);
+ }
+
+ @Test
+ public void accessStaticFieldString() throws ScriptException {
+ e.eval("var ps_string = SharedObject.publicStaticString;");
+ assertEquals(SharedObject.publicStaticString, e.get("ps_string"));
+ assertEquals("string", e.eval("typeof ps_string;"));
+ e.eval("SharedObject.publicStaticString = 'changedString';");
+ assertEquals("changedString", SharedObject.publicStaticString);
+ }
+
+ @Test
+ public void accessStaticFieldStringArray() throws ScriptException {
+ e.eval("var ps_string_array = SharedObject.publicStaticStringArray;");
+ assertEquals(SharedObject.publicStaticStringArray[0], e.eval("SharedObject.publicStaticStringArray[0]"));
+ assertArrayEquals(SharedObject.publicStaticStringArray, (String[])e.get("ps_string_array"));
+ e.eval("var ts_string_arr = new (Java.type(\"java.lang.String[]\"))(3);" +
+ "ts_string_arr[0] = 'abc';" +
+ "ts_string_arr[1] = '123';" +
+ "ts_string_arr[2] = 'xyzzzz';" +
+ "SharedObject.publicStaticStringArray = ts_string_arr;");
+ assertArrayEquals(new String[] { "abc", "123", "xyzzzz" }, SharedObject.publicStaticStringArray);
+ e.eval("SharedObject.publicStaticStringArray[0] = 'nashorn';");
+ assertEquals("nashorn", SharedObject.publicStaticStringArray[0]);
+ }
+
+ @Test
+ public void accessFinalFieldString() throws ScriptException {
+ e.eval("var pf_string = o.publicFinalString;");
+ assertEquals(o.publicFinalString, e.get("pf_string"));
+ assertEquals("string", e.eval("typeof pf_string;"));
+ e.eval("o.publicFinalString = 'changedString';");
+ assertEquals("PublicFinalString", o.publicFinalString);
+ }
+
+ @Test
+ public void accessFinalFieldStringArray() throws ScriptException {
+ e.eval("var pf_string_array = o.publicFinalStringArray;");
+ assertEquals(o.publicFinalStringArray[0], e.eval("o.publicFinalStringArray[0]"));
+ assertArrayEquals(o.publicFinalStringArray, (String[])e.get("pf_string_array"));
+ e.eval("var tf_string_arr = new (Java.type(\"java.lang.String[]\"))(3);" +
+ "tf_string_arr[0] = 'abc';" +
+ "tf_string_arr[1] = '123';" +
+ "tf_string_arr[2] = 'xyzzzz';" +
+ "o.publicFinalStringArray = tf_string_arr;");
+ assertArrayEquals(new String[] { "FinalArrayString[0]", "FinalArrayString[1]", "FinalArrayString[2]", "FinalArrayString[3]" }, o.publicFinalStringArray);
+ e.eval("o.publicFinalStringArray[0] = 'nashorn';");
+ assertEquals("nashorn", o.publicFinalStringArray[0]);
+ }
+
+ @Test
+ public void accessStaticFinalFieldString() throws ScriptException {
+ e.eval("var psf_string = SharedObject.publicStaticFinalString;");
+ assertEquals(SharedObject.publicStaticFinalString, e.get("psf_string"));
+ assertEquals("string", e.eval("typeof psf_string;"));
+ e.eval("SharedObject.publicStaticFinalString = 'changedString';");
+ assertEquals("PublicStaticFinalString", SharedObject.publicStaticFinalString);
+ }
+
+ @Test
+ public void accessStaticFinalFieldStringArray() throws ScriptException {
+ e.eval("var psf_string_array = SharedObject.publicStaticFinalStringArray;");
+ assertEquals(SharedObject.publicStaticFinalStringArray[0], e.eval("SharedObject.publicStaticFinalStringArray[0]"));
+ assertArrayEquals(SharedObject.publicStaticFinalStringArray, (String[])e.get("psf_string_array"));
+ e.eval("var tsf_string_arr = new (Java.type(\"java.lang.String[]\"))(3);" +
+ "tsf_string_arr[0] = 'abc';" +
+ "tsf_string_arr[1] = '123';" +
+ "tsf_string_arr[2] = 'xyzzzz';" +
+ "SharedObject.publicStaticFinalStringArray = tsf_string_arr;");
+ assertArrayEquals(new String[] { "StaticFinalArrayString[0]",
+ "StaticFinalArrayString[1]",
+ "StaticFinalArrayString[2]",
+ "StaticFinalArrayString[3]" },
+ SharedObject.publicStaticFinalStringArray);
+ e.eval("SharedObject.publicStaticFinalStringArray[0] = 'nashorn';");
+ assertEquals("nashorn", SharedObject.publicStaticFinalStringArray[0]);
+ }
+
+}
--- a/nashorn/test/src/jdk/nashorn/api/scripting/InvocableTest.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,539 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.scripting;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.fail;
-import java.util.Objects;
-import java.util.function.Function;
-import javax.script.Invocable;
-import javax.script.ScriptContext;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
-import javax.script.ScriptException;
-import javax.script.SimpleScriptContext;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-/**
- * Tests for javax.script.Invocable implementation of nashorn.
- */
-@SuppressWarnings("javadoc")
-public class InvocableTest {
-
- private static void log(final String msg) {
- org.testng.Reporter.log(msg, true);
- }
-
- @Test
- public void invokeMethodTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
-
- try {
- e.eval("var Example = function() { this.hello = function() { return 'Hello World!'; };}; myExample = new Example();");
- final Object obj = e.get("myExample");
- final Object res = ((Invocable) e).invokeMethod(obj, "hello");
- assertEquals(res, "Hello World!");
- } catch (final Exception exp) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
-
- @Test
- /**
- * Check that we can call invokeMethod on an object that we got by
- * evaluating script with different Context set.
- */
- public void invokeMethodDifferentContextTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
-
- try {
- // define an object with method on it
- final Object obj = e.eval("({ hello: function() { return 'Hello World!'; } })");
-
- final ScriptContext ctxt = new SimpleScriptContext();
- ctxt.setBindings(e.createBindings(), ScriptContext.ENGINE_SCOPE);
- e.setContext(ctxt);
-
- // invoke 'func' on obj - but with current script context changed
- final Object res = ((Invocable) e).invokeMethod(obj, "hello");
- assertEquals(res, "Hello World!");
- } catch (final Exception exp) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
-
- @Test
- /**
- * Check that invokeMethod throws NPE on null method name.
- */
- public void invokeMethodNullNameTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
-
- try {
- final Object obj = e.eval("({})");
- ((Invocable) e).invokeMethod(obj, null);
- fail("should have thrown NPE");
- } catch (final Exception exp) {
- if (!(exp instanceof NullPointerException)) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
- }
-
- @Test
- /**
- * Check that invokeMethod throws NoSuchMethodException on missing method.
- */
- public void invokeMethodMissingTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
-
- try {
- final Object obj = e.eval("({})");
- ((Invocable) e).invokeMethod(obj, "nonExistentMethod");
- fail("should have thrown NoSuchMethodException");
- } catch (final Exception exp) {
- if (!(exp instanceof NoSuchMethodException)) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
- }
-
- @Test
- /**
- * Check that calling method on non-script object 'thiz' results in
- * IllegalArgumentException.
- */
- public void invokeMethodNonScriptObjectThizTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
-
- try {
- ((Invocable) e).invokeMethod(new Object(), "toString");
- fail("should have thrown IllegalArgumentException");
- } catch (final Exception exp) {
- if (!(exp instanceof IllegalArgumentException)) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
- }
-
- @Test
- /**
- * Check that calling method on null 'thiz' results in
- * IllegalArgumentException.
- */
- public void invokeMethodNullThizTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
-
- try {
- ((Invocable) e).invokeMethod(null, "toString");
- fail("should have thrown IllegalArgumentException");
- } catch (final Exception exp) {
- if (!(exp instanceof IllegalArgumentException)) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
- }
-
- @Test
- /**
- * Check that calling method on mirror created by another engine results in
- * IllegalArgumentException.
- */
- public void invokeMethodMixEnginesTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine engine1 = m.getEngineByName("nashorn");
- final ScriptEngine engine2 = m.getEngineByName("nashorn");
-
- try {
- final Object obj = engine1.eval("({ run: function() {} })");
- // pass object from engine1 to engine2 as 'thiz' for invokeMethod
- ((Invocable) engine2).invokeMethod(obj, "run");
- fail("should have thrown IllegalArgumentException");
- } catch (final Exception exp) {
- if (!(exp instanceof IllegalArgumentException)) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
- }
-
- @Test
- public void getInterfaceTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- final Invocable inv = (Invocable) e;
-
- // try to get interface from global functions
- try {
- e.eval("function run() { print('run'); };");
- final Runnable runnable = inv.getInterface(Runnable.class);
- runnable.run();
- } catch (final Exception exp) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
-
- // try interface on specific script object
- try {
- e.eval("var obj = { run: function() { print('run from obj'); } };");
- final Object obj = e.get("obj");
- final Runnable runnable = inv.getInterface(obj, Runnable.class);
- runnable.run();
- } catch (final Exception exp) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
-
- public interface Foo {
-
- public void bar();
- }
-
- public interface Foo2 extends Foo {
-
- public void bar2();
- }
-
- @Test
- public void getInterfaceMissingTest() {
- final ScriptEngineManager manager = new ScriptEngineManager();
- final ScriptEngine engine = manager.getEngineByName("nashorn");
-
- // don't define any function.
- try {
- engine.eval("");
- } catch (final Exception exp) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
-
- Runnable runnable = ((Invocable) engine).getInterface(Runnable.class);
- if (runnable != null) {
- fail("runnable is not null!");
- }
-
- // now define "run"
- try {
- engine.eval("function run() { print('this is run function'); }");
- } catch (final Exception exp) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- runnable = ((Invocable) engine).getInterface(Runnable.class);
- // should not return null now!
- runnable.run();
-
- // define only one method of "Foo2"
- try {
- engine.eval("function bar() { print('bar function'); }");
- } catch (final Exception exp) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
-
- Foo2 foo2 = ((Invocable) engine).getInterface(Foo2.class);
- if (foo2 != null) {
- throw new RuntimeException("foo2 is not null!");
- }
-
- // now define other method of "Foo2"
- try {
- engine.eval("function bar2() { print('bar2 function'); }");
- } catch (final Exception exp) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- foo2 = ((Invocable) engine).getInterface(Foo2.class);
- foo2.bar();
- foo2.bar2();
- }
-
- @Test
- /**
- * Try passing non-interface Class object for interface implementation.
- */
- public void getNonInterfaceGetInterfaceTest() {
- final ScriptEngineManager manager = new ScriptEngineManager();
- final ScriptEngine engine = manager.getEngineByName("nashorn");
- try {
- log(Objects.toString(((Invocable) engine).getInterface(Object.class)));
- fail("Should have thrown IllegalArgumentException");
- } catch (final Exception exp) {
- if (!(exp instanceof IllegalArgumentException)) {
- fail("IllegalArgumentException expected, got " + exp);
- }
- }
- }
-
- @Test
- /**
- * Check that we can get interface out of a script object even after
- * switching to use different ScriptContext.
- */
- public void getInterfaceDifferentContext() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- try {
- final Object obj = e.eval("({ run: function() { } })");
-
- // change script context
- final ScriptContext ctxt = new SimpleScriptContext();
- ctxt.setBindings(e.createBindings(), ScriptContext.ENGINE_SCOPE);
- e.setContext(ctxt);
-
- final Runnable r = ((Invocable) e).getInterface(obj, Runnable.class);
- r.run();
- } catch (final Exception exp) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
-
- @Test
- /**
- * Check that getInterface on non-script object 'thiz' results in
- * IllegalArgumentException.
- */
- public void getInterfaceNonScriptObjectThizTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
-
- try {
- ((Invocable) e).getInterface(new Object(), Runnable.class);
- fail("should have thrown IllegalArgumentException");
- } catch (final Exception exp) {
- if (!(exp instanceof IllegalArgumentException)) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
- }
-
- @Test
- /**
- * Check that getInterface on null 'thiz' results in
- * IllegalArgumentException.
- */
- public void getInterfaceNullThizTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
-
- try {
- ((Invocable) e).getInterface(null, Runnable.class);
- fail("should have thrown IllegalArgumentException");
- } catch (final Exception exp) {
- if (!(exp instanceof IllegalArgumentException)) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
- }
-
- @Test
- /**
- * Check that calling getInterface on mirror created by another engine
- * results in IllegalArgumentException.
- */
- public void getInterfaceMixEnginesTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine engine1 = m.getEngineByName("nashorn");
- final ScriptEngine engine2 = m.getEngineByName("nashorn");
-
- try {
- final Object obj = engine1.eval("({ run: function() {} })");
- // pass object from engine1 to engine2 as 'thiz' for getInterface
- ((Invocable) engine2).getInterface(obj, Runnable.class);
- fail("should have thrown IllegalArgumentException");
- } catch (final Exception exp) {
- if (!(exp instanceof IllegalArgumentException)) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
- }
-
- @Test
- /**
- * check that null function name results in NPE.
- */
- public void invokeFunctionNullNameTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
-
- try {
- ((Invocable)e).invokeFunction(null);
- fail("should have thrown NPE");
- } catch (final Exception exp) {
- if (!(exp instanceof NullPointerException)) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
- }
-
- @Test
- /**
- * Check that attempt to call missing function results in
- * NoSuchMethodException.
- */
- public void invokeFunctionMissingTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
-
- try {
- ((Invocable)e).invokeFunction("NonExistentFunc");
- fail("should have thrown NoSuchMethodException");
- } catch (final Exception exp) {
- if (!(exp instanceof NoSuchMethodException)) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
- }
-
- @Test
- /**
- * Check that invokeFunction calls functions only from current context's
- * Bindings.
- */
- public void invokeFunctionDifferentContextTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
-
- try {
- // define an object with method on it
- e.eval("function hello() { return 'Hello World!'; }");
- final ScriptContext ctxt = new SimpleScriptContext();
- ctxt.setBindings(e.createBindings(), ScriptContext.ENGINE_SCOPE);
- // change engine's current context
- e.setContext(ctxt);
-
- ((Invocable) e).invokeFunction("hello"); // no 'hello' in new context!
- fail("should have thrown NoSuchMethodException");
- } catch (final Exception exp) {
- if (!(exp instanceof NoSuchMethodException)) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
- }
-
- @Test
- public void invokeFunctionExceptionTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- try {
- e.eval("function func() { throw new TypeError(); }");
- } catch (final Throwable t) {
- t.printStackTrace();
- fail(t.getMessage());
- }
-
- try {
- ((Invocable) e).invokeFunction("func");
- fail("should have thrown exception");
- } catch (final ScriptException se) {
- // ECMA TypeError property wrapped as a ScriptException
- log("got " + se + " as expected");
- } catch (final Throwable t) {
- t.printStackTrace();
- fail(t.getMessage());
- }
- }
-
- @Test
- public void invokeMethodExceptionTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- try {
- e.eval("var sobj = {}; sobj.foo = function func() { throw new TypeError(); }");
- } catch (final Throwable t) {
- t.printStackTrace();
- fail(t.getMessage());
- }
-
- try {
- final Object sobj = e.get("sobj");
- ((Invocable) e).invokeMethod(sobj, "foo");
- fail("should have thrown exception");
- } catch (final ScriptException se) {
- // ECMA TypeError property wrapped as a ScriptException
- log("got " + se + " as expected");
- } catch (final Throwable t) {
- t.printStackTrace();
- fail(t.getMessage());
- }
- }
-
- @Test
- /**
- * Tests whether invocation of a JavaScript method through a variable arity
- * Java method will pass the vararg array. Both non-vararg and vararg
- * JavaScript methods are tested.
- *
- * @throws ScriptException
- */
- public void variableArityInterfaceTest() throws ScriptException {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- e.eval(
- "function test1(i, strings) {"
- + " return 'i == ' + i + ', strings instanceof java.lang.String[] == ' + (strings instanceof Java.type('java.lang.String[]')) + ', strings == ' + java.util.Arrays.toString(strings)"
- + "}"
- + "function test2() {"
- + " return 'arguments[0] == ' + arguments[0] + ', arguments[1] instanceof java.lang.String[] == ' + (arguments[1] instanceof Java.type('java.lang.String[]')) + ', arguments[1] == ' + java.util.Arrays.toString(arguments[1])"
- + "}");
- final VariableArityTestInterface itf = ((Invocable) e).getInterface(VariableArityTestInterface.class);
- Assert.assertEquals(itf.test1(42, "a", "b"), "i == 42, strings instanceof java.lang.String[] == true, strings == [a, b]");
- Assert.assertEquals(itf.test2(44, "c", "d", "e"), "arguments[0] == 44, arguments[1] instanceof java.lang.String[] == true, arguments[1] == [c, d, e]");
- }
-
- @Test
- public void defaultMethodTest() throws ScriptException {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- final Invocable inv = (Invocable) e;
-
- final Object obj = e.eval("({ apply: function(arg) { return arg.toUpperCase(); }})");
- @SuppressWarnings("unchecked")
- final Function<String, String> func = inv.getInterface(obj, Function.class);
- assertEquals(func.apply("hello"), "HELLO");
- }
-}
--- a/nashorn/test/src/jdk/nashorn/api/scripting/MultipleEngineTest.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.scripting;
-
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
-import javax.script.ScriptException;
-import org.testng.annotations.Test;
-
-/**
- * Test that we can create multiple, independent script engines and use those
- * independently.
- *
- * @test
- * @run testng jdk.nashorn.api.scripting.MultipleEngineTest
- */
-@SuppressWarnings("javadoc")
-public class MultipleEngineTest {
- @Test
- public void createAndUseManyEngine() throws ScriptException {
- final ScriptEngineManager m = new ScriptEngineManager();
-
- final ScriptEngine e1 = m.getEngineByName("nashorn");
- e1.eval("var x = 33; print(x);");
-
- final ScriptEngine e2 = m.getEngineByName("nashorn");
- e2.eval("try { print(x) } catch(e) { print(e); }");
- }
-}
--- a/nashorn/test/src/jdk/nashorn/api/scripting/PluggableJSObjectTest.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,288 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.scripting;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.fail;
-
-import java.nio.IntBuffer;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Set;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
-import org.testng.annotations.Test;
-
-/**
- * Tests for pluggable external impls. of jdk.nashorn.api.scripting.JSObject.
- *
- * JDK-8024615: Refactor ScriptObjectMirror and JSObject to support external
- * JSObject implementations.
- */
-@SuppressWarnings("javadoc")
-public class PluggableJSObjectTest {
- public static class MapWrapperObject extends AbstractJSObject {
- private final HashMap<String, Object> map = new LinkedHashMap<>();
-
- public HashMap<String, Object> getMap() {
- return map;
- }
-
- @Override
- public Object getMember(final String name) {
- return map.get(name);
- }
-
- @Override
- public void setMember(final String name, final Object value) {
- map.put(name, value);
- }
-
- @Override
- public boolean hasMember(final String name) {
- return map.containsKey(name);
- }
-
- @Override
- public void removeMember(final String name) {
- map.remove(name);
- }
-
- @Override
- public Set<String> keySet() {
- return map.keySet();
- }
-
- @Override
- public Collection<Object> values() {
- return map.values();
- }
- }
-
- @Test
- // Named property access on a JSObject
- public void namedAccessTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- try {
- final MapWrapperObject obj = new MapWrapperObject();
- e.put("obj", obj);
- obj.getMap().put("foo", "bar");
-
- // property-like access on MapWrapperObject objects
- assertEquals(e.eval("obj.foo"), "bar");
- e.eval("obj.foo = 'hello'");
- assertEquals(e.eval("'foo' in obj"), Boolean.TRUE);
- assertEquals(e.eval("obj.foo"), "hello");
- assertEquals(obj.getMap().get("foo"), "hello");
- e.eval("delete obj.foo");
- assertFalse(obj.getMap().containsKey("foo"));
- assertEquals(e.eval("'foo' in obj"), Boolean.FALSE);
- } catch (final Exception exp) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
-
- // @bug 8062030: Nashorn bug retrieving array property after key string concatenation
- @Test
- // ConsString attribute access on a JSObject
- public void consStringTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- try {
- final MapWrapperObject obj = new MapWrapperObject();
- e.put("obj", obj);
- e.put("f", "f");
- e.eval("obj[f + 'oo'] = 'bar';");
-
- assertEquals(obj.getMap().get("foo"), "bar");
- assertEquals(e.eval("obj[f + 'oo']"), "bar");
- assertEquals(e.eval("obj['foo']"), "bar");
- assertEquals(e.eval("f + 'oo' in obj"), Boolean.TRUE);
- assertEquals(e.eval("'foo' in obj"), Boolean.TRUE);
- e.eval("delete obj[f + 'oo']");
- assertFalse(obj.getMap().containsKey("foo"));
- assertEquals(e.eval("obj[f + 'oo']"), null);
- assertEquals(e.eval("obj['foo']"), null);
- assertEquals(e.eval("f + 'oo' in obj"), Boolean.FALSE);
- assertEquals(e.eval("'foo' in obj"), Boolean.FALSE);
- } catch (final Exception exp) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
-
- public static class BufferObject extends AbstractJSObject {
- private final IntBuffer buf;
-
- public BufferObject(final int size) {
- buf = IntBuffer.allocate(size);
- }
-
- public IntBuffer getBuffer() {
- return buf;
- }
-
- @Override
- public Object getMember(final String name) {
- return name.equals("length")? buf.capacity() : null;
- }
-
- @Override
- public boolean hasSlot(final int i) {
- return i > -1 && i < buf.capacity();
- }
-
- @Override
- public Object getSlot(final int i) {
- return buf.get(i);
- }
-
- @Override
- public void setSlot(final int i, final Object value) {
- buf.put(i, ((Number)value).intValue());
- }
-
- @Override
- public boolean isArray() {
- return true;
- }
- }
-
- @Test
- // array-like indexed access for a JSObject
- public void indexedAccessTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- try {
- final BufferObject buf = new BufferObject(2);
- e.put("buf", buf);
-
- // array-like access on BufferObject objects
- assertEquals(e.eval("buf.length"), buf.getBuffer().capacity());
- e.eval("buf[0] = 23");
- assertEquals(buf.getBuffer().get(0), 23);
- assertEquals(e.eval("buf[0]"), 23);
- assertEquals(e.eval("buf[1]"), 0);
- buf.getBuffer().put(1, 42);
- assertEquals(e.eval("buf[1]"), 42);
- assertEquals(e.eval("Array.isArray(buf)"), Boolean.TRUE);
- } catch (final Exception exp) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
-
- public static class Adder extends AbstractJSObject {
- @Override
- public Object call(final Object thiz, final Object... args) {
- double res = 0.0;
- for (final Object arg : args) {
- res += ((Number)arg).doubleValue();
- }
- return res;
- }
-
- @Override
- public boolean isFunction() {
- return true;
- }
- }
-
- @Test
- // a callable JSObject
- public void callableJSObjectTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- try {
- e.put("sum", new Adder());
- // check callability of Adder objects
- assertEquals(e.eval("typeof sum"), "function");
- assertEquals(((Number)e.eval("sum(1, 2, 3, 4, 5)")).intValue(), 15);
- } catch (final Exception exp) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
-
- public static class Factory extends AbstractJSObject {
- @SuppressWarnings("unused")
- @Override
- public Object newObject(final Object... args) {
- return new HashMap<Object, Object>();
- }
-
- @Override
- public boolean isFunction() {
- return true;
- }
- }
-
- @Test
- // a factory JSObject
- public void factoryJSObjectTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- try {
- e.put("Factory", new Factory());
-
- // check new on Factory
- assertEquals(e.eval("typeof Factory"), "function");
- assertEquals(e.eval("typeof new Factory()"), "object");
- assertEquals(e.eval("(new Factory()) instanceof java.util.Map"), Boolean.TRUE);
- } catch (final Exception exp) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
-
- @Test
- // iteration tests
- public void iteratingJSObjectTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- try {
- final MapWrapperObject obj = new MapWrapperObject();
- obj.setMember("foo", "hello");
- obj.setMember("bar", "world");
- e.put("obj", obj);
-
- // check for..in
- Object val = e.eval("var str = ''; for (i in obj) str += i; str");
- assertEquals(val.toString(), "foobar");
-
- // check for..each..in
- val = e.eval("var str = ''; for each (i in obj) str += i; str");
- assertEquals(val.toString(), "helloworld");
- } catch (final Exception exp) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
-}
--- a/nashorn/test/src/jdk/nashorn/api/scripting/ScopeTest.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,779 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package jdk.nashorn.api.scripting;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
-import javax.script.Bindings;
-import javax.script.ScriptContext;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
-import javax.script.ScriptException;
-import javax.script.SimpleBindings;
-import javax.script.SimpleScriptContext;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-/**
- * Tests for jsr223 Bindings "scope" (engine, global scopes)
- */
-@SuppressWarnings("javadoc")
-public class ScopeTest {
-
- @Test
- public void createBindingsTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- final Bindings b = e.createBindings();
- b.put("foo", 42.0);
- Object res = null;
- try {
- res = e.eval("foo == 42.0", b);
- } catch (final ScriptException | NullPointerException se) {
- se.printStackTrace();
- fail(se.getMessage());
- }
-
- assertEquals(res, Boolean.TRUE);
- }
-
- @Test
- public void engineScopeTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- final Bindings engineScope = e.getBindings(ScriptContext.ENGINE_SCOPE);
-
- // check few ECMA standard built-in global properties
- assertNotNull(engineScope.get("Object"));
- assertNotNull(engineScope.get("TypeError"));
- assertNotNull(engineScope.get("eval"));
-
- // can access via ScriptEngine.get as well
- assertNotNull(e.get("Object"));
- assertNotNull(e.get("TypeError"));
- assertNotNull(e.get("eval"));
-
- // Access by either way should return same object
- assertEquals(engineScope.get("Array"), e.get("Array"));
- assertEquals(engineScope.get("EvalError"), e.get("EvalError"));
- assertEquals(engineScope.get("undefined"), e.get("undefined"));
-
- // try exposing a new variable from scope
- engineScope.put("myVar", "foo");
- try {
- assertEquals(e.eval("myVar"), "foo");
- } catch (final ScriptException se) {
- se.printStackTrace();
- fail(se.getMessage());
- }
-
- // update "myVar" in script an check the value from scope
- try {
- e.eval("myVar = 'nashorn';");
- } catch (final ScriptException se) {
- se.printStackTrace();
- fail(se.getMessage());
- }
-
- // now check modified value from scope and engine
- assertEquals(engineScope.get("myVar"), "nashorn");
- assertEquals(e.get("myVar"), "nashorn");
- }
-
- @Test
- public void multiGlobalTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- final Bindings b = e.createBindings();
- final ScriptContext newCtxt = new SimpleScriptContext();
- newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
-
- try {
- final Object obj1 = e.eval("Object");
- final Object obj2 = e.eval("Object", newCtxt);
- Assert.assertNotEquals(obj1, obj2);
- Assert.assertNotNull(obj1);
- Assert.assertNotNull(obj2);
- Assert.assertEquals(obj1.toString(), obj2.toString());
-
- e.eval("x = 'hello'");
- e.eval("x = 'world'", newCtxt);
- Object x1 = e.getContext().getAttribute("x");
- Object x2 = newCtxt.getAttribute("x");
- Assert.assertNotEquals(x1, x2);
- Assert.assertEquals(x1, "hello");
- Assert.assertEquals(x2, "world");
-
- x1 = e.eval("x");
- x2 = e.eval("x", newCtxt);
- Assert.assertNotEquals(x1, x2);
- Assert.assertEquals(x1, "hello");
- Assert.assertEquals(x2, "world");
-
- final ScriptContext origCtxt = e.getContext();
- e.setContext(newCtxt);
- e.eval("y = new Object()");
- e.eval("y = new Object()", origCtxt);
-
- final Object y1 = origCtxt.getAttribute("y");
- final Object y2 = newCtxt.getAttribute("y");
- Assert.assertNotEquals(y1, y2);
- final Object yeval1 = e.eval("y");
- final Object yeval2 = e.eval("y", origCtxt);
- Assert.assertNotEquals(yeval1, yeval2);
- Assert.assertEquals("[object Object]", y1.toString());
- Assert.assertEquals("[object Object]", y2.toString());
- } catch (final ScriptException se) {
- se.printStackTrace();
- fail(se.getMessage());
- }
- }
-
- @Test
- public void userEngineScopeBindingsTest() throws ScriptException {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- e.eval("function func() {}");
-
- final ScriptContext newContext = new SimpleScriptContext();
- newContext.setBindings(new SimpleBindings(), ScriptContext.ENGINE_SCOPE);
- // we are using a new bindings - so it should have 'func' defined
- final Object value = e.eval("typeof func", newContext);
- assertTrue(value.equals("undefined"));
- }
-
- @Test
- public void userEngineScopeBindingsNoLeakTest() throws ScriptException {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- final ScriptContext newContext = new SimpleScriptContext();
- newContext.setBindings(new SimpleBindings(), ScriptContext.ENGINE_SCOPE);
- e.eval("function foo() {}", newContext);
-
- // in the default context's ENGINE_SCOPE, 'foo' shouldn't exist
- assertTrue(e.eval("typeof foo").equals("undefined"));
- }
-
- @Test
- public void userEngineScopeBindingsRetentionTest() throws ScriptException {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- final ScriptContext newContext = new SimpleScriptContext();
- newContext.setBindings(new SimpleBindings(), ScriptContext.ENGINE_SCOPE);
- e.eval("function foo() {}", newContext);
-
- // definition retained with user's ENGINE_SCOPE Binding
- assertTrue(e.eval("typeof foo", newContext).equals("function"));
-
- final Bindings oldBindings = newContext.getBindings(ScriptContext.ENGINE_SCOPE);
- // but not in another ENGINE_SCOPE binding
- newContext.setBindings(new SimpleBindings(), ScriptContext.ENGINE_SCOPE);
- assertTrue(e.eval("typeof foo", newContext).equals("undefined"));
-
- // restore ENGINE_SCOPE and check again
- newContext.setBindings(oldBindings, ScriptContext.ENGINE_SCOPE);
- assertTrue(e.eval("typeof foo", newContext).equals("function"));
- }
-
- @Test
- // check that engine.js definitions are visible in all new global instances
- public void checkBuiltinsInNewBindingsTest() throws ScriptException {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
-
- // check default global instance has engine.js definitions
- final Bindings g = (Bindings) e.eval("this");
- Object value = g.get("__noSuchProperty__");
- assertTrue(value instanceof ScriptObjectMirror && ((ScriptObjectMirror)value).isFunction());
- value = g.get("print");
- assertTrue(value instanceof ScriptObjectMirror && ((ScriptObjectMirror)value).isFunction());
-
- // check new global instance created has engine.js definitions
- final Bindings b = e.createBindings();
- value = b.get("__noSuchProperty__");
- assertTrue(value instanceof ScriptObjectMirror && ((ScriptObjectMirror)value).isFunction());
- value = b.get("print");
- assertTrue(value instanceof ScriptObjectMirror && ((ScriptObjectMirror)value).isFunction());
-
- // put a mapping into GLOBAL_SCOPE
- final Bindings globalScope = e.getContext().getBindings(ScriptContext.GLOBAL_SCOPE);
- globalScope.put("x", "hello");
-
- // GLOBAL_SCOPE mapping should be visible from default ScriptContext eval
- assertTrue(e.eval("x").equals("hello"));
-
- final ScriptContext ctx = new SimpleScriptContext();
- ctx.setBindings(globalScope, ScriptContext.GLOBAL_SCOPE);
- ctx.setBindings(b, ScriptContext.ENGINE_SCOPE);
-
- // GLOBAL_SCOPE mapping should be visible from non-default ScriptContext eval
- assertTrue(e.eval("x", ctx).equals("hello"));
-
- // try some arbitray Bindings for ENGINE_SCOPE
- final Bindings sb = new SimpleBindings();
- ctx.setBindings(sb, ScriptContext.ENGINE_SCOPE);
-
- // GLOBAL_SCOPE mapping should be visible from non-default ScriptContext eval
- assertTrue(e.eval("x", ctx).equals("hello"));
-
- // engine.js builtins are still defined even with arbitrary Bindings
- assertTrue(e.eval("typeof print", ctx).equals("function"));
- assertTrue(e.eval("typeof __noSuchProperty__", ctx).equals("function"));
-
- // ENGINE_SCOPE definition should 'hide' GLOBAL_SCOPE definition
- sb.put("x", "newX");
- assertTrue(e.eval("x", ctx).equals("newX"));
- }
-
- /**
- * Test multi-threaded access to defined global variables for shared script classes with multiple globals.
- */
- @Test
- public static void multiThreadedVarTest() throws ScriptException, InterruptedException {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- final Bindings b = e.createBindings();
- final ScriptContext origContext = e.getContext();
- final ScriptContext newCtxt = new SimpleScriptContext();
- newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
- final String sharedScript = "foo";
-
- assertEquals(e.eval("var foo = 'original context';", origContext), null);
- assertEquals(e.eval("var foo = 'new context';", newCtxt), null);
-
- final Thread t1 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
- final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "new context", 1000));
- t1.start();
- t2.start();
- t1.join();
- t2.join();
-
- assertEquals(e.eval("var foo = 'newer context';", newCtxt), null);
- final Thread t3 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
- final Thread t4 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "newer context", 1000));
-
- t3.start();
- t4.start();
- t3.join();
- t4.join();
-
- assertEquals(e.eval(sharedScript), "original context");
- assertEquals(e.eval(sharedScript, newCtxt), "newer context");
- }
-
- /**
- * Test multi-threaded access to undefined global variables for shared script classes with multiple globals.
- */
- @Test
- public static void multiThreadedGlobalTest() throws ScriptException, InterruptedException {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- final Bindings b = e.createBindings();
- final ScriptContext origContext = e.getContext();
- final ScriptContext newCtxt = new SimpleScriptContext();
- newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
-
- assertEquals(e.eval("foo = 'original context';", origContext), "original context");
- assertEquals(e.eval("foo = 'new context';", newCtxt), "new context");
- final String sharedScript = "foo";
-
- final Thread t1 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
- final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "new context", 1000));
- t1.start();
- t2.start();
- t1.join();
- t2.join();
-
- final Object obj3 = e.eval("delete foo; foo = 'newer context';", newCtxt);
- assertEquals(obj3, "newer context");
- final Thread t3 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
- final Thread t4 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "newer context", 1000));
-
- t3.start();
- t4.start();
- t3.join();
- t4.join();
-
- Assert.assertEquals(e.eval(sharedScript), "original context");
- Assert.assertEquals(e.eval(sharedScript, newCtxt), "newer context");
- }
-
- /**
- * Test multi-threaded access using the postfix ++ operator for shared script classes with multiple globals.
- */
- @Test
- public static void multiThreadedIncTest() throws ScriptException, InterruptedException {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- final Bindings b = e.createBindings();
- final ScriptContext origContext = e.getContext();
- final ScriptContext newCtxt = new SimpleScriptContext();
- newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
-
- assertEquals(e.eval("var x = 0;", origContext), null);
- assertEquals(e.eval("var x = 2;", newCtxt), null);
- final String sharedScript = "x++;";
-
- final Thread t1 = new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- for (int i = 0; i < 1000; i++) {
- assertEquals(e.eval(sharedScript, origContext), (double)i);
- }
- } catch (final ScriptException se) {
- fail(se.toString());
- }
- }
- });
- final Thread t2 = new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- for (int i = 2; i < 1000; i++) {
- assertEquals(e.eval(sharedScript, newCtxt), (double)i);
- }
- } catch (final ScriptException se) {
- fail(se.toString());
- }
- }
- });
- t1.start();
- t2.start();
- t1.join();
- t2.join();
- }
-
- /**
- * Test multi-threaded access to primitive prototype properties for shared script classes with multiple globals.
- */
- @Test
- public static void multiThreadedPrimitiveTest() throws ScriptException, InterruptedException {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- final Bindings b = e.createBindings();
- final ScriptContext origContext = e.getContext();
- final ScriptContext newCtxt = new SimpleScriptContext();
- newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
-
- final Object obj1 = e.eval("String.prototype.foo = 'original context';", origContext);
- final Object obj2 = e.eval("String.prototype.foo = 'new context';", newCtxt);
- assertEquals(obj1, "original context");
- assertEquals(obj2, "new context");
- final String sharedScript = "''.foo";
-
- final Thread t1 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
- final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "new context", 1000));
- t1.start();
- t2.start();
- t1.join();
- t2.join();
-
- final Object obj3 = e.eval("delete String.prototype.foo; Object.prototype.foo = 'newer context';", newCtxt);
- assertEquals(obj3, "newer context");
- final Thread t3 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
- final Thread t4 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "newer context", 1000));
-
- t3.start();
- t4.start();
- t3.join();
- t4.join();
-
- Assert.assertEquals(e.eval(sharedScript), "original context");
- Assert.assertEquals(e.eval(sharedScript, newCtxt), "newer context");
- }
-
-
- /**
- * Test multi-threaded access to prototype user accessor properties for shared script classes with multiple globals.
- */
- @Test
- public static void multiThreadedAccessorTest() throws ScriptException, InterruptedException {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- final Bindings b = e.createBindings();
- final ScriptContext origContext = e.getContext();
- final ScriptContext newCtxt = new SimpleScriptContext();
- newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
-
- e.eval("Object.defineProperty(Object.prototype, 'foo', { get: function() 'original context' })", origContext);
- e.eval("Object.defineProperty(Object.prototype, 'foo', { get: function() 'new context', configurable: true })", newCtxt);
- final String sharedScript = "({}).foo";
-
- final Thread t1 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
- final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "new context", 1000));
- t1.start();
- t2.start();
- t1.join();
- t2.join();
-
- final Object obj3 = e.eval("delete Object.prototype.foo; Object.prototype.foo = 'newer context';", newCtxt);
- assertEquals(obj3, "newer context");
- final Thread t3 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
- final Thread t4 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "newer context", 1000));
-
- t3.start();
- t4.start();
- t3.join();
- t4.join();
- }
-
- /**
- * Test multi-threaded access to primitive prototype user accessor properties for shared script classes with multiple globals.
- */
- @Test
- public static void multiThreadedPrimitiveAccessorTest() throws ScriptException, InterruptedException {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- final Bindings b = e.createBindings();
- final ScriptContext origContext = e.getContext();
- final ScriptContext newCtxt = new SimpleScriptContext();
- newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
-
- e.eval("Object.defineProperty(String.prototype, 'foo', { get: function() 'original context' })", origContext);
- e.eval("Object.defineProperty(String.prototype, 'foo', { get: function() 'new context' })", newCtxt);
- final String sharedScript = "''.foo";
-
- final Thread t1 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
- final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "new context", 1000));
- t1.start();
- t2.start();
- t1.join();
- t2.join();
-
- final Object obj3 = e.eval("delete String.prototype.foo; Object.prototype.foo = 'newer context';", newCtxt);
- assertEquals(obj3, "newer context");
- final Thread t3 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
- final Thread t4 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "newer context", 1000));
-
- t3.start();
- t4.start();
- t3.join();
- t4.join();
- }
-
- /**
- * Test multi-threaded scope function invocation for shared script classes with multiple globals.
- */
- @Test
- public static void multiThreadedFunctionTest() throws ScriptException, InterruptedException {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- final Bindings b = e.createBindings();
- final ScriptContext origContext = e.getContext();
- final ScriptContext newCtxt = new SimpleScriptContext();
- newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
-
- e.eval(new URLReader(ScopeTest.class.getResource("resources/func.js")), origContext);
- assertEquals(origContext.getAttribute("scopeVar"), 1);
- assertEquals(e.eval("scopeTest()"), 1);
-
- e.eval(new URLReader(ScopeTest.class.getResource("resources/func.js")), newCtxt);
- assertEquals(newCtxt.getAttribute("scopeVar"), 1);
- assertEquals(e.eval("scopeTest();", newCtxt), 1);
-
- assertEquals(e.eval("scopeVar = 3;", newCtxt), 3);
- assertEquals(newCtxt.getAttribute("scopeVar"), 3);
-
-
- final Thread t1 = new Thread(new ScriptRunner(e, origContext, "scopeTest()", 1, 1000));
- final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, "scopeTest()", 3, 1000));
-
- t1.start();
- t2.start();
- t1.join();
- t2.join();
-
- }
-
- /**
- * Test multi-threaded access to global getters and setters for shared script classes with multiple globals.
- */
- @Test
- public static void getterSetterTest() throws ScriptException, InterruptedException {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- final Bindings b = e.createBindings();
- final ScriptContext origContext = e.getContext();
- final ScriptContext newCtxt = new SimpleScriptContext();
- newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
- final String sharedScript = "accessor1";
-
- e.eval(new URLReader(ScopeTest.class.getResource("resources/gettersetter.js")), origContext);
- assertEquals(e.eval("accessor1 = 1;"), 1);
- assertEquals(e.eval(sharedScript), 1);
-
- e.eval(new URLReader(ScopeTest.class.getResource("resources/gettersetter.js")), newCtxt);
- assertEquals(e.eval("accessor1 = 2;", newCtxt), 2);
- assertEquals(e.eval(sharedScript, newCtxt), 2);
-
-
- final Thread t1 = new Thread(new ScriptRunner(e, origContext, sharedScript, 1, 1000));
- final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, 2, 1000));
-
- t1.start();
- t2.start();
- t1.join();
- t2.join();
-
- assertEquals(e.eval(sharedScript), 1);
- assertEquals(e.eval(sharedScript, newCtxt), 2);
- assertEquals(e.eval("v"), 1);
- assertEquals(e.eval("v", newCtxt), 2);
- }
-
- /**
- * Test multi-threaded access to global getters and setters for shared script classes with multiple globals.
- */
- @Test
- public static void getterSetter2Test() throws ScriptException, InterruptedException {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- final Bindings b = e.createBindings();
- final ScriptContext origContext = e.getContext();
- final ScriptContext newCtxt = new SimpleScriptContext();
- newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
- final String sharedScript = "accessor2";
-
- e.eval(new URLReader(ScopeTest.class.getResource("resources/gettersetter.js")), origContext);
- assertEquals(e.eval("accessor2 = 1;"), 1);
- assertEquals(e.eval(sharedScript), 1);
-
- e.eval(new URLReader(ScopeTest.class.getResource("resources/gettersetter.js")), newCtxt);
- assertEquals(e.eval("accessor2 = 2;", newCtxt), 2);
- assertEquals(e.eval(sharedScript, newCtxt), 2);
-
-
- final Thread t1 = new Thread(new ScriptRunner(e, origContext, sharedScript, 1, 1000));
- final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, 2, 1000));
-
- t1.start();
- t2.start();
- t1.join();
- t2.join();
-
- assertEquals(e.eval(sharedScript), 1);
- assertEquals(e.eval(sharedScript, newCtxt), 2);
- assertEquals(e.eval("x"), 1);
- assertEquals(e.eval("x", newCtxt), 2);
- }
-
- // @bug 8058422: Users should be able to overwrite "context" and "engine" variables
- @Test
- public static void contextOverwriteTest() throws ScriptException {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- final Bindings b = new SimpleBindings();
- b.put("context", "hello");
- b.put("foo", 32);
- final ScriptContext newCtxt = new SimpleScriptContext();
- newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
- e.setContext(newCtxt);
- assertEquals(e.eval("context"), "hello");
- assertEquals(((Number)e.eval("foo")).intValue(), 32);
- }
-
- // @bug 8058422: Users should be able to overwrite "context" and "engine" variables
- @Test
- public static void contextOverwriteInScriptTest() throws ScriptException {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- e.put("foo", 32);
-
- assertEquals(((Number)e.eval("foo")).intValue(), 32);
- assertEquals(e.eval("context = 'bar'"), "bar");
- assertEquals(((Number)e.eval("foo")).intValue(), 32);
- }
-
- // @bug 8058422: Users should be able to overwrite "context" and "engine" variables
- @Test
- public static void engineOverwriteTest() throws ScriptException {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- final Bindings b = new SimpleBindings();
- b.put("engine", "hello");
- b.put("foo", 32);
- final ScriptContext newCtxt = new SimpleScriptContext();
- newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
- e.setContext(newCtxt);
- assertEquals(e.eval("engine"), "hello");
- assertEquals(((Number)e.eval("foo")).intValue(), 32);
- }
-
- // @bug 8058422: Users should be able to overwrite "context" and "engine" variables
- @Test
- public static void engineOverwriteInScriptTest() throws ScriptException {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- e.put("foo", 32);
-
- assertEquals(((Number)e.eval("foo")).intValue(), 32);
- assertEquals(e.eval("engine = 'bar'"), "bar");
- assertEquals(((Number)e.eval("foo")).intValue(), 32);
- }
-
- // @bug 8044750: megamorphic getter for scope objects does not call __noSuchProperty__ hook
- @Test
- public static void testMegamorphicGetInGlobal() throws Exception {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine engine = m.getEngineByName("nashorn");
- final String script = "foo";
- // "foo" is megamorphic because of different global scopes.
- // Make sure ScriptContext variable search works even after
- // it becomes megamorphic.
- for (int index = 0; index < 25; index++) {
- final Bindings bindings = new SimpleBindings();
- bindings.put("foo", index);
- final Number value = (Number)engine.eval(script, bindings);
- assertEquals(index, value.intValue());
- }
- }
-
- /**
- * Test "slow" scopes involving {@code with} and {@code eval} statements for shared script classes with multiple globals.
- * @throws ScriptException
- * @throws InterruptedException
- */
- @Test
- public static void testSlowScope() throws ScriptException, InterruptedException {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
-
- for (int i = 0; i < 100; i++) {
- final Bindings b = e.createBindings();
- final ScriptContext ctxt = new SimpleScriptContext();
- ctxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
-
- e.eval(new URLReader(ScopeTest.class.getResource("resources/witheval.js")), ctxt);
- assertEquals(e.eval("a", ctxt), 1);
- assertEquals(b.get("a"), 1);
- assertEquals(e.eval("b", ctxt), 3);
- assertEquals(b.get("b"), 3);
- assertEquals(e.eval("c", ctxt), 10);
- assertEquals(b.get("c"), 10);
- }
- }
-
- private static class ScriptRunner implements Runnable {
-
- final ScriptEngine engine;
- final ScriptContext context;
- final String source;
- final Object expected;
- final int iterations;
-
- ScriptRunner(final ScriptEngine engine, final ScriptContext context, final String source, final Object expected, final int iterations) {
- this.engine = engine;
- this.context = context;
- this.source = source;
- this.expected = expected;
- this.iterations = iterations;
- }
-
- @Override
- public void run() {
- try {
- for (int i = 0; i < iterations; i++) {
- assertEquals(engine.eval(source, context), expected);
- }
- } catch (final ScriptException se) {
- throw new RuntimeException(se);
- }
- }
- }
-
- // @bug 8071678: NashornScriptEngine returns javax.script.ScriptContext instance
- // with get/setAttribute methods insonsistent for GLOBAL_SCOPE
- @Test
- public void testGlobalScopeSearch() throws Exception {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- final ScriptContext c = e.getContext();
- c.setAttribute("name1234", "value", ScriptContext.GLOBAL_SCOPE);
- assertEquals(c.getAttribute("name1234"), "value");
- assertEquals(c.getAttributesScope("name1234"),
- ScriptContext.GLOBAL_SCOPE);
- }
-
- // @bug 8071594: NashornScriptEngine returns javax.script.ScriptContext instance
- // which doesn't completely conform to the spec regarding exceptions throwing
- @Test
- public void testScriptContext_NPE_IAE() throws Exception {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- final ScriptContext c = e.getContext();
- try {
- c.getAttribute("");
- throw new AssertionError("should have thrown IAE");
- } catch (IllegalArgumentException iae1) {}
-
- try {
- c.getAttribute(null);
- throw new AssertionError("should have thrown NPE");
- } catch (NullPointerException npe1) {}
-
- try {
- c.getAttribute("", ScriptContext.ENGINE_SCOPE);
- throw new AssertionError("should have thrown IAE");
- } catch (IllegalArgumentException iae2) {}
-
- try {
- c.getAttribute(null, ScriptContext.ENGINE_SCOPE);
- throw new AssertionError("should have thrown NPE");
- } catch (NullPointerException npe2) {}
-
- try {
- c.removeAttribute("", ScriptContext.ENGINE_SCOPE);
- throw new AssertionError("should have thrown IAE");
- } catch (IllegalArgumentException iae3) {}
-
- try {
- c.removeAttribute(null, ScriptContext.ENGINE_SCOPE);
- throw new AssertionError("should have thrown NPE");
- } catch (NullPointerException npe3) {}
-
- try {
- c.setAttribute("", "value", ScriptContext.ENGINE_SCOPE);
- throw new AssertionError("should have thrown IAE");
- } catch (IllegalArgumentException iae4) {}
-
- try {
- c.setAttribute(null, "value", ScriptContext.ENGINE_SCOPE);
- throw new AssertionError("should have thrown NPE");
- } catch (NullPointerException npe4) {}
-
- try {
- c.getAttributesScope("");
- throw new AssertionError("should have thrown IAE");
- } catch (IllegalArgumentException iae5) {}
-
- try {
- c.getAttributesScope(null);
- throw new AssertionError("should have thrown NPE");
- } catch (NullPointerException npe5) {}
- }
-}
--- a/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineSecurityTest.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,311 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.scripting;
-
-import static org.testng.Assert.fail;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
-import javax.script.ScriptException;
-import org.testng.annotations.Test;
-
-/**
- * jsr223 tests for security access checks.
- */
-@SuppressWarnings("javadoc")
-public class ScriptEngineSecurityTest {
-
- private static void log(final String msg) {
- org.testng.Reporter.log(msg, true);
- }
-
- @Test
- public void securityPackagesTest() {
- if (System.getSecurityManager() == null) {
- // pass vacuously
- return;
- }
-
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- try {
- e.eval("var v = Packages.sun.misc.Unsafe;");
- fail("should have thrown SecurityException");
- } catch (final Exception exp) {
- if (exp instanceof SecurityException) {
- log("got " + exp + " as expected");
- } else {
- fail(exp.getMessage());
- }
- }
- }
-
- @Test
- public void securityJavaTypeTest() {
- if (System.getSecurityManager() == null) {
- // pass vacuously
- return;
- }
-
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- try {
- e.eval("var v = Java.type('sun.misc.Unsafe');");
- fail("should have thrown SecurityException");
- } catch (final Exception exp) {
- if (exp instanceof SecurityException) {
- log("got " + exp + " as expected");
- } else {
- fail(exp.getMessage());
- }
- }
- }
-
- @Test
- public void securityClassForNameTest() {
- if (System.getSecurityManager() == null) {
- // pass vacuously
- return;
- }
-
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- try {
- e.eval("var v = java.lang.Class.forName('sun.misc.Unsafe');");
- fail("should have thrown SecurityException");
- } catch (final Exception exp) {
- if (exp instanceof SecurityException) {
- log("got " + exp + " as expected");
- } else {
- fail(exp.getMessage());
- }
- }
- }
-
- @Test
- public void securitySystemExit() {
- if (System.getSecurityManager() == null) {
- // pass vacuously
- return;
- }
-
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- try {
- e.eval("java.lang.System.exit(0);");
- fail("should have thrown SecurityException");
- } catch (final Exception exp) {
- if (exp instanceof SecurityException) {
- log("got " + exp + " as expected");
- } else {
- fail(exp.getMessage());
- }
- }
- }
-
-
- @Test
- public void securitySystemExitFromFinalizerThread() throws ScriptException {
- if (System.getSecurityManager() == null) {
- // pass vacuously
- return;
- }
-
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- e.eval("var o = Java.extend(Java.type('javax.imageio.spi.ServiceRegistry'), { deregisterAll: this.exit.bind(null, 1234)});\n" +
- "new o(new java.util.ArrayList().iterator())");
- System.gc();
- System.runFinalization();
- // NOTE: this test just exits the VM if it fails.
- }
-
- @Test
- public void securitySystemLoadLibrary() {
- if (System.getSecurityManager() == null) {
- // pass vacuously
- return;
- }
-
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- try {
- e.eval("java.lang.System.loadLibrary('foo');");
- fail("should have thrown SecurityException");
- } catch (final Exception exp) {
- if (exp instanceof SecurityException) {
- log("got " + exp + " as expected");
- } else {
- fail(exp.getMessage());
- }
- }
- }
-
- // @bug 8032948: Nashorn linkages awry
- @SuppressWarnings("serial")
- public static class FakeProxy extends Proxy {
- public FakeProxy(final InvocationHandler ih) {
- super(ih);
- }
-
- public static Class<?> makeProxyClass(final ClassLoader cl, final Class<?>... ifaces) {
- return Proxy.getProxyClass(cl, ifaces);
- }
- }
-
- @Test
- public void fakeProxySubclassAccessCheckTest() {
- if (System.getSecurityManager() == null) {
- // pass vacuously
- return;
- }
-
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
-
- e.put("name", ScriptEngineSecurityTest.class.getName());
- e.put("cl", ScriptEngineSecurityTest.class.getClassLoader());
- e.put("intfs", new Class[] { Runnable.class });
-
- final String getClass = "Java.type(name + '$FakeProxy').getProxyClass(cl, intfs);";
-
- // Should not be able to call static methods of Proxy via fake subclass
- try {
- e.eval(getClass);
- fail("should have thrown SecurityException");
- } catch (final Exception exp) {
- if (! (exp instanceof SecurityException)) {
- fail("SecurityException expected, got " + exp);
- }
- }
- }
-
- @Test
- public void fakeProxySubclassAccessCheckTest2() {
- if (System.getSecurityManager() == null) {
- // pass vacuously
- return;
- }
-
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
-
- e.put("name", ScriptEngineSecurityTest.class.getName());
- e.put("cl", ScriptEngineSecurityTest.class.getClassLoader());
- e.put("intfs", new Class[] { Runnable.class });
-
- final String getClass = "Java.type(name + '$FakeProxy').makeProxyClass(cl, intfs);";
-
- // Should not be able to call static methods of Proxy via fake subclass
- try {
- e.eval(getClass);
- fail("should have thrown SecurityException");
- } catch (final Exception exp) {
- if (! (exp instanceof SecurityException)) {
- fail("SecurityException expected, got " + exp);
- }
- }
- }
-
- @Test
- public static void proxyStaticAccessCheckTest() {
- if (System.getSecurityManager() == null) {
- // pass vacuously
- return;
- }
-
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- final Runnable r = (Runnable)Proxy.newProxyInstance(
- ScriptEngineTest.class.getClassLoader(),
- new Class[] { Runnable.class },
- new InvocationHandler() {
- @Override
- public Object invoke(final Object p, final Method mtd, final Object[] a) {
- return null;
- }
- });
-
- e.put("rc", r.getClass());
- e.put("cl", ScriptEngineSecurityTest.class.getClassLoader());
- e.put("intfs", new Class[] { Runnable.class });
-
- // make sure static methods of Proxy is not accessible via subclass
- try {
- e.eval("rc.static.getProxyClass(cl, intfs)");
- fail("Should have thrown SecurityException");
- } catch (final Exception exp) {
- if (! (exp instanceof SecurityException)) {
- fail("SecurityException expected, got " + exp);
- }
- }
- }
-
-
- @Test
- public void nashornConfigSecurityTest() {
- if (System.getSecurityManager() == null) {
- // pass vacuously
- return;
- }
-
- final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
- try {
- fac.getScriptEngine(new ClassFilter() {
- @Override
- public boolean exposeToScripts(final String name) {
- return true;
- }
- });
- fail("SecurityException should have been thrown");
- } catch (final SecurityException e) {
- //empty
- }
- }
-
- @Test
- public void nashornConfigSecurityTest2() {
- if (System.getSecurityManager() == null) {
- // pass vacuously
- return;
- }
-
- final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
- try {
- fac.getScriptEngine(new String[0], null, new ClassFilter() {
- @Override
- public boolean exposeToScripts(final String name) {
- return true;
- }
- });
- fail("SecurityException should have been thrown");
- } catch (final SecurityException e) {
- //empty
- }
- }
-}
--- a/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,880 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.scripting;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
-
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.Collections;
-import java.util.concurrent.Callable;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.function.Consumer;
-import java.util.function.Function;
-import javax.script.Bindings;
-import javax.script.Compilable;
-import javax.script.CompiledScript;
-import javax.script.Invocable;
-import javax.script.ScriptContext;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineFactory;
-import javax.script.ScriptEngineManager;
-import javax.script.ScriptException;
-import javax.script.SimpleScriptContext;
-import org.testng.annotations.Test;
-
-/**
- * Tests for JSR-223 script engine for Nashorn.
- *
- * @test
- * @build jdk.nashorn.api.scripting.Window jdk.nashorn.api.scripting.WindowEventHandler jdk.nashorn.api.scripting.VariableArityTestInterface jdk.nashorn.api.scripting.ScriptEngineTest
- * @run testng/othervm jdk.nashorn.api.scripting.ScriptEngineTest
- */
-@SuppressWarnings("javadoc")
-public class ScriptEngineTest {
-
- private static void log(final String msg) {
- org.testng.Reporter.log(msg, true);
- }
-
- @Test
- public void argumentsTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
-
- final String[] args = new String[] { "hello", "world" };
- try {
- e.put("arguments", args);
- final Object arg0 = e.eval("arguments[0]");
- final Object arg1 = e.eval("arguments[1]");
- assertEquals(args[0], arg0);
- assertEquals(args[1], arg1);
- } catch (final Exception exp) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
-
- @Test
- public void argumentsWithTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
-
- final String[] args = new String[] { "hello", "world" };
- try {
- e.put("arguments", args);
- final Object arg0 = e.eval("var imports = new JavaImporter(java.io); " +
- " with(imports) { arguments[0] }");
- final Object arg1 = e.eval("var imports = new JavaImporter(java.util, java.io); " +
- " with(imports) { arguments[1] }");
- assertEquals(args[0], arg0);
- assertEquals(args[1], arg1);
- } catch (final Exception exp) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
-
- @Test
- public void argumentsEmptyTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
-
- try {
- assertEquals(e.eval("arguments instanceof Array"), true);
- assertEquals(e.eval("arguments.length == 0"), true);
- } catch (final Exception exp) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
-
- @Test
- public void factoryTests() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- assertNotNull(e);
-
- final ScriptEngineFactory fac = e.getFactory();
-
- assertEquals(fac.getLanguageName(), "ECMAScript");
- assertEquals(fac.getParameter(ScriptEngine.NAME), "javascript");
- assertEquals(fac.getLanguageVersion(), "ECMA - 262 Edition 5.1");
- assertEquals(fac.getEngineName(), "Oracle Nashorn");
- assertEquals(fac.getOutputStatement("context"), "print(context)");
- assertEquals(fac.getProgram("print('hello')", "print('world')"), "print('hello');print('world');");
- assertEquals(fac.getParameter(ScriptEngine.NAME), "javascript");
-
- boolean seenJS = false;
- for (final String ext : fac.getExtensions()) {
- if (ext.equals("js")) {
- seenJS = true;
- }
- }
-
- assertEquals(seenJS, true);
- final String str = fac.getMethodCallSyntax("obj", "foo", "x");
- assertEquals(str, "obj.foo(x)");
-
- boolean seenNashorn = false, seenJavaScript = false, seenECMAScript = false;
- for (final String name : fac.getNames()) {
- switch (name) {
- case "nashorn": seenNashorn = true; break;
- case "javascript": seenJavaScript = true; break;
- case "ECMAScript": seenECMAScript = true; break;
- default:
- break;
- }
- }
-
- assertTrue(seenNashorn);
- assertTrue(seenJavaScript);
- assertTrue(seenECMAScript);
-
- boolean seenAppJS = false, seenAppECMA = false, seenTextJS = false, seenTextECMA = false;
- for (final String mime : fac.getMimeTypes()) {
- switch (mime) {
- case "application/javascript": seenAppJS = true; break;
- case "application/ecmascript": seenAppECMA = true; break;
- case "text/javascript": seenTextJS = true; break;
- case "text/ecmascript": seenTextECMA = true; break;
- default:
- break;
- }
- }
-
- assertTrue(seenAppJS);
- assertTrue(seenAppECMA);
- assertTrue(seenTextJS);
- assertTrue(seenTextECMA);
- }
-
- @Test
- public void evalTests() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- e.put(ScriptEngine.FILENAME, "myfile.js");
-
- try {
- e.eval("print('hello')");
- } catch (final ScriptException se) {
- fail(se.getMessage());
- }
- try {
- e.eval("print('hello)");
- fail("script exception expected");
- } catch (final ScriptException se) {
- assertEquals(se.getLineNumber(), 1);
- assertEquals(se.getColumnNumber(), 13);
- assertEquals(se.getFileName(), "myfile.js");
- // se.printStackTrace();
- }
-
- try {
- Object obj = e.eval("34 + 41");
- assertTrue(34.0 + 41.0 == ((Number)obj).doubleValue());
- obj = e.eval("x = 5");
- assertTrue(5.0 == ((Number)obj).doubleValue());
- } catch (final ScriptException se) {
- se.printStackTrace();
- fail(se.getMessage());
- }
- }
-
- @Test
- public void compileTests() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- CompiledScript script = null;
-
- try {
- script = ((Compilable)e).compile("print('hello')");
- } catch (final ScriptException se) {
- fail(se.getMessage());
- }
-
- try {
- script.eval();
- } catch (final ScriptException | NullPointerException se) {
- se.printStackTrace();
- fail(se.getMessage());
- }
-
- // try to compile from a Reader
- try {
- script = ((Compilable)e).compile(new StringReader("print('world')"));
- } catch (final ScriptException se) {
- fail(se.getMessage());
- }
-
- try {
- script.eval();
- } catch (final ScriptException | NullPointerException se) {
- se.printStackTrace();
- fail(se.getMessage());
- }
- }
-
- @Test
- public void compileAndEvalInDiffContextTest() throws ScriptException {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine engine = m.getEngineByName("js");
- final Compilable compilable = (Compilable) engine;
- final CompiledScript compiledScript = compilable.compile("foo");
- final ScriptContext ctxt = new SimpleScriptContext();
- ctxt.setAttribute("foo", "hello", ScriptContext.ENGINE_SCOPE);
- assertEquals(compiledScript.eval(ctxt), "hello");
- }
-
- @Test
- public void accessGlobalTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
-
- try {
- e.eval("var x = 'hello'");
- assertEquals(e.get("x"), "hello");
- } catch (final ScriptException exp) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
-
- @Test
- public void exposeGlobalTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
-
- try {
- e.put("y", "foo");
- e.eval("print(y)");
- } catch (final ScriptException exp) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
-
- @Test
- public void putGlobalFunctionTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
-
- e.put("callable", new Callable<String>() {
- @Override
- public String call() throws Exception {
- return "callable was called";
- }
- });
-
- try {
- e.eval("print(callable.call())");
- } catch (final ScriptException exp) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
-
- @Test
- public void windowAlertTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- final Window window = new Window();
-
- try {
- e.put("window", window);
- e.eval("print(window.alert)");
- e.eval("window.alert('calling window.alert...')");
- } catch (final Exception exp) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
-
- @Test
- public void windowLocationTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- final Window window = new Window();
-
- try {
- e.put("window", window);
- e.eval("print(window.location)");
- final Object locationValue = e.eval("window.getLocation()");
- assertEquals(locationValue, "http://localhost:8080/window");
- } catch (final Exception exp) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
-
- @Test
- public void windowItemTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- final Window window = new Window();
-
- try {
- e.put("window", window);
- final String item1 = (String)e.eval("window.item(65535)");
- assertEquals(item1, "ffff");
- final String item2 = (String)e.eval("window.item(255)");
- assertEquals(item2, "ff");
- } catch (final Exception exp) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
-
- @Test
- public void windowEventTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- final Window window = new Window();
-
- try {
- e.put("window", window);
- e.eval("window.onload = function() { print('window load event fired'); return true }");
- assertTrue((Boolean)e.eval("window.onload.loaded()"));
- final WindowEventHandler handler = window.getOnload();
- assertNotNull(handler);
- assertTrue(handler.loaded());
- } catch (final Exception exp) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
-
- @Test
- public void throwTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- e.put(ScriptEngine.FILENAME, "throwtest.js");
-
- try {
- e.eval("throw 'foo'");
- } catch (final ScriptException exp) {
- log(exp.getMessage());
- assertEquals(exp.getMessage(), "foo in throwtest.js at line number 1 at column number 0");
- assertEquals(exp.getFileName(), "throwtest.js");
- assertEquals(exp.getLineNumber(), 1);
- }
- }
-
- @Test
- public void setTimeoutTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- final Window window = new Window();
-
- try {
- final Class<?> setTimeoutParamTypes[] = { Window.class, String.class, int.class };
- final Method setTimeout = Window.class.getDeclaredMethod("setTimeout", setTimeoutParamTypes);
- assertNotNull(setTimeout);
- e.put("window", window);
- e.eval("window.setTimeout('foo()', 100)");
-
- // try to make setTimeout global
- e.put("setTimeout", setTimeout);
- // TODO: java.lang.ClassCastException: required class
- // java.lang.Integer but encountered class java.lang.Double
- // e.eval("setTimeout('foo2()', 200)");
- } catch (final Exception exp) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
-
- @Test
- public void setWriterTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- final StringWriter sw = new StringWriter();
- e.getContext().setWriter(sw);
-
- try {
- e.eval("print('hello world')");
- } catch (final Exception exp) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- assertEquals(sw.toString(), println("hello world"));
- }
-
- @Test
- public void redefineEchoTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
-
- try {
- e.eval("var echo = {}; if (typeof echo !== 'object') { throw 'echo is a '+typeof echo; }");
- } catch (final Exception exp) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
- @Test
- public void noEnumerablePropertiesTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- try {
- e.eval("for (i in this) { throw 'found property: ' + i }");
- } catch (final Exception exp) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
-
- @Test
- public void noRefErrorForGlobalThisAccessTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- try {
- e.eval("this.foo");
- } catch (final Exception exp) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
-
- @Test
- public void refErrorForUndeclaredAccessTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- try {
- e.eval("try { print(foo); throw 'no ref error' } catch (e) { if (!(e instanceof ReferenceError)) throw e; }");
- } catch (final Exception exp) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
-
- @Test
- public void typeErrorForGlobalThisCallTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- try {
- e.eval("try { this.foo() } catch(e) { if (! (e instanceof TypeError)) throw 'no type error' }");
- } catch (final Exception exp) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
-
- @Test
- public void refErrorForUndeclaredCallTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- try {
- e.eval("try { foo() } catch(e) { if (! (e instanceof ReferenceError)) throw 'no ref error' }");
- } catch (final Exception exp) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
-
- @Test
- // check that print function prints arg followed by newline char
- public void printTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- final StringWriter sw = new StringWriter();
- e.getContext().setWriter(sw);
- try {
- e.eval("print('hello')");
- } catch (final Throwable t) {
- t.printStackTrace();
- fail(t.getMessage());
- }
-
- assertEquals(sw.toString(), println("hello"));
- }
-
- @Test
- // check that print prints all arguments (more than one)
- public void printManyTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- final StringWriter sw = new StringWriter();
- e.getContext().setWriter(sw);
- try {
- e.eval("print(34, true, 'hello')");
- } catch (final Throwable t) {
- t.printStackTrace();
- fail(t.getMessage());
- }
-
- assertEquals(sw.toString(), println("34 true hello"));
- }
-
- @Test
- public void scriptObjectAutoConversionTest() throws ScriptException {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- e.eval("obj = { foo: 'hello' }");
- e.put("Window", e.eval("Packages.jdk.nashorn.api.scripting.Window"));
- assertEquals(e.eval("Window.funcJSObject(obj)"), "hello");
- assertEquals(e.eval("Window.funcScriptObjectMirror(obj)"), "hello");
- assertEquals(e.eval("Window.funcMap(obj)"), "hello");
- assertEquals(e.eval("Window.funcJSObject(obj)"), "hello");
- }
-
- // @bug 8032948: Nashorn linkages awry
- @Test
- public void checkProxyAccess() throws ScriptException {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- final boolean[] reached = new boolean[1];
- final Runnable r = (Runnable)Proxy.newProxyInstance(
- ScriptEngineTest.class.getClassLoader(),
- new Class[] { Runnable.class },
- new InvocationHandler() {
- @Override
- public Object invoke(final Object p, final Method mtd, final Object[] a) {
- reached[0] = true;
- return null;
- }
- });
-
- e.put("r", r);
- e.eval("r.run()");
-
- assertTrue(reached[0]);
- }
-
- // properties that can be read by any code
- private static String[] propNames = {
- "java.version",
- "java.vendor",
- "java.vendor.url",
- "java.class.version",
- "os.name",
- "os.version",
- "os.arch",
- "file.separator",
- "path.separator",
- "line.separator",
- "java.specification.version",
- "java.specification.vendor",
- "java.specification.name",
- "java.vm.specification.version",
- "java.vm.specification.vendor",
- "java.vm.specification.name",
- "java.vm.version",
- "java.vm.vendor",
- "java.vm.name"
- };
-
- // @bug 8033924: Default permissions are not given for eval code
- @Test
- public void checkPropertyReadPermissions() throws ScriptException {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
-
- for (final String name : propNames) {
- checkProperty(e, name);
- }
- }
-
- // @bug 8046013: TypeError: Cannot apply "with" to non script object
- @Test
- public void withOnMirrorTest() throws ScriptException {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
-
- final Object obj = e.eval("({ foo: 'hello'})");
- final Object[] arr = new Object[1];
- arr[0] = obj;
- e.put("arr", arr);
- final Object res = e.eval("var res; with(arr[0]) { res = foo; }; res");
- assertEquals(res, "hello");
- }
-
- // @bug 8054223: Nashorn: AssertionError when use __DIR__ and ScriptEngine.eval()
- @Test
- public void check__DIR__Test() throws ScriptException {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- e.eval("__DIR__");
- }
-
- // @bug 8050432:javax.script.filename variable should not be enumerable
- // with nashorn engine's ENGINE_SCOPE bindings
- @Test
- public void enumerableGlobalsTest() throws ScriptException {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
-
- e.put(ScriptEngine.FILENAME, "test");
- final Object enumerable = e.eval(
- "Object.getOwnPropertyDescriptor(this, " +
- " 'javax.script.filename').enumerable");
- assertEquals(enumerable, Boolean.FALSE);
- }
-
- public static class Context {
- private Object myobj;
-
- public void set(final Object o) {
- myobj = o;
- }
-
- public Object get() {
- return myobj;
- }
- }
-
- // @bug 8050977: Java8 Javascript Nashorn exception:
- // no current Global instance for nashorn
- @Test
- public void currentGlobalMissingTest() throws Exception {
- final ScriptEngineManager manager = new ScriptEngineManager();
- final ScriptEngine e = manager.getEngineByName("nashorn");
-
- final Context ctx = new Context();
- e.put("ctx", ctx);
- e.eval("var obj = { foo: function(str) { return str.toUpperCase() } }");
- e.eval("ctx.set(obj)");
- final Invocable inv = (Invocable)e;
- assertEquals("HELLO", inv.invokeMethod(ctx.get(), "foo", "hello"));
- // try object literal
- e.eval("ctx.set({ bar: function(str) { return str.toLowerCase() } })");
- assertEquals("hello", inv.invokeMethod(ctx.get(), "bar", "HELLO"));
- // try array literal
- e.eval("var arr = [ 'hello', 'world' ]");
- e.eval("ctx.set(arr)");
- assertEquals("helloworld", inv.invokeMethod(ctx.get(), "join", ""));
- }
-
- // @bug 8068524: NashornScriptEngineFactory.getParameter() throws IAE
- // for an unknown key, doesn't conform to the general spec
- @Test
- public void getParameterInvalidKeyTest() throws Exception {
- final ScriptEngineManager manager = new ScriptEngineManager();
- final ScriptEngine e = manager.getEngineByName("nashorn");
- // no exception expected here!
- Object value = e.getFactory().getParameter("no value assigned to this key");
- assertNull(value);
- }
-
- // @bug JDK-8068889: ConsString arguments to a functional interface wasn't converted to string.
- @Test
- public void functionalInterfaceStringTest() throws Exception {
- final ScriptEngineManager manager = new ScriptEngineManager();
- final ScriptEngine e = manager.getEngineByName("nashorn");
- final AtomicBoolean invoked = new AtomicBoolean(false);
- e.put("f", new Function<String, String>() {
- @Override
- public String apply(String t) {
- invoked.set(true);
- return t;
- }
- });
- assertEquals(e.eval("var x = 'a'; x += 'b'; f(x)"), "ab");
- assertTrue(invoked.get());
- }
-
- // @bug JDK-8068889: ScriptObject arguments to a functional interface wasn't converted to a mirror.
- @Test
- public void functionalInterfaceObjectTest() throws Exception {
- final ScriptEngineManager manager = new ScriptEngineManager();
- final ScriptEngine e = manager.getEngineByName("nashorn");
- final AtomicBoolean invoked = new AtomicBoolean(false);
- e.put("c", new Consumer<Object>() {
- @Override
- public void accept(Object t) {
- assertTrue(t instanceof ScriptObjectMirror);
- assertEquals(((ScriptObjectMirror)t).get("a"), "xyz");
- invoked.set(true);
- }
- });
- e.eval("var x = 'xy'; x += 'z';c({a:x})");
- assertTrue(invoked.get());
- }
-
- @Test
- public void testLengthOnArrayLikeObjects() throws Exception {
- final ScriptEngine e = new ScriptEngineManager().getEngineByName("nashorn");
- final Object val = e.eval("var arr = { length: 1, 0: 1}; arr.length");
-
- assertTrue(Number.class.isAssignableFrom(val.getClass()));
- assertTrue(((Number)val).intValue() == 1);
- }
-
- // @bug JDK-8068603: NashornScriptEngine.put/get() impls don't conform to NPE, IAE spec assertions
- @Test
- public void illegalBindingsValuesTest() throws Exception {
- final ScriptEngineManager manager = new ScriptEngineManager();
- final ScriptEngine e = manager.getEngineByName("nashorn");
-
- try {
- e.put(null, "null-value");
- fail();
- } catch (NullPointerException x) {
- // expected
- }
-
- try {
- e.put("", "empty-value");
- fail();
- } catch (IllegalArgumentException x) {
- // expected
- }
-
- final Bindings b = e.getBindings(ScriptContext.ENGINE_SCOPE);
- assertTrue(b instanceof ScriptObjectMirror);
-
- try {
- b.put(null, "null-value");
- fail();
- } catch (NullPointerException x) {
- // expected
- }
-
- try {
- b.put("", "empty-value");
- fail();
- } catch (IllegalArgumentException x) {
- // expected
- }
-
- try {
- b.get(null);
- fail();
- } catch (NullPointerException x) {
- // expected
- }
-
- try {
- b.get("");
- fail();
- } catch (IllegalArgumentException x) {
- // expected
- }
-
- try {
- b.get(1);
- fail();
- } catch (ClassCastException x) {
- // expected
- }
-
- try {
- b.remove(null);
- fail();
- } catch (NullPointerException x) {
- // expected
- }
-
- try {
- b.remove("");
- fail();
- } catch (IllegalArgumentException x) {
- // expected
- }
-
- try {
- b.remove(1);
- fail();
- } catch (ClassCastException x) {
- // expected
- }
-
- try {
- b.containsKey(null);
- fail();
- } catch (NullPointerException x) {
- // expected
- }
-
- try {
- b.containsKey("");
- fail();
- } catch (IllegalArgumentException x) {
- // expected
- }
-
- try {
- b.containsKey(1);
- fail();
- } catch (ClassCastException x) {
- // expected
- }
-
- try {
- b.putAll(null);
- fail();
- } catch (NullPointerException x) {
- // expected
- }
-
- try {
- b.putAll(Collections.singletonMap((String)null, "null-value"));
- fail();
- } catch (NullPointerException x) {
- // expected
- }
-
- try {
- b.putAll(Collections.singletonMap("", "empty-value"));
- fail();
- } catch (IllegalArgumentException x) {
- // expected
- }
- }
-
- // @bug 8071989: NashornScriptEngine returns javax.script.ScriptContext instance
- // with insonsistent get/remove methods behavior for undefined attributes
- @Test
- public void testScriptContextGetRemoveUndefined() throws Exception {
- final ScriptEngineManager manager = new ScriptEngineManager();
- final ScriptEngine e = manager.getEngineByName("nashorn");
- final ScriptContext ctx = e.getContext();
- assertNull(ctx.getAttribute("undefinedname", ScriptContext.ENGINE_SCOPE));
- assertNull(ctx.removeAttribute("undefinedname", ScriptContext.ENGINE_SCOPE));
- }
-
- private static void checkProperty(final ScriptEngine e, final String name)
- throws ScriptException {
- final String value = System.getProperty(name);
- e.put("name", name);
- assertEquals(value, e.eval("java.lang.System.getProperty(name)"));
- }
-
- private static final String LINE_SEPARATOR = System.getProperty("line.separator");
-
- // Returns String that would be the result of calling PrintWriter.println
- // of the given String. (This is to handle platform specific newline).
- private static String println(final String str) {
- return str + LINE_SEPARATOR;
- }
-}
--- a/nashorn/test/src/jdk/nashorn/api/scripting/ScriptObjectMirrorTest.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,387 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.scripting;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
-
-import java.nio.ByteBuffer;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.function.Function;
-import javax.script.Bindings;
-import javax.script.Invocable;
-import javax.script.ScriptContext;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
-import javax.script.ScriptException;
-import org.testng.annotations.Test;
-
-/**
- * Tests to check jdk.nashorn.api.scripting.ScriptObjectMirror API.
- */
-@SuppressWarnings("javadoc")
-public class ScriptObjectMirrorTest {
-
- @SuppressWarnings("unchecked")
- @Test
- public void reflectionTest() throws ScriptException {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
-
- e.eval("var obj = { x: 344, y: 'nashorn' }");
-
- int count = 0;
- Map<Object, Object> map = (Map<Object, Object>) e.get("obj");
- assertFalse(map.isEmpty());
- assertTrue(map.keySet().contains("x"));
- assertTrue(map.containsKey("x"));
- assertTrue(map.values().contains("nashorn"));
- assertTrue(map.containsValue("nashorn"));
- for (final Map.Entry<?, ?> ex : map.entrySet()) {
- final Object key = ex.getKey();
- if (key.equals("x")) {
- assertTrue(344 == ((Number) ex.getValue()).doubleValue());
- count++;
- } else if (key.equals("y")) {
- assertEquals(ex.getValue(), "nashorn");
- count++;
- }
- }
- assertEquals(2, count);
- assertEquals(2, map.size());
-
- // add property
- map.put("z", "hello");
- assertEquals(e.eval("obj.z"), "hello");
- assertEquals(map.get("z"), "hello");
- assertTrue(map.keySet().contains("z"));
- assertTrue(map.containsKey("z"));
- assertTrue(map.values().contains("hello"));
- assertTrue(map.containsValue("hello"));
- assertEquals(map.size(), 3);
-
- final Map<Object, Object> newMap = new HashMap<>();
- newMap.put("foo", 23.0);
- newMap.put("bar", true);
- map.putAll(newMap);
-
- assertEquals(e.eval("obj.foo"), 23.0);
- assertEquals(e.eval("obj.bar"), true);
-
- // remove using map method
- map.remove("foo");
- assertEquals(e.eval("typeof obj.foo"), "undefined");
-
- count = 0;
- e.eval("var arr = [ true, 'hello' ]");
- map = (Map<Object, Object>) e.get("arr");
- assertFalse(map.isEmpty());
- assertTrue(map.containsKey("length"));
- assertTrue(map.containsValue("hello"));
- for (final Map.Entry<?, ?> ex : map.entrySet()) {
- final Object key = ex.getKey();
- if (key.equals("0")) {
- assertEquals(ex.getValue(), Boolean.TRUE);
- count++;
- } else if (key.equals("1")) {
- assertEquals(ex.getValue(), "hello");
- count++;
- }
- }
- assertEquals(count, 2);
- assertEquals(map.size(), 2);
-
- // add element
- map.put("2", "world");
- assertEquals(map.get("2"), "world");
- assertEquals(map.size(), 3);
-
- // remove all
- map.clear();
- assertTrue(map.isEmpty());
- assertEquals(e.eval("typeof arr[0]"), "undefined");
- assertEquals(e.eval("typeof arr[1]"), "undefined");
- assertEquals(e.eval("typeof arr[2]"), "undefined");
- }
-
- @Test
- public void jsobjectTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- try {
- e.eval("var obj = { '1': 'world', func: function() { return this.bar; }, bar: 'hello' }");
- final ScriptObjectMirror obj = (ScriptObjectMirror) e.get("obj");
-
- // try basic get on existing properties
- if (!obj.getMember("bar").equals("hello")) {
- fail("obj.bar != 'hello'");
- }
-
- if (!obj.getSlot(1).equals("world")) {
- fail("obj[1] != 'world'");
- }
-
- if (!obj.callMember("func", new Object[0]).equals("hello")) {
- fail("obj.func() != 'hello'");
- }
-
- // try setting properties
- obj.setMember("bar", "new-bar");
- obj.setSlot(1, "new-element-1");
- if (!obj.getMember("bar").equals("new-bar")) {
- fail("obj.bar != 'new-bar'");
- }
-
- if (!obj.getSlot(1).equals("new-element-1")) {
- fail("obj[1] != 'new-element-1'");
- }
-
- // try adding properties
- obj.setMember("prop", "prop-value");
- obj.setSlot(12, "element-12");
- if (!obj.getMember("prop").equals("prop-value")) {
- fail("obj.prop != 'prop-value'");
- }
-
- if (!obj.getSlot(12).equals("element-12")) {
- fail("obj[12] != 'element-12'");
- }
-
- // delete properties
- obj.removeMember("prop");
- if ("prop-value".equals(obj.getMember("prop"))) {
- fail("obj.prop is not deleted!");
- }
-
- // Simple eval tests
- assertEquals(obj.eval("typeof Object"), "function");
- assertEquals(obj.eval("'nashorn'.substring(3)"), "horn");
- } catch (final Exception exp) {
- exp.printStackTrace();
- fail(exp.getMessage());
- }
- }
-
- @Test
- public void scriptObjectMirrorToStringTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- try {
- final Object obj = e.eval("new TypeError('wrong type')");
- assertEquals(obj.toString(), "TypeError: wrong type", "toString returns wrong value");
- } catch (final Throwable t) {
- t.printStackTrace();
- fail(t.getMessage());
- }
-
- try {
- final Object obj = e.eval("function func() { print('hello'); }");
- assertEquals(obj.toString(), "function func() { print('hello'); }", "toString returns wrong value");
- } catch (final Throwable t) {
- t.printStackTrace();
- fail(t.getMessage());
- }
- }
-
- @Test
- public void mirrorNewObjectGlobalFunctionTest() throws ScriptException {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- final ScriptEngine e2 = m.getEngineByName("nashorn");
-
- e.eval("function func() {}");
- e2.put("foo", e.get("func"));
- final ScriptObjectMirror e2global = (ScriptObjectMirror)e2.eval("this");
- final Object newObj = ((ScriptObjectMirror)e2global.getMember("foo")).newObject();
- assertTrue(newObj instanceof ScriptObjectMirror);
- }
-
- @Test
- public void mirrorNewObjectInstanceFunctionTest() throws ScriptException {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- final ScriptEngine e2 = m.getEngineByName("nashorn");
-
- e.eval("function func() {}");
- e2.put("func", e.get("func"));
- final ScriptObjectMirror e2obj = (ScriptObjectMirror)e2.eval("({ foo: func })");
- final Object newObj = ((ScriptObjectMirror)e2obj.getMember("foo")).newObject();
- assertTrue(newObj instanceof ScriptObjectMirror);
- }
-
- @Test
- public void indexPropertiesExternalBufferTest() throws ScriptException {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- final ScriptObjectMirror obj = (ScriptObjectMirror)e.eval("var obj = {}; obj");
- final ByteBuffer buf = ByteBuffer.allocate(5);
- int i;
- for (i = 0; i < 5; i++) {
- buf.put(i, (byte)(i+10));
- }
- obj.setIndexedPropertiesToExternalArrayData(buf);
-
- for (i = 0; i < 5; i++) {
- assertEquals((byte)(i+10), ((Number)e.eval("obj[" + i + "]")).byteValue());
- }
-
- e.eval("for (i = 0; i < 5; i++) obj[i] = 0");
- for (i = 0; i < 5; i++) {
- assertEquals((byte)0, ((Number)e.eval("obj[" + i + "]")).byteValue());
- assertEquals((byte)0, buf.get(i));
- }
- }
-
- @Test
- public void conversionTest() throws ScriptException {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- final ScriptObjectMirror arr = (ScriptObjectMirror)e.eval("[33, 45, 23]");
- final int[] intArr = arr.to(int[].class);
- assertEquals(intArr[0], 33);
- assertEquals(intArr[1], 45);
- assertEquals(intArr[2], 23);
-
- final List<?> list = arr.to(List.class);
- assertEquals(list.get(0), 33);
- assertEquals(list.get(1), 45);
- assertEquals(list.get(2), 23);
-
- ScriptObjectMirror obj = (ScriptObjectMirror)e.eval(
- "({ valueOf: function() { return 42 } })");
- assertEquals(Double.valueOf(42.0), obj.to(Double.class));
-
- obj = (ScriptObjectMirror)e.eval(
- "({ toString: function() { return 'foo' } })");
- assertEquals("foo", obj.to(String.class));
- }
-
- // @bug 8044000: Access to undefined property yields "null" instead of "undefined"
- @Test
- public void mapScriptObjectMirrorCallsiteTest() throws ScriptException {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine engine = m.getEngineByName("nashorn");
- final String TEST_SCRIPT = "typeof obj.foo";
-
- final Bindings global = engine.getContext().getBindings(ScriptContext.ENGINE_SCOPE);
- engine.eval("var obj = java.util.Collections.emptyMap()");
- // this will drive callsite "obj.foo" of TEST_SCRIPT
- // to use "obj instanceof Map" as it's guard
- engine.eval(TEST_SCRIPT, global);
- // redefine 'obj' to be a script object
- engine.eval("obj = {}");
-
- final Bindings newGlobal = engine.createBindings();
- // transfer 'obj' from default global to new global
- // new global will get a ScriptObjectMirror wrapping 'obj'
- newGlobal.put("obj", global.get("obj"));
-
- // Every ScriptObjectMirror is a Map! If callsite "obj.foo"
- // does not see the new 'obj' is a ScriptObjectMirror, it'll
- // continue to use Map's get("obj.foo") instead of ScriptObjectMirror's
- // getMember("obj.foo") - thereby getting null instead of undefined
- assertEquals("undefined", engine.eval(TEST_SCRIPT, newGlobal));
- }
-
- public interface MirrorCheckExample {
- Object test1(Object arg);
- Object test2(Object arg);
- boolean compare(Object o1, Object o2);
- }
-
- // @bug 8053910: ScriptObjectMirror causing havoc with Invocation interface
- @Test
- public void checkMirrorToObject() throws Exception {
- final ScriptEngineManager engineManager = new ScriptEngineManager();
- final ScriptEngine engine = engineManager.getEngineByName("nashorn");
- final Invocable invocable = (Invocable)engine;
-
- engine.eval("function test1(arg) { return { arg: arg }; }");
- engine.eval("function test2(arg) { return arg; }");
- engine.eval("function compare(arg1, arg2) { return arg1 == arg2; }");
-
- final Map<String, Object> map = new HashMap<>();
- map.put("option", true);
-
- final MirrorCheckExample example = invocable.getInterface(MirrorCheckExample.class);
-
- final Object value1 = invocable.invokeFunction("test1", map);
- final Object value2 = example.test1(map);
- final Object value3 = invocable.invokeFunction("test2", value2);
- final Object value4 = example.test2(value2);
-
- // check that Object type argument receives a ScriptObjectMirror
- // when ScriptObject is passed
- assertEquals(ScriptObjectMirror.class, value1.getClass());
- assertEquals(ScriptObjectMirror.class, value2.getClass());
- assertEquals(ScriptObjectMirror.class, value3.getClass());
- assertEquals(ScriptObjectMirror.class, value4.getClass());
- assertTrue((boolean)invocable.invokeFunction("compare", value1, value1));
- assertTrue(example.compare(value1, value1));
- assertTrue((boolean)invocable.invokeFunction("compare", value3, value4));
- assertTrue(example.compare(value3, value4));
- }
-
- // @bug 8053910: ScriptObjectMirror causing havoc with Invocation interface
- @Test
- public void mirrorUnwrapInterfaceMethod() throws Exception {
- final ScriptEngineManager engineManager = new ScriptEngineManager();
- final ScriptEngine engine = engineManager.getEngineByName("nashorn");
- final Invocable invocable = (Invocable)engine;
- engine.eval("function apply(obj) { " +
- " return obj instanceof Packages.jdk.nashorn.api.scripting.ScriptObjectMirror; " +
- "}");
- @SuppressWarnings("unchecked")
- final Function<Object,Object> func = invocable.getInterface(Function.class);
- assertFalse((boolean)func.apply(engine.eval("({ x: 2 })")));
- }
-
- // @bug 8055687: Wrong "this" passed to JSObject.eval call
- @Test
- public void checkThisForJSObjectEval() throws Exception {
- final ScriptEngineManager engineManager = new ScriptEngineManager();
- final ScriptEngine e = engineManager.getEngineByName("nashorn");
- final JSObject jsobj = (JSObject)e.eval("({foo: 23, bar: 'hello' })");
- assertEquals(((Number)jsobj.eval("this.foo")).intValue(), 23);
- assertEquals(jsobj.eval("this.bar"), "hello");
- assertEquals(jsobj.eval("String(this)"), "[object Object]");
- final Object global = e.eval("this");
- assertFalse(global.equals(jsobj.eval("this")));
- }
-
- @Test
- public void topLevelAnonFuncStatement() throws Exception {
- final ScriptEngineManager engineManager = new ScriptEngineManager();
- final ScriptEngine e = engineManager.getEngineByName("nashorn");
- final JSObject func = (JSObject)e.eval("function(x) { return x + ' world' }");
- assertTrue(func.isFunction());
- assertEquals(func.call(e.eval("this"), "hello"), "hello world");
- }
-}
--- a/nashorn/test/src/jdk/nashorn/api/scripting/VariableArityTestInterface.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.scripting;
-
-@SuppressWarnings("javadoc")
-public interface VariableArityTestInterface {
- public String test1(int i, String... strings);
- public String test2(int i, String... strings);
-}
--- a/nashorn/test/src/jdk/nashorn/api/scripting/Window.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.scripting;
-
-import java.util.Map;
-import javax.script.Bindings;
-
-@SuppressWarnings("javadoc")
-public class Window {
-
- private String location = "http://localhost:8080/window";
-
- private WindowEventHandler onload = null;
-
- public void alert(final String message) {
- System.out.println("alert: " + message);
- }
-
- public String getLocation() {
- return location;
- }
-
- public void setLocation(final String location) {
- this.location = location;
- }
-
- public String item(final int index) {
- return Integer.toHexString(index);
- }
-
- public WindowEventHandler getOnload() {
- return onload;
- }
-
- public void setOnload(final WindowEventHandler onload) {
- this.onload = onload;
- }
-
- public static int setTimeout(final Window self, final String code, final int delay) {
- return self.setTimeout(code, delay);
- }
-
- public int setTimeout(final String code, final int delay) {
- System.out.println("window.setTimeout: " + delay + ", code: " + code);
- return 0;
- }
-
- public static Object funcJSObject(final JSObject jsobj) {
- return jsobj.getMember("foo");
- }
-
- public static Object funcScriptObjectMirror(final ScriptObjectMirror sobj) {
- return sobj.get("foo");
- }
-
- public static Object funcMap(final Map<?,?> map) {
- return map.get("foo");
- }
-
- public static Object funcBindings(final Bindings bindings) {
- return bindings.get("foo");
- }
-}
--- a/nashorn/test/src/jdk/nashorn/api/scripting/WindowEventHandler.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.api.scripting;
-
-@SuppressWarnings("javadoc")
-public interface WindowEventHandler {
- public boolean loaded();
-}
--- a/nashorn/test/src/jdk/nashorn/api/scripting/resources/func.js Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-// This script is loaded from jdk.nashorn.api.scripting.ScopeTest to test script class sharing and reuse.
-
-var scopeVar = 1;
-var global = this;
-undefGlobal = this;
-
-function scopeTest() {
- if (this !== global) {
- throw new Error("this !== global");
- }
- if (this !== undefGlobal) {
- throw new Error("this !== undefinedGlobal")
- }
- return scopeVar;
-}
-
-scopeTest();
--- a/nashorn/test/src/jdk/nashorn/api/scripting/resources/gettersetter.js Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-// This script is loaded from jdk.nashorn.api.scripting.ScopeTest to test script class sharing and reuse.
-
-var v;
-
-Object.defineProperty(this, "accessor1", {
- get: function() { return v; },
- set: function(n) { v = n; }
-});
-
-Object.defineProperty(this, "accessor2", {
- get: function() { return x; },
- set: function(n) { x = n; }
-});
--- a/nashorn/test/src/jdk/nashorn/api/scripting/resources/witheval.js Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-// This script is loaded from jdk.nashorn.api.scripting.ScopeTest to test script class sharing and reuse.
-
-var a;
-
-function outer(p, e) {
- eval(e);
- with(p) {
- function inner() {
- a = 1;
- c = 10;
- if (a !== 1) {
- throw new Error("a !== 1");
- }
- if (b !== 3) {
- throw new Error("b !== 3");
- }
- if (c !== 10) {
- throw new Error("c !== 10");
- }
- }
- inner();
- }
-}
-
-outer({}, "b = 3;");
-
-if (a !== 1) {
- throw new Error("a !== 1");
-}
-if (b !== 3) {
- throw new Error("b !== 3");
-}
-if (c !== 10) {
- throw new Error("c !== 10");
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/api/scripting/test/InvocableTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,539 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.scripting.test;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.fail;
+import java.util.Objects;
+import java.util.function.Function;
+import javax.script.Invocable;
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import javax.script.SimpleScriptContext;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * Tests for javax.script.Invocable implementation of nashorn.
+ */
+@SuppressWarnings("javadoc")
+public class InvocableTest {
+
+ private static void log(final String msg) {
+ org.testng.Reporter.log(msg, true);
+ }
+
+ @Test
+ public void invokeMethodTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+
+ try {
+ e.eval("var Example = function() { this.hello = function() { return 'Hello World!'; };}; myExample = new Example();");
+ final Object obj = e.get("myExample");
+ final Object res = ((Invocable) e).invokeMethod(obj, "hello");
+ assertEquals(res, "Hello World!");
+ } catch (final Exception exp) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+
+ @Test
+ /**
+ * Check that we can call invokeMethod on an object that we got by
+ * evaluating script with different Context set.
+ */
+ public void invokeMethodDifferentContextTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+
+ try {
+ // define an object with method on it
+ final Object obj = e.eval("({ hello: function() { return 'Hello World!'; } })");
+
+ final ScriptContext ctxt = new SimpleScriptContext();
+ ctxt.setBindings(e.createBindings(), ScriptContext.ENGINE_SCOPE);
+ e.setContext(ctxt);
+
+ // invoke 'func' on obj - but with current script context changed
+ final Object res = ((Invocable) e).invokeMethod(obj, "hello");
+ assertEquals(res, "Hello World!");
+ } catch (final Exception exp) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+
+ @Test
+ /**
+ * Check that invokeMethod throws NPE on null method name.
+ */
+ public void invokeMethodNullNameTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+
+ try {
+ final Object obj = e.eval("({})");
+ ((Invocable) e).invokeMethod(obj, null);
+ fail("should have thrown NPE");
+ } catch (final Exception exp) {
+ if (!(exp instanceof NullPointerException)) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+ }
+
+ @Test
+ /**
+ * Check that invokeMethod throws NoSuchMethodException on missing method.
+ */
+ public void invokeMethodMissingTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+
+ try {
+ final Object obj = e.eval("({})");
+ ((Invocable) e).invokeMethod(obj, "nonExistentMethod");
+ fail("should have thrown NoSuchMethodException");
+ } catch (final Exception exp) {
+ if (!(exp instanceof NoSuchMethodException)) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+ }
+
+ @Test
+ /**
+ * Check that calling method on non-script object 'thiz' results in
+ * IllegalArgumentException.
+ */
+ public void invokeMethodNonScriptObjectThizTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+
+ try {
+ ((Invocable) e).invokeMethod(new Object(), "toString");
+ fail("should have thrown IllegalArgumentException");
+ } catch (final Exception exp) {
+ if (!(exp instanceof IllegalArgumentException)) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+ }
+
+ @Test
+ /**
+ * Check that calling method on null 'thiz' results in
+ * IllegalArgumentException.
+ */
+ public void invokeMethodNullThizTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+
+ try {
+ ((Invocable) e).invokeMethod(null, "toString");
+ fail("should have thrown IllegalArgumentException");
+ } catch (final Exception exp) {
+ if (!(exp instanceof IllegalArgumentException)) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+ }
+
+ @Test
+ /**
+ * Check that calling method on mirror created by another engine results in
+ * IllegalArgumentException.
+ */
+ public void invokeMethodMixEnginesTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine engine1 = m.getEngineByName("nashorn");
+ final ScriptEngine engine2 = m.getEngineByName("nashorn");
+
+ try {
+ final Object obj = engine1.eval("({ run: function() {} })");
+ // pass object from engine1 to engine2 as 'thiz' for invokeMethod
+ ((Invocable) engine2).invokeMethod(obj, "run");
+ fail("should have thrown IllegalArgumentException");
+ } catch (final Exception exp) {
+ if (!(exp instanceof IllegalArgumentException)) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+ }
+
+ @Test
+ public void getInterfaceTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final Invocable inv = (Invocable) e;
+
+ // try to get interface from global functions
+ try {
+ e.eval("function run() { print('run'); };");
+ final Runnable runnable = inv.getInterface(Runnable.class);
+ runnable.run();
+ } catch (final Exception exp) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+
+ // try interface on specific script object
+ try {
+ e.eval("var obj = { run: function() { print('run from obj'); } };");
+ final Object obj = e.get("obj");
+ final Runnable runnable = inv.getInterface(obj, Runnable.class);
+ runnable.run();
+ } catch (final Exception exp) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+
+ public interface Foo {
+
+ public void bar();
+ }
+
+ public interface Foo2 extends Foo {
+
+ public void bar2();
+ }
+
+ @Test
+ public void getInterfaceMissingTest() {
+ final ScriptEngineManager manager = new ScriptEngineManager();
+ final ScriptEngine engine = manager.getEngineByName("nashorn");
+
+ // don't define any function.
+ try {
+ engine.eval("");
+ } catch (final Exception exp) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+
+ Runnable runnable = ((Invocable) engine).getInterface(Runnable.class);
+ if (runnable != null) {
+ fail("runnable is not null!");
+ }
+
+ // now define "run"
+ try {
+ engine.eval("function run() { print('this is run function'); }");
+ } catch (final Exception exp) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ runnable = ((Invocable) engine).getInterface(Runnable.class);
+ // should not return null now!
+ runnable.run();
+
+ // define only one method of "Foo2"
+ try {
+ engine.eval("function bar() { print('bar function'); }");
+ } catch (final Exception exp) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+
+ Foo2 foo2 = ((Invocable) engine).getInterface(Foo2.class);
+ if (foo2 != null) {
+ throw new RuntimeException("foo2 is not null!");
+ }
+
+ // now define other method of "Foo2"
+ try {
+ engine.eval("function bar2() { print('bar2 function'); }");
+ } catch (final Exception exp) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ foo2 = ((Invocable) engine).getInterface(Foo2.class);
+ foo2.bar();
+ foo2.bar2();
+ }
+
+ @Test
+ /**
+ * Try passing non-interface Class object for interface implementation.
+ */
+ public void getNonInterfaceGetInterfaceTest() {
+ final ScriptEngineManager manager = new ScriptEngineManager();
+ final ScriptEngine engine = manager.getEngineByName("nashorn");
+ try {
+ log(Objects.toString(((Invocable) engine).getInterface(Object.class)));
+ fail("Should have thrown IllegalArgumentException");
+ } catch (final Exception exp) {
+ if (!(exp instanceof IllegalArgumentException)) {
+ fail("IllegalArgumentException expected, got " + exp);
+ }
+ }
+ }
+
+ @Test
+ /**
+ * Check that we can get interface out of a script object even after
+ * switching to use different ScriptContext.
+ */
+ public void getInterfaceDifferentContext() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ try {
+ final Object obj = e.eval("({ run: function() { } })");
+
+ // change script context
+ final ScriptContext ctxt = new SimpleScriptContext();
+ ctxt.setBindings(e.createBindings(), ScriptContext.ENGINE_SCOPE);
+ e.setContext(ctxt);
+
+ final Runnable r = ((Invocable) e).getInterface(obj, Runnable.class);
+ r.run();
+ } catch (final Exception exp) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+
+ @Test
+ /**
+ * Check that getInterface on non-script object 'thiz' results in
+ * IllegalArgumentException.
+ */
+ public void getInterfaceNonScriptObjectThizTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+
+ try {
+ ((Invocable) e).getInterface(new Object(), Runnable.class);
+ fail("should have thrown IllegalArgumentException");
+ } catch (final Exception exp) {
+ if (!(exp instanceof IllegalArgumentException)) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+ }
+
+ @Test
+ /**
+ * Check that getInterface on null 'thiz' results in
+ * IllegalArgumentException.
+ */
+ public void getInterfaceNullThizTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+
+ try {
+ ((Invocable) e).getInterface(null, Runnable.class);
+ fail("should have thrown IllegalArgumentException");
+ } catch (final Exception exp) {
+ if (!(exp instanceof IllegalArgumentException)) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+ }
+
+ @Test
+ /**
+ * Check that calling getInterface on mirror created by another engine
+ * results in IllegalArgumentException.
+ */
+ public void getInterfaceMixEnginesTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine engine1 = m.getEngineByName("nashorn");
+ final ScriptEngine engine2 = m.getEngineByName("nashorn");
+
+ try {
+ final Object obj = engine1.eval("({ run: function() {} })");
+ // pass object from engine1 to engine2 as 'thiz' for getInterface
+ ((Invocable) engine2).getInterface(obj, Runnable.class);
+ fail("should have thrown IllegalArgumentException");
+ } catch (final Exception exp) {
+ if (!(exp instanceof IllegalArgumentException)) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+ }
+
+ @Test
+ /**
+ * check that null function name results in NPE.
+ */
+ public void invokeFunctionNullNameTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+
+ try {
+ ((Invocable)e).invokeFunction(null);
+ fail("should have thrown NPE");
+ } catch (final Exception exp) {
+ if (!(exp instanceof NullPointerException)) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+ }
+
+ @Test
+ /**
+ * Check that attempt to call missing function results in
+ * NoSuchMethodException.
+ */
+ public void invokeFunctionMissingTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+
+ try {
+ ((Invocable)e).invokeFunction("NonExistentFunc");
+ fail("should have thrown NoSuchMethodException");
+ } catch (final Exception exp) {
+ if (!(exp instanceof NoSuchMethodException)) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+ }
+
+ @Test
+ /**
+ * Check that invokeFunction calls functions only from current context's
+ * Bindings.
+ */
+ public void invokeFunctionDifferentContextTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+
+ try {
+ // define an object with method on it
+ e.eval("function hello() { return 'Hello World!'; }");
+ final ScriptContext ctxt = new SimpleScriptContext();
+ ctxt.setBindings(e.createBindings(), ScriptContext.ENGINE_SCOPE);
+ // change engine's current context
+ e.setContext(ctxt);
+
+ ((Invocable) e).invokeFunction("hello"); // no 'hello' in new context!
+ fail("should have thrown NoSuchMethodException");
+ } catch (final Exception exp) {
+ if (!(exp instanceof NoSuchMethodException)) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+ }
+
+ @Test
+ public void invokeFunctionExceptionTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ try {
+ e.eval("function func() { throw new TypeError(); }");
+ } catch (final Throwable t) {
+ t.printStackTrace();
+ fail(t.getMessage());
+ }
+
+ try {
+ ((Invocable) e).invokeFunction("func");
+ fail("should have thrown exception");
+ } catch (final ScriptException se) {
+ // ECMA TypeError property wrapped as a ScriptException
+ log("got " + se + " as expected");
+ } catch (final Throwable t) {
+ t.printStackTrace();
+ fail(t.getMessage());
+ }
+ }
+
+ @Test
+ public void invokeMethodExceptionTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ try {
+ e.eval("var sobj = {}; sobj.foo = function func() { throw new TypeError(); }");
+ } catch (final Throwable t) {
+ t.printStackTrace();
+ fail(t.getMessage());
+ }
+
+ try {
+ final Object sobj = e.get("sobj");
+ ((Invocable) e).invokeMethod(sobj, "foo");
+ fail("should have thrown exception");
+ } catch (final ScriptException se) {
+ // ECMA TypeError property wrapped as a ScriptException
+ log("got " + se + " as expected");
+ } catch (final Throwable t) {
+ t.printStackTrace();
+ fail(t.getMessage());
+ }
+ }
+
+ @Test
+ /**
+ * Tests whether invocation of a JavaScript method through a variable arity
+ * Java method will pass the vararg array. Both non-vararg and vararg
+ * JavaScript methods are tested.
+ *
+ * @throws ScriptException
+ */
+ public void variableArityInterfaceTest() throws ScriptException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ e.eval(
+ "function test1(i, strings) {"
+ + " return 'i == ' + i + ', strings instanceof java.lang.String[] == ' + (strings instanceof Java.type('java.lang.String[]')) + ', strings == ' + java.util.Arrays.toString(strings)"
+ + "}"
+ + "function test2() {"
+ + " return 'arguments[0] == ' + arguments[0] + ', arguments[1] instanceof java.lang.String[] == ' + (arguments[1] instanceof Java.type('java.lang.String[]')) + ', arguments[1] == ' + java.util.Arrays.toString(arguments[1])"
+ + "}");
+ final VariableArityTestInterface itf = ((Invocable) e).getInterface(VariableArityTestInterface.class);
+ Assert.assertEquals(itf.test1(42, "a", "b"), "i == 42, strings instanceof java.lang.String[] == true, strings == [a, b]");
+ Assert.assertEquals(itf.test2(44, "c", "d", "e"), "arguments[0] == 44, arguments[1] instanceof java.lang.String[] == true, arguments[1] == [c, d, e]");
+ }
+
+ @Test
+ public void defaultMethodTest() throws ScriptException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final Invocable inv = (Invocable) e;
+
+ final Object obj = e.eval("({ apply: function(arg) { return arg.toUpperCase(); }})");
+ @SuppressWarnings("unchecked")
+ final Function<String, String> func = inv.getInterface(obj, Function.class);
+ assertEquals(func.apply("hello"), "HELLO");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/api/scripting/test/MultipleEngineTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.scripting.test;
+
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import org.testng.annotations.Test;
+
+/**
+ * Test that we can create multiple, independent script engines and use those
+ * independently.
+ *
+ * @test
+ * @run testng jdk.nashorn.api.scripting.test.MultipleEngineTest
+ */
+@SuppressWarnings("javadoc")
+public class MultipleEngineTest {
+ @Test
+ public void createAndUseManyEngine() throws ScriptException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+
+ final ScriptEngine e1 = m.getEngineByName("nashorn");
+ e1.eval("var x = 33; print(x);");
+
+ final ScriptEngine e2 = m.getEngineByName("nashorn");
+ e2.eval("try { print(x) } catch(e) { print(e); }");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/api/scripting/test/PluggableJSObjectTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,289 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.scripting.test;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.fail;
+
+import java.nio.IntBuffer;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Set;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import jdk.nashorn.api.scripting.AbstractJSObject;
+import org.testng.annotations.Test;
+
+/**
+ * Tests for pluggable external impls. of jdk.nashorn.api.scripting.JSObject.
+ *
+ * JDK-8024615: Refactor ScriptObjectMirror and JSObject to support external
+ * JSObject implementations.
+ */
+@SuppressWarnings("javadoc")
+public class PluggableJSObjectTest {
+ public static class MapWrapperObject extends AbstractJSObject {
+ private final HashMap<String, Object> map = new LinkedHashMap<>();
+
+ public HashMap<String, Object> getMap() {
+ return map;
+ }
+
+ @Override
+ public Object getMember(final String name) {
+ return map.get(name);
+ }
+
+ @Override
+ public void setMember(final String name, final Object value) {
+ map.put(name, value);
+ }
+
+ @Override
+ public boolean hasMember(final String name) {
+ return map.containsKey(name);
+ }
+
+ @Override
+ public void removeMember(final String name) {
+ map.remove(name);
+ }
+
+ @Override
+ public Set<String> keySet() {
+ return map.keySet();
+ }
+
+ @Override
+ public Collection<Object> values() {
+ return map.values();
+ }
+ }
+
+ @Test
+ // Named property access on a JSObject
+ public void namedAccessTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ try {
+ final MapWrapperObject obj = new MapWrapperObject();
+ e.put("obj", obj);
+ obj.getMap().put("foo", "bar");
+
+ // property-like access on MapWrapperObject objects
+ assertEquals(e.eval("obj.foo"), "bar");
+ e.eval("obj.foo = 'hello'");
+ assertEquals(e.eval("'foo' in obj"), Boolean.TRUE);
+ assertEquals(e.eval("obj.foo"), "hello");
+ assertEquals(obj.getMap().get("foo"), "hello");
+ e.eval("delete obj.foo");
+ assertFalse(obj.getMap().containsKey("foo"));
+ assertEquals(e.eval("'foo' in obj"), Boolean.FALSE);
+ } catch (final Exception exp) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+
+ // @bug 8062030: Nashorn bug retrieving array property after key string concatenation
+ @Test
+ // ConsString attribute access on a JSObject
+ public void consStringTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ try {
+ final MapWrapperObject obj = new MapWrapperObject();
+ e.put("obj", obj);
+ e.put("f", "f");
+ e.eval("obj[f + 'oo'] = 'bar';");
+
+ assertEquals(obj.getMap().get("foo"), "bar");
+ assertEquals(e.eval("obj[f + 'oo']"), "bar");
+ assertEquals(e.eval("obj['foo']"), "bar");
+ assertEquals(e.eval("f + 'oo' in obj"), Boolean.TRUE);
+ assertEquals(e.eval("'foo' in obj"), Boolean.TRUE);
+ e.eval("delete obj[f + 'oo']");
+ assertFalse(obj.getMap().containsKey("foo"));
+ assertEquals(e.eval("obj[f + 'oo']"), null);
+ assertEquals(e.eval("obj['foo']"), null);
+ assertEquals(e.eval("f + 'oo' in obj"), Boolean.FALSE);
+ assertEquals(e.eval("'foo' in obj"), Boolean.FALSE);
+ } catch (final Exception exp) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+
+ public static class BufferObject extends AbstractJSObject {
+ private final IntBuffer buf;
+
+ public BufferObject(final int size) {
+ buf = IntBuffer.allocate(size);
+ }
+
+ public IntBuffer getBuffer() {
+ return buf;
+ }
+
+ @Override
+ public Object getMember(final String name) {
+ return name.equals("length")? buf.capacity() : null;
+ }
+
+ @Override
+ public boolean hasSlot(final int i) {
+ return i > -1 && i < buf.capacity();
+ }
+
+ @Override
+ public Object getSlot(final int i) {
+ return buf.get(i);
+ }
+
+ @Override
+ public void setSlot(final int i, final Object value) {
+ buf.put(i, ((Number)value).intValue());
+ }
+
+ @Override
+ public boolean isArray() {
+ return true;
+ }
+ }
+
+ @Test
+ // array-like indexed access for a JSObject
+ public void indexedAccessTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ try {
+ final BufferObject buf = new BufferObject(2);
+ e.put("buf", buf);
+
+ // array-like access on BufferObject objects
+ assertEquals(e.eval("buf.length"), buf.getBuffer().capacity());
+ e.eval("buf[0] = 23");
+ assertEquals(buf.getBuffer().get(0), 23);
+ assertEquals(e.eval("buf[0]"), 23);
+ assertEquals(e.eval("buf[1]"), 0);
+ buf.getBuffer().put(1, 42);
+ assertEquals(e.eval("buf[1]"), 42);
+ assertEquals(e.eval("Array.isArray(buf)"), Boolean.TRUE);
+ } catch (final Exception exp) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+
+ public static class Adder extends AbstractJSObject {
+ @Override
+ public Object call(final Object thiz, final Object... args) {
+ double res = 0.0;
+ for (final Object arg : args) {
+ res += ((Number)arg).doubleValue();
+ }
+ return res;
+ }
+
+ @Override
+ public boolean isFunction() {
+ return true;
+ }
+ }
+
+ @Test
+ // a callable JSObject
+ public void callableJSObjectTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ try {
+ e.put("sum", new Adder());
+ // check callability of Adder objects
+ assertEquals(e.eval("typeof sum"), "function");
+ assertEquals(((Number)e.eval("sum(1, 2, 3, 4, 5)")).intValue(), 15);
+ } catch (final Exception exp) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+
+ public static class Factory extends AbstractJSObject {
+ @SuppressWarnings("unused")
+ @Override
+ public Object newObject(final Object... args) {
+ return new HashMap<Object, Object>();
+ }
+
+ @Override
+ public boolean isFunction() {
+ return true;
+ }
+ }
+
+ @Test
+ // a factory JSObject
+ public void factoryJSObjectTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ try {
+ e.put("Factory", new Factory());
+
+ // check new on Factory
+ assertEquals(e.eval("typeof Factory"), "function");
+ assertEquals(e.eval("typeof new Factory()"), "object");
+ assertEquals(e.eval("(new Factory()) instanceof java.util.Map"), Boolean.TRUE);
+ } catch (final Exception exp) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+
+ @Test
+ // iteration tests
+ public void iteratingJSObjectTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ try {
+ final MapWrapperObject obj = new MapWrapperObject();
+ obj.setMember("foo", "hello");
+ obj.setMember("bar", "world");
+ e.put("obj", obj);
+
+ // check for..in
+ Object val = e.eval("var str = ''; for (i in obj) str += i; str");
+ assertEquals(val.toString(), "foobar");
+
+ // check for..each..in
+ val = e.eval("var str = ''; for each (i in obj) str += i; str");
+ assertEquals(val.toString(), "helloworld");
+ } catch (final Exception exp) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/api/scripting/test/ScopeTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,781 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.nashorn.api.scripting.test;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+import javax.script.Bindings;
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import javax.script.SimpleBindings;
+import javax.script.SimpleScriptContext;
+import jdk.nashorn.api.scripting.ScriptObjectMirror;
+import jdk.nashorn.api.scripting.URLReader;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * Tests for jsr223 Bindings "scope" (engine, global scopes)
+ */
+@SuppressWarnings("javadoc")
+public class ScopeTest {
+
+ @Test
+ public void createBindingsTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final Bindings b = e.createBindings();
+ b.put("foo", 42.0);
+ Object res = null;
+ try {
+ res = e.eval("foo == 42.0", b);
+ } catch (final ScriptException | NullPointerException se) {
+ se.printStackTrace();
+ fail(se.getMessage());
+ }
+
+ assertEquals(res, Boolean.TRUE);
+ }
+
+ @Test
+ public void engineScopeTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final Bindings engineScope = e.getBindings(ScriptContext.ENGINE_SCOPE);
+
+ // check few ECMA standard built-in global properties
+ assertNotNull(engineScope.get("Object"));
+ assertNotNull(engineScope.get("TypeError"));
+ assertNotNull(engineScope.get("eval"));
+
+ // can access via ScriptEngine.get as well
+ assertNotNull(e.get("Object"));
+ assertNotNull(e.get("TypeError"));
+ assertNotNull(e.get("eval"));
+
+ // Access by either way should return same object
+ assertEquals(engineScope.get("Array"), e.get("Array"));
+ assertEquals(engineScope.get("EvalError"), e.get("EvalError"));
+ assertEquals(engineScope.get("undefined"), e.get("undefined"));
+
+ // try exposing a new variable from scope
+ engineScope.put("myVar", "foo");
+ try {
+ assertEquals(e.eval("myVar"), "foo");
+ } catch (final ScriptException se) {
+ se.printStackTrace();
+ fail(se.getMessage());
+ }
+
+ // update "myVar" in script an check the value from scope
+ try {
+ e.eval("myVar = 'nashorn';");
+ } catch (final ScriptException se) {
+ se.printStackTrace();
+ fail(se.getMessage());
+ }
+
+ // now check modified value from scope and engine
+ assertEquals(engineScope.get("myVar"), "nashorn");
+ assertEquals(e.get("myVar"), "nashorn");
+ }
+
+ @Test
+ public void multiGlobalTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final Bindings b = e.createBindings();
+ final ScriptContext newCtxt = new SimpleScriptContext();
+ newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
+
+ try {
+ final Object obj1 = e.eval("Object");
+ final Object obj2 = e.eval("Object", newCtxt);
+ Assert.assertNotEquals(obj1, obj2);
+ Assert.assertNotNull(obj1);
+ Assert.assertNotNull(obj2);
+ Assert.assertEquals(obj1.toString(), obj2.toString());
+
+ e.eval("x = 'hello'");
+ e.eval("x = 'world'", newCtxt);
+ Object x1 = e.getContext().getAttribute("x");
+ Object x2 = newCtxt.getAttribute("x");
+ Assert.assertNotEquals(x1, x2);
+ Assert.assertEquals(x1, "hello");
+ Assert.assertEquals(x2, "world");
+
+ x1 = e.eval("x");
+ x2 = e.eval("x", newCtxt);
+ Assert.assertNotEquals(x1, x2);
+ Assert.assertEquals(x1, "hello");
+ Assert.assertEquals(x2, "world");
+
+ final ScriptContext origCtxt = e.getContext();
+ e.setContext(newCtxt);
+ e.eval("y = new Object()");
+ e.eval("y = new Object()", origCtxt);
+
+ final Object y1 = origCtxt.getAttribute("y");
+ final Object y2 = newCtxt.getAttribute("y");
+ Assert.assertNotEquals(y1, y2);
+ final Object yeval1 = e.eval("y");
+ final Object yeval2 = e.eval("y", origCtxt);
+ Assert.assertNotEquals(yeval1, yeval2);
+ Assert.assertEquals("[object Object]", y1.toString());
+ Assert.assertEquals("[object Object]", y2.toString());
+ } catch (final ScriptException se) {
+ se.printStackTrace();
+ fail(se.getMessage());
+ }
+ }
+
+ @Test
+ public void userEngineScopeBindingsTest() throws ScriptException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ e.eval("function func() {}");
+
+ final ScriptContext newContext = new SimpleScriptContext();
+ newContext.setBindings(new SimpleBindings(), ScriptContext.ENGINE_SCOPE);
+ // we are using a new bindings - so it should have 'func' defined
+ final Object value = e.eval("typeof func", newContext);
+ assertTrue(value.equals("undefined"));
+ }
+
+ @Test
+ public void userEngineScopeBindingsNoLeakTest() throws ScriptException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final ScriptContext newContext = new SimpleScriptContext();
+ newContext.setBindings(new SimpleBindings(), ScriptContext.ENGINE_SCOPE);
+ e.eval("function foo() {}", newContext);
+
+ // in the default context's ENGINE_SCOPE, 'foo' shouldn't exist
+ assertTrue(e.eval("typeof foo").equals("undefined"));
+ }
+
+ @Test
+ public void userEngineScopeBindingsRetentionTest() throws ScriptException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final ScriptContext newContext = new SimpleScriptContext();
+ newContext.setBindings(new SimpleBindings(), ScriptContext.ENGINE_SCOPE);
+ e.eval("function foo() {}", newContext);
+
+ // definition retained with user's ENGINE_SCOPE Binding
+ assertTrue(e.eval("typeof foo", newContext).equals("function"));
+
+ final Bindings oldBindings = newContext.getBindings(ScriptContext.ENGINE_SCOPE);
+ // but not in another ENGINE_SCOPE binding
+ newContext.setBindings(new SimpleBindings(), ScriptContext.ENGINE_SCOPE);
+ assertTrue(e.eval("typeof foo", newContext).equals("undefined"));
+
+ // restore ENGINE_SCOPE and check again
+ newContext.setBindings(oldBindings, ScriptContext.ENGINE_SCOPE);
+ assertTrue(e.eval("typeof foo", newContext).equals("function"));
+ }
+
+ @Test
+ // check that engine.js definitions are visible in all new global instances
+ public void checkBuiltinsInNewBindingsTest() throws ScriptException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+
+ // check default global instance has engine.js definitions
+ final Bindings g = (Bindings) e.eval("this");
+ Object value = g.get("__noSuchProperty__");
+ assertTrue(value instanceof ScriptObjectMirror && ((ScriptObjectMirror)value).isFunction());
+ value = g.get("print");
+ assertTrue(value instanceof ScriptObjectMirror && ((ScriptObjectMirror)value).isFunction());
+
+ // check new global instance created has engine.js definitions
+ final Bindings b = e.createBindings();
+ value = b.get("__noSuchProperty__");
+ assertTrue(value instanceof ScriptObjectMirror && ((ScriptObjectMirror)value).isFunction());
+ value = b.get("print");
+ assertTrue(value instanceof ScriptObjectMirror && ((ScriptObjectMirror)value).isFunction());
+
+ // put a mapping into GLOBAL_SCOPE
+ final Bindings globalScope = e.getContext().getBindings(ScriptContext.GLOBAL_SCOPE);
+ globalScope.put("x", "hello");
+
+ // GLOBAL_SCOPE mapping should be visible from default ScriptContext eval
+ assertTrue(e.eval("x").equals("hello"));
+
+ final ScriptContext ctx = new SimpleScriptContext();
+ ctx.setBindings(globalScope, ScriptContext.GLOBAL_SCOPE);
+ ctx.setBindings(b, ScriptContext.ENGINE_SCOPE);
+
+ // GLOBAL_SCOPE mapping should be visible from non-default ScriptContext eval
+ assertTrue(e.eval("x", ctx).equals("hello"));
+
+ // try some arbitray Bindings for ENGINE_SCOPE
+ final Bindings sb = new SimpleBindings();
+ ctx.setBindings(sb, ScriptContext.ENGINE_SCOPE);
+
+ // GLOBAL_SCOPE mapping should be visible from non-default ScriptContext eval
+ assertTrue(e.eval("x", ctx).equals("hello"));
+
+ // engine.js builtins are still defined even with arbitrary Bindings
+ assertTrue(e.eval("typeof print", ctx).equals("function"));
+ assertTrue(e.eval("typeof __noSuchProperty__", ctx).equals("function"));
+
+ // ENGINE_SCOPE definition should 'hide' GLOBAL_SCOPE definition
+ sb.put("x", "newX");
+ assertTrue(e.eval("x", ctx).equals("newX"));
+ }
+
+ /**
+ * Test multi-threaded access to defined global variables for shared script classes with multiple globals.
+ */
+ @Test
+ public static void multiThreadedVarTest() throws ScriptException, InterruptedException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final Bindings b = e.createBindings();
+ final ScriptContext origContext = e.getContext();
+ final ScriptContext newCtxt = new SimpleScriptContext();
+ newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
+ final String sharedScript = "foo";
+
+ assertEquals(e.eval("var foo = 'original context';", origContext), null);
+ assertEquals(e.eval("var foo = 'new context';", newCtxt), null);
+
+ final Thread t1 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
+ final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "new context", 1000));
+ t1.start();
+ t2.start();
+ t1.join();
+ t2.join();
+
+ assertEquals(e.eval("var foo = 'newer context';", newCtxt), null);
+ final Thread t3 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
+ final Thread t4 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "newer context", 1000));
+
+ t3.start();
+ t4.start();
+ t3.join();
+ t4.join();
+
+ assertEquals(e.eval(sharedScript), "original context");
+ assertEquals(e.eval(sharedScript, newCtxt), "newer context");
+ }
+
+ /**
+ * Test multi-threaded access to undefined global variables for shared script classes with multiple globals.
+ */
+ @Test
+ public static void multiThreadedGlobalTest() throws ScriptException, InterruptedException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final Bindings b = e.createBindings();
+ final ScriptContext origContext = e.getContext();
+ final ScriptContext newCtxt = new SimpleScriptContext();
+ newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
+
+ assertEquals(e.eval("foo = 'original context';", origContext), "original context");
+ assertEquals(e.eval("foo = 'new context';", newCtxt), "new context");
+ final String sharedScript = "foo";
+
+ final Thread t1 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
+ final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "new context", 1000));
+ t1.start();
+ t2.start();
+ t1.join();
+ t2.join();
+
+ final Object obj3 = e.eval("delete foo; foo = 'newer context';", newCtxt);
+ assertEquals(obj3, "newer context");
+ final Thread t3 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
+ final Thread t4 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "newer context", 1000));
+
+ t3.start();
+ t4.start();
+ t3.join();
+ t4.join();
+
+ Assert.assertEquals(e.eval(sharedScript), "original context");
+ Assert.assertEquals(e.eval(sharedScript, newCtxt), "newer context");
+ }
+
+ /**
+ * Test multi-threaded access using the postfix ++ operator for shared script classes with multiple globals.
+ */
+ @Test
+ public static void multiThreadedIncTest() throws ScriptException, InterruptedException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final Bindings b = e.createBindings();
+ final ScriptContext origContext = e.getContext();
+ final ScriptContext newCtxt = new SimpleScriptContext();
+ newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
+
+ assertEquals(e.eval("var x = 0;", origContext), null);
+ assertEquals(e.eval("var x = 2;", newCtxt), null);
+ final String sharedScript = "x++;";
+
+ final Thread t1 = new Thread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ for (int i = 0; i < 1000; i++) {
+ assertEquals(e.eval(sharedScript, origContext), (double)i);
+ }
+ } catch (final ScriptException se) {
+ fail(se.toString());
+ }
+ }
+ });
+ final Thread t2 = new Thread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ for (int i = 2; i < 1000; i++) {
+ assertEquals(e.eval(sharedScript, newCtxt), (double)i);
+ }
+ } catch (final ScriptException se) {
+ fail(se.toString());
+ }
+ }
+ });
+ t1.start();
+ t2.start();
+ t1.join();
+ t2.join();
+ }
+
+ /**
+ * Test multi-threaded access to primitive prototype properties for shared script classes with multiple globals.
+ */
+ @Test
+ public static void multiThreadedPrimitiveTest() throws ScriptException, InterruptedException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final Bindings b = e.createBindings();
+ final ScriptContext origContext = e.getContext();
+ final ScriptContext newCtxt = new SimpleScriptContext();
+ newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
+
+ final Object obj1 = e.eval("String.prototype.foo = 'original context';", origContext);
+ final Object obj2 = e.eval("String.prototype.foo = 'new context';", newCtxt);
+ assertEquals(obj1, "original context");
+ assertEquals(obj2, "new context");
+ final String sharedScript = "''.foo";
+
+ final Thread t1 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
+ final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "new context", 1000));
+ t1.start();
+ t2.start();
+ t1.join();
+ t2.join();
+
+ final Object obj3 = e.eval("delete String.prototype.foo; Object.prototype.foo = 'newer context';", newCtxt);
+ assertEquals(obj3, "newer context");
+ final Thread t3 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
+ final Thread t4 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "newer context", 1000));
+
+ t3.start();
+ t4.start();
+ t3.join();
+ t4.join();
+
+ Assert.assertEquals(e.eval(sharedScript), "original context");
+ Assert.assertEquals(e.eval(sharedScript, newCtxt), "newer context");
+ }
+
+
+ /**
+ * Test multi-threaded access to prototype user accessor properties for shared script classes with multiple globals.
+ */
+ @Test
+ public static void multiThreadedAccessorTest() throws ScriptException, InterruptedException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final Bindings b = e.createBindings();
+ final ScriptContext origContext = e.getContext();
+ final ScriptContext newCtxt = new SimpleScriptContext();
+ newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
+
+ e.eval("Object.defineProperty(Object.prototype, 'foo', { get: function() 'original context' })", origContext);
+ e.eval("Object.defineProperty(Object.prototype, 'foo', { get: function() 'new context', configurable: true })", newCtxt);
+ final String sharedScript = "({}).foo";
+
+ final Thread t1 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
+ final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "new context", 1000));
+ t1.start();
+ t2.start();
+ t1.join();
+ t2.join();
+
+ final Object obj3 = e.eval("delete Object.prototype.foo; Object.prototype.foo = 'newer context';", newCtxt);
+ assertEquals(obj3, "newer context");
+ final Thread t3 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
+ final Thread t4 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "newer context", 1000));
+
+ t3.start();
+ t4.start();
+ t3.join();
+ t4.join();
+ }
+
+ /**
+ * Test multi-threaded access to primitive prototype user accessor properties for shared script classes with multiple globals.
+ */
+ @Test
+ public static void multiThreadedPrimitiveAccessorTest() throws ScriptException, InterruptedException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final Bindings b = e.createBindings();
+ final ScriptContext origContext = e.getContext();
+ final ScriptContext newCtxt = new SimpleScriptContext();
+ newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
+
+ e.eval("Object.defineProperty(String.prototype, 'foo', { get: function() 'original context' })", origContext);
+ e.eval("Object.defineProperty(String.prototype, 'foo', { get: function() 'new context' })", newCtxt);
+ final String sharedScript = "''.foo";
+
+ final Thread t1 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
+ final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "new context", 1000));
+ t1.start();
+ t2.start();
+ t1.join();
+ t2.join();
+
+ final Object obj3 = e.eval("delete String.prototype.foo; Object.prototype.foo = 'newer context';", newCtxt);
+ assertEquals(obj3, "newer context");
+ final Thread t3 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
+ final Thread t4 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "newer context", 1000));
+
+ t3.start();
+ t4.start();
+ t3.join();
+ t4.join();
+ }
+
+ /**
+ * Test multi-threaded scope function invocation for shared script classes with multiple globals.
+ */
+ @Test
+ public static void multiThreadedFunctionTest() throws ScriptException, InterruptedException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final Bindings b = e.createBindings();
+ final ScriptContext origContext = e.getContext();
+ final ScriptContext newCtxt = new SimpleScriptContext();
+ newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
+
+ e.eval(new URLReader(ScopeTest.class.getResource("resources/func.js")), origContext);
+ assertEquals(origContext.getAttribute("scopeVar"), 1);
+ assertEquals(e.eval("scopeTest()"), 1);
+
+ e.eval(new URLReader(ScopeTest.class.getResource("resources/func.js")), newCtxt);
+ assertEquals(newCtxt.getAttribute("scopeVar"), 1);
+ assertEquals(e.eval("scopeTest();", newCtxt), 1);
+
+ assertEquals(e.eval("scopeVar = 3;", newCtxt), 3);
+ assertEquals(newCtxt.getAttribute("scopeVar"), 3);
+
+
+ final Thread t1 = new Thread(new ScriptRunner(e, origContext, "scopeTest()", 1, 1000));
+ final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, "scopeTest()", 3, 1000));
+
+ t1.start();
+ t2.start();
+ t1.join();
+ t2.join();
+
+ }
+
+ /**
+ * Test multi-threaded access to global getters and setters for shared script classes with multiple globals.
+ */
+ @Test
+ public static void getterSetterTest() throws ScriptException, InterruptedException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final Bindings b = e.createBindings();
+ final ScriptContext origContext = e.getContext();
+ final ScriptContext newCtxt = new SimpleScriptContext();
+ newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
+ final String sharedScript = "accessor1";
+
+ e.eval(new URLReader(ScopeTest.class.getResource("resources/gettersetter.js")), origContext);
+ assertEquals(e.eval("accessor1 = 1;"), 1);
+ assertEquals(e.eval(sharedScript), 1);
+
+ e.eval(new URLReader(ScopeTest.class.getResource("resources/gettersetter.js")), newCtxt);
+ assertEquals(e.eval("accessor1 = 2;", newCtxt), 2);
+ assertEquals(e.eval(sharedScript, newCtxt), 2);
+
+
+ final Thread t1 = new Thread(new ScriptRunner(e, origContext, sharedScript, 1, 1000));
+ final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, 2, 1000));
+
+ t1.start();
+ t2.start();
+ t1.join();
+ t2.join();
+
+ assertEquals(e.eval(sharedScript), 1);
+ assertEquals(e.eval(sharedScript, newCtxt), 2);
+ assertEquals(e.eval("v"), 1);
+ assertEquals(e.eval("v", newCtxt), 2);
+ }
+
+ /**
+ * Test multi-threaded access to global getters and setters for shared script classes with multiple globals.
+ */
+ @Test
+ public static void getterSetter2Test() throws ScriptException, InterruptedException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final Bindings b = e.createBindings();
+ final ScriptContext origContext = e.getContext();
+ final ScriptContext newCtxt = new SimpleScriptContext();
+ newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
+ final String sharedScript = "accessor2";
+
+ e.eval(new URLReader(ScopeTest.class.getResource("resources/gettersetter.js")), origContext);
+ assertEquals(e.eval("accessor2 = 1;"), 1);
+ assertEquals(e.eval(sharedScript), 1);
+
+ e.eval(new URLReader(ScopeTest.class.getResource("resources/gettersetter.js")), newCtxt);
+ assertEquals(e.eval("accessor2 = 2;", newCtxt), 2);
+ assertEquals(e.eval(sharedScript, newCtxt), 2);
+
+
+ final Thread t1 = new Thread(new ScriptRunner(e, origContext, sharedScript, 1, 1000));
+ final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, 2, 1000));
+
+ t1.start();
+ t2.start();
+ t1.join();
+ t2.join();
+
+ assertEquals(e.eval(sharedScript), 1);
+ assertEquals(e.eval(sharedScript, newCtxt), 2);
+ assertEquals(e.eval("x"), 1);
+ assertEquals(e.eval("x", newCtxt), 2);
+ }
+
+ // @bug 8058422: Users should be able to overwrite "context" and "engine" variables
+ @Test
+ public static void contextOverwriteTest() throws ScriptException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final Bindings b = new SimpleBindings();
+ b.put("context", "hello");
+ b.put("foo", 32);
+ final ScriptContext newCtxt = new SimpleScriptContext();
+ newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
+ e.setContext(newCtxt);
+ assertEquals(e.eval("context"), "hello");
+ assertEquals(((Number)e.eval("foo")).intValue(), 32);
+ }
+
+ // @bug 8058422: Users should be able to overwrite "context" and "engine" variables
+ @Test
+ public static void contextOverwriteInScriptTest() throws ScriptException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ e.put("foo", 32);
+
+ assertEquals(((Number)e.eval("foo")).intValue(), 32);
+ assertEquals(e.eval("context = 'bar'"), "bar");
+ assertEquals(((Number)e.eval("foo")).intValue(), 32);
+ }
+
+ // @bug 8058422: Users should be able to overwrite "context" and "engine" variables
+ @Test
+ public static void engineOverwriteTest() throws ScriptException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final Bindings b = new SimpleBindings();
+ b.put("engine", "hello");
+ b.put("foo", 32);
+ final ScriptContext newCtxt = new SimpleScriptContext();
+ newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
+ e.setContext(newCtxt);
+ assertEquals(e.eval("engine"), "hello");
+ assertEquals(((Number)e.eval("foo")).intValue(), 32);
+ }
+
+ // @bug 8058422: Users should be able to overwrite "context" and "engine" variables
+ @Test
+ public static void engineOverwriteInScriptTest() throws ScriptException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ e.put("foo", 32);
+
+ assertEquals(((Number)e.eval("foo")).intValue(), 32);
+ assertEquals(e.eval("engine = 'bar'"), "bar");
+ assertEquals(((Number)e.eval("foo")).intValue(), 32);
+ }
+
+ // @bug 8044750: megamorphic getter for scope objects does not call __noSuchProperty__ hook
+ @Test
+ public static void testMegamorphicGetInGlobal() throws Exception {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine engine = m.getEngineByName("nashorn");
+ final String script = "foo";
+ // "foo" is megamorphic because of different global scopes.
+ // Make sure ScriptContext variable search works even after
+ // it becomes megamorphic.
+ for (int index = 0; index < 25; index++) {
+ final Bindings bindings = new SimpleBindings();
+ bindings.put("foo", index);
+ final Number value = (Number)engine.eval(script, bindings);
+ assertEquals(index, value.intValue());
+ }
+ }
+
+ /**
+ * Test "slow" scopes involving {@code with} and {@code eval} statements for shared script classes with multiple globals.
+ * @throws ScriptException
+ * @throws InterruptedException
+ */
+ @Test
+ public static void testSlowScope() throws ScriptException, InterruptedException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+
+ for (int i = 0; i < 100; i++) {
+ final Bindings b = e.createBindings();
+ final ScriptContext ctxt = new SimpleScriptContext();
+ ctxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
+
+ e.eval(new URLReader(ScopeTest.class.getResource("resources/witheval.js")), ctxt);
+ assertEquals(e.eval("a", ctxt), 1);
+ assertEquals(b.get("a"), 1);
+ assertEquals(e.eval("b", ctxt), 3);
+ assertEquals(b.get("b"), 3);
+ assertEquals(e.eval("c", ctxt), 10);
+ assertEquals(b.get("c"), 10);
+ }
+ }
+
+ private static class ScriptRunner implements Runnable {
+
+ final ScriptEngine engine;
+ final ScriptContext context;
+ final String source;
+ final Object expected;
+ final int iterations;
+
+ ScriptRunner(final ScriptEngine engine, final ScriptContext context, final String source, final Object expected, final int iterations) {
+ this.engine = engine;
+ this.context = context;
+ this.source = source;
+ this.expected = expected;
+ this.iterations = iterations;
+ }
+
+ @Override
+ public void run() {
+ try {
+ for (int i = 0; i < iterations; i++) {
+ assertEquals(engine.eval(source, context), expected);
+ }
+ } catch (final ScriptException se) {
+ throw new RuntimeException(se);
+ }
+ }
+ }
+
+ // @bug 8071678: NashornScriptEngine returns javax.script.ScriptContext instance
+ // with get/setAttribute methods insonsistent for GLOBAL_SCOPE
+ @Test
+ public void testGlobalScopeSearch() throws Exception {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final ScriptContext c = e.getContext();
+ c.setAttribute("name1234", "value", ScriptContext.GLOBAL_SCOPE);
+ assertEquals(c.getAttribute("name1234"), "value");
+ assertEquals(c.getAttributesScope("name1234"),
+ ScriptContext.GLOBAL_SCOPE);
+ }
+
+ // @bug 8071594: NashornScriptEngine returns javax.script.ScriptContext instance
+ // which doesn't completely conform to the spec regarding exceptions throwing
+ @Test
+ public void testScriptContext_NPE_IAE() throws Exception {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final ScriptContext c = e.getContext();
+ try {
+ c.getAttribute("");
+ throw new AssertionError("should have thrown IAE");
+ } catch (IllegalArgumentException iae1) {}
+
+ try {
+ c.getAttribute(null);
+ throw new AssertionError("should have thrown NPE");
+ } catch (NullPointerException npe1) {}
+
+ try {
+ c.getAttribute("", ScriptContext.ENGINE_SCOPE);
+ throw new AssertionError("should have thrown IAE");
+ } catch (IllegalArgumentException iae2) {}
+
+ try {
+ c.getAttribute(null, ScriptContext.ENGINE_SCOPE);
+ throw new AssertionError("should have thrown NPE");
+ } catch (NullPointerException npe2) {}
+
+ try {
+ c.removeAttribute("", ScriptContext.ENGINE_SCOPE);
+ throw new AssertionError("should have thrown IAE");
+ } catch (IllegalArgumentException iae3) {}
+
+ try {
+ c.removeAttribute(null, ScriptContext.ENGINE_SCOPE);
+ throw new AssertionError("should have thrown NPE");
+ } catch (NullPointerException npe3) {}
+
+ try {
+ c.setAttribute("", "value", ScriptContext.ENGINE_SCOPE);
+ throw new AssertionError("should have thrown IAE");
+ } catch (IllegalArgumentException iae4) {}
+
+ try {
+ c.setAttribute(null, "value", ScriptContext.ENGINE_SCOPE);
+ throw new AssertionError("should have thrown NPE");
+ } catch (NullPointerException npe4) {}
+
+ try {
+ c.getAttributesScope("");
+ throw new AssertionError("should have thrown IAE");
+ } catch (IllegalArgumentException iae5) {}
+
+ try {
+ c.getAttributesScope(null);
+ throw new AssertionError("should have thrown NPE");
+ } catch (NullPointerException npe5) {}
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/api/scripting/test/ScriptEngineSecurityTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,313 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.scripting.test;
+
+import static org.testng.Assert.fail;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import jdk.nashorn.api.scripting.ClassFilter;
+import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
+import org.testng.annotations.Test;
+
+/**
+ * jsr223 tests for security access checks.
+ */
+@SuppressWarnings("javadoc")
+public class ScriptEngineSecurityTest {
+
+ private static void log(final String msg) {
+ org.testng.Reporter.log(msg, true);
+ }
+
+ @Test
+ public void securityPackagesTest() {
+ if (System.getSecurityManager() == null) {
+ // pass vacuously
+ return;
+ }
+
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ try {
+ e.eval("var v = Packages.sun.misc.Unsafe;");
+ fail("should have thrown SecurityException");
+ } catch (final Exception exp) {
+ if (exp instanceof SecurityException) {
+ log("got " + exp + " as expected");
+ } else {
+ fail(exp.getMessage());
+ }
+ }
+ }
+
+ @Test
+ public void securityJavaTypeTest() {
+ if (System.getSecurityManager() == null) {
+ // pass vacuously
+ return;
+ }
+
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ try {
+ e.eval("var v = Java.type('sun.misc.Unsafe');");
+ fail("should have thrown SecurityException");
+ } catch (final Exception exp) {
+ if (exp instanceof SecurityException) {
+ log("got " + exp + " as expected");
+ } else {
+ fail(exp.getMessage());
+ }
+ }
+ }
+
+ @Test
+ public void securityClassForNameTest() {
+ if (System.getSecurityManager() == null) {
+ // pass vacuously
+ return;
+ }
+
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ try {
+ e.eval("var v = java.lang.Class.forName('sun.misc.Unsafe');");
+ fail("should have thrown SecurityException");
+ } catch (final Exception exp) {
+ if (exp instanceof SecurityException) {
+ log("got " + exp + " as expected");
+ } else {
+ fail(exp.getMessage());
+ }
+ }
+ }
+
+ @Test
+ public void securitySystemExit() {
+ if (System.getSecurityManager() == null) {
+ // pass vacuously
+ return;
+ }
+
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ try {
+ e.eval("java.lang.System.exit(0);");
+ fail("should have thrown SecurityException");
+ } catch (final Exception exp) {
+ if (exp instanceof SecurityException) {
+ log("got " + exp + " as expected");
+ } else {
+ fail(exp.getMessage());
+ }
+ }
+ }
+
+
+ @Test
+ public void securitySystemExitFromFinalizerThread() throws ScriptException {
+ if (System.getSecurityManager() == null) {
+ // pass vacuously
+ return;
+ }
+
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ e.eval("var o = Java.extend(Java.type('javax.imageio.spi.ServiceRegistry'), { deregisterAll: this.exit.bind(null, 1234)});\n" +
+ "new o(new java.util.ArrayList().iterator())");
+ System.gc();
+ System.runFinalization();
+ // NOTE: this test just exits the VM if it fails.
+ }
+
+ @Test
+ public void securitySystemLoadLibrary() {
+ if (System.getSecurityManager() == null) {
+ // pass vacuously
+ return;
+ }
+
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ try {
+ e.eval("java.lang.System.loadLibrary('foo');");
+ fail("should have thrown SecurityException");
+ } catch (final Exception exp) {
+ if (exp instanceof SecurityException) {
+ log("got " + exp + " as expected");
+ } else {
+ fail(exp.getMessage());
+ }
+ }
+ }
+
+ // @bug 8032948: Nashorn linkages awry
+ @SuppressWarnings("serial")
+ public static class FakeProxy extends Proxy {
+ public FakeProxy(final InvocationHandler ih) {
+ super(ih);
+ }
+
+ public static Class<?> makeProxyClass(final ClassLoader cl, final Class<?>... ifaces) {
+ return Proxy.getProxyClass(cl, ifaces);
+ }
+ }
+
+ @Test
+ public void fakeProxySubclassAccessCheckTest() {
+ if (System.getSecurityManager() == null) {
+ // pass vacuously
+ return;
+ }
+
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+
+ e.put("name", ScriptEngineSecurityTest.class.getName());
+ e.put("cl", ScriptEngineSecurityTest.class.getClassLoader());
+ e.put("intfs", new Class[] { Runnable.class });
+
+ final String getClass = "Java.type(name + '$FakeProxy').getProxyClass(cl, intfs);";
+
+ // Should not be able to call static methods of Proxy via fake subclass
+ try {
+ e.eval(getClass);
+ fail("should have thrown SecurityException");
+ } catch (final Exception exp) {
+ if (! (exp instanceof SecurityException)) {
+ fail("SecurityException expected, got " + exp);
+ }
+ }
+ }
+
+ @Test
+ public void fakeProxySubclassAccessCheckTest2() {
+ if (System.getSecurityManager() == null) {
+ // pass vacuously
+ return;
+ }
+
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+
+ e.put("name", ScriptEngineSecurityTest.class.getName());
+ e.put("cl", ScriptEngineSecurityTest.class.getClassLoader());
+ e.put("intfs", new Class[] { Runnable.class });
+
+ final String getClass = "Java.type(name + '$FakeProxy').makeProxyClass(cl, intfs);";
+
+ // Should not be able to call static methods of Proxy via fake subclass
+ try {
+ e.eval(getClass);
+ fail("should have thrown SecurityException");
+ } catch (final Exception exp) {
+ if (! (exp instanceof SecurityException)) {
+ fail("SecurityException expected, got " + exp);
+ }
+ }
+ }
+
+ @Test
+ public static void proxyStaticAccessCheckTest() {
+ if (System.getSecurityManager() == null) {
+ // pass vacuously
+ return;
+ }
+
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final Runnable r = (Runnable)Proxy.newProxyInstance(
+ ScriptEngineTest.class.getClassLoader(),
+ new Class[] { Runnable.class },
+ new InvocationHandler() {
+ @Override
+ public Object invoke(final Object p, final Method mtd, final Object[] a) {
+ return null;
+ }
+ });
+
+ e.put("rc", r.getClass());
+ e.put("cl", ScriptEngineSecurityTest.class.getClassLoader());
+ e.put("intfs", new Class[] { Runnable.class });
+
+ // make sure static methods of Proxy is not accessible via subclass
+ try {
+ e.eval("rc.static.getProxyClass(cl, intfs)");
+ fail("Should have thrown SecurityException");
+ } catch (final Exception exp) {
+ if (! (exp instanceof SecurityException)) {
+ fail("SecurityException expected, got " + exp);
+ }
+ }
+ }
+
+
+ @Test
+ public void nashornConfigSecurityTest() {
+ if (System.getSecurityManager() == null) {
+ // pass vacuously
+ return;
+ }
+
+ final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
+ try {
+ fac.getScriptEngine(new ClassFilter() {
+ @Override
+ public boolean exposeToScripts(final String name) {
+ return true;
+ }
+ });
+ fail("SecurityException should have been thrown");
+ } catch (final SecurityException e) {
+ //empty
+ }
+ }
+
+ @Test
+ public void nashornConfigSecurityTest2() {
+ if (System.getSecurityManager() == null) {
+ // pass vacuously
+ return;
+ }
+
+ final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
+ try {
+ fac.getScriptEngine(new String[0], null, new ClassFilter() {
+ @Override
+ public boolean exposeToScripts(final String name) {
+ return true;
+ }
+ });
+ fail("SecurityException should have been thrown");
+ } catch (final SecurityException e) {
+ //empty
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/api/scripting/test/ScriptEngineTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,881 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.scripting.test;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.Collections;
+import java.util.concurrent.Callable;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import javax.script.Bindings;
+import javax.script.Compilable;
+import javax.script.CompiledScript;
+import javax.script.Invocable;
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineFactory;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import javax.script.SimpleScriptContext;
+import jdk.nashorn.api.scripting.ScriptObjectMirror;
+import org.testng.annotations.Test;
+
+/**
+ * Tests for JSR-223 script engine for Nashorn.
+ *
+ * @test
+ * @build jdk.nashorn.api.scripting.test.Window jdk.nashorn.api.scripting.test.WindowEventHandler jdk.nashorn.api.scripting.test.VariableArityTestInterface jdk.nashorn.api.scripting.test.ScriptEngineTest
+ * @run testng/othervm jdk.nashorn.api.scripting.test.ScriptEngineTest
+ */
+@SuppressWarnings("javadoc")
+public class ScriptEngineTest {
+
+ private static void log(final String msg) {
+ org.testng.Reporter.log(msg, true);
+ }
+
+ @Test
+ public void argumentsTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+
+ final String[] args = new String[] { "hello", "world" };
+ try {
+ e.put("arguments", args);
+ final Object arg0 = e.eval("arguments[0]");
+ final Object arg1 = e.eval("arguments[1]");
+ assertEquals(args[0], arg0);
+ assertEquals(args[1], arg1);
+ } catch (final Exception exp) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+
+ @Test
+ public void argumentsWithTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+
+ final String[] args = new String[] { "hello", "world" };
+ try {
+ e.put("arguments", args);
+ final Object arg0 = e.eval("var imports = new JavaImporter(java.io); " +
+ " with(imports) { arguments[0] }");
+ final Object arg1 = e.eval("var imports = new JavaImporter(java.util, java.io); " +
+ " with(imports) { arguments[1] }");
+ assertEquals(args[0], arg0);
+ assertEquals(args[1], arg1);
+ } catch (final Exception exp) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+
+ @Test
+ public void argumentsEmptyTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+
+ try {
+ assertEquals(e.eval("arguments instanceof Array"), true);
+ assertEquals(e.eval("arguments.length == 0"), true);
+ } catch (final Exception exp) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+
+ @Test
+ public void factoryTests() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ assertNotNull(e);
+
+ final ScriptEngineFactory fac = e.getFactory();
+
+ assertEquals(fac.getLanguageName(), "ECMAScript");
+ assertEquals(fac.getParameter(ScriptEngine.NAME), "javascript");
+ assertEquals(fac.getLanguageVersion(), "ECMA - 262 Edition 5.1");
+ assertEquals(fac.getEngineName(), "Oracle Nashorn");
+ assertEquals(fac.getOutputStatement("context"), "print(context)");
+ assertEquals(fac.getProgram("print('hello')", "print('world')"), "print('hello');print('world');");
+ assertEquals(fac.getParameter(ScriptEngine.NAME), "javascript");
+
+ boolean seenJS = false;
+ for (final String ext : fac.getExtensions()) {
+ if (ext.equals("js")) {
+ seenJS = true;
+ }
+ }
+
+ assertEquals(seenJS, true);
+ final String str = fac.getMethodCallSyntax("obj", "foo", "x");
+ assertEquals(str, "obj.foo(x)");
+
+ boolean seenNashorn = false, seenJavaScript = false, seenECMAScript = false;
+ for (final String name : fac.getNames()) {
+ switch (name) {
+ case "nashorn": seenNashorn = true; break;
+ case "javascript": seenJavaScript = true; break;
+ case "ECMAScript": seenECMAScript = true; break;
+ default:
+ break;
+ }
+ }
+
+ assertTrue(seenNashorn);
+ assertTrue(seenJavaScript);
+ assertTrue(seenECMAScript);
+
+ boolean seenAppJS = false, seenAppECMA = false, seenTextJS = false, seenTextECMA = false;
+ for (final String mime : fac.getMimeTypes()) {
+ switch (mime) {
+ case "application/javascript": seenAppJS = true; break;
+ case "application/ecmascript": seenAppECMA = true; break;
+ case "text/javascript": seenTextJS = true; break;
+ case "text/ecmascript": seenTextECMA = true; break;
+ default:
+ break;
+ }
+ }
+
+ assertTrue(seenAppJS);
+ assertTrue(seenAppECMA);
+ assertTrue(seenTextJS);
+ assertTrue(seenTextECMA);
+ }
+
+ @Test
+ public void evalTests() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ e.put(ScriptEngine.FILENAME, "myfile.js");
+
+ try {
+ e.eval("print('hello')");
+ } catch (final ScriptException se) {
+ fail(se.getMessage());
+ }
+ try {
+ e.eval("print('hello)");
+ fail("script exception expected");
+ } catch (final ScriptException se) {
+ assertEquals(se.getLineNumber(), 1);
+ assertEquals(se.getColumnNumber(), 13);
+ assertEquals(se.getFileName(), "myfile.js");
+ // se.printStackTrace();
+ }
+
+ try {
+ Object obj = e.eval("34 + 41");
+ assertTrue(34.0 + 41.0 == ((Number)obj).doubleValue());
+ obj = e.eval("x = 5");
+ assertTrue(5.0 == ((Number)obj).doubleValue());
+ } catch (final ScriptException se) {
+ se.printStackTrace();
+ fail(se.getMessage());
+ }
+ }
+
+ @Test
+ public void compileTests() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ CompiledScript script = null;
+
+ try {
+ script = ((Compilable)e).compile("print('hello')");
+ } catch (final ScriptException se) {
+ fail(se.getMessage());
+ }
+
+ try {
+ script.eval();
+ } catch (final ScriptException | NullPointerException se) {
+ se.printStackTrace();
+ fail(se.getMessage());
+ }
+
+ // try to compile from a Reader
+ try {
+ script = ((Compilable)e).compile(new StringReader("print('world')"));
+ } catch (final ScriptException se) {
+ fail(se.getMessage());
+ }
+
+ try {
+ script.eval();
+ } catch (final ScriptException | NullPointerException se) {
+ se.printStackTrace();
+ fail(se.getMessage());
+ }
+ }
+
+ @Test
+ public void compileAndEvalInDiffContextTest() throws ScriptException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine engine = m.getEngineByName("js");
+ final Compilable compilable = (Compilable) engine;
+ final CompiledScript compiledScript = compilable.compile("foo");
+ final ScriptContext ctxt = new SimpleScriptContext();
+ ctxt.setAttribute("foo", "hello", ScriptContext.ENGINE_SCOPE);
+ assertEquals(compiledScript.eval(ctxt), "hello");
+ }
+
+ @Test
+ public void accessGlobalTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+
+ try {
+ e.eval("var x = 'hello'");
+ assertEquals(e.get("x"), "hello");
+ } catch (final ScriptException exp) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+
+ @Test
+ public void exposeGlobalTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+
+ try {
+ e.put("y", "foo");
+ e.eval("print(y)");
+ } catch (final ScriptException exp) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+
+ @Test
+ public void putGlobalFunctionTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+
+ e.put("callable", new Callable<String>() {
+ @Override
+ public String call() throws Exception {
+ return "callable was called";
+ }
+ });
+
+ try {
+ e.eval("print(callable.call())");
+ } catch (final ScriptException exp) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+
+ @Test
+ public void windowAlertTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final Window window = new Window();
+
+ try {
+ e.put("window", window);
+ e.eval("print(window.alert)");
+ e.eval("window.alert('calling window.alert...')");
+ } catch (final Exception exp) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+
+ @Test
+ public void windowLocationTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final Window window = new Window();
+
+ try {
+ e.put("window", window);
+ e.eval("print(window.location)");
+ final Object locationValue = e.eval("window.getLocation()");
+ assertEquals(locationValue, "http://localhost:8080/window");
+ } catch (final Exception exp) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+
+ @Test
+ public void windowItemTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final Window window = new Window();
+
+ try {
+ e.put("window", window);
+ final String item1 = (String)e.eval("window.item(65535)");
+ assertEquals(item1, "ffff");
+ final String item2 = (String)e.eval("window.item(255)");
+ assertEquals(item2, "ff");
+ } catch (final Exception exp) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+
+ @Test
+ public void windowEventTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final Window window = new Window();
+
+ try {
+ e.put("window", window);
+ e.eval("window.onload = function() { print('window load event fired'); return true }");
+ assertTrue((Boolean)e.eval("window.onload.loaded()"));
+ final WindowEventHandler handler = window.getOnload();
+ assertNotNull(handler);
+ assertTrue(handler.loaded());
+ } catch (final Exception exp) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+
+ @Test
+ public void throwTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ e.put(ScriptEngine.FILENAME, "throwtest.js");
+
+ try {
+ e.eval("throw 'foo'");
+ } catch (final ScriptException exp) {
+ log(exp.getMessage());
+ assertEquals(exp.getMessage(), "foo in throwtest.js at line number 1 at column number 0");
+ assertEquals(exp.getFileName(), "throwtest.js");
+ assertEquals(exp.getLineNumber(), 1);
+ }
+ }
+
+ @Test
+ public void setTimeoutTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final Window window = new Window();
+
+ try {
+ final Class<?> setTimeoutParamTypes[] = { Window.class, String.class, int.class };
+ final Method setTimeout = Window.class.getDeclaredMethod("setTimeout", setTimeoutParamTypes);
+ assertNotNull(setTimeout);
+ e.put("window", window);
+ e.eval("window.setTimeout('foo()', 100)");
+
+ // try to make setTimeout global
+ e.put("setTimeout", setTimeout);
+ // TODO: java.lang.ClassCastException: required class
+ // java.lang.Integer but encountered class java.lang.Double
+ // e.eval("setTimeout('foo2()', 200)");
+ } catch (final Exception exp) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+
+ @Test
+ public void setWriterTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final StringWriter sw = new StringWriter();
+ e.getContext().setWriter(sw);
+
+ try {
+ e.eval("print('hello world')");
+ } catch (final Exception exp) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ assertEquals(sw.toString(), println("hello world"));
+ }
+
+ @Test
+ public void redefineEchoTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+
+ try {
+ e.eval("var echo = {}; if (typeof echo !== 'object') { throw 'echo is a '+typeof echo; }");
+ } catch (final Exception exp) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+ @Test
+ public void noEnumerablePropertiesTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ try {
+ e.eval("for (i in this) { throw 'found property: ' + i }");
+ } catch (final Exception exp) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+
+ @Test
+ public void noRefErrorForGlobalThisAccessTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ try {
+ e.eval("this.foo");
+ } catch (final Exception exp) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+
+ @Test
+ public void refErrorForUndeclaredAccessTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ try {
+ e.eval("try { print(foo); throw 'no ref error' } catch (e) { if (!(e instanceof ReferenceError)) throw e; }");
+ } catch (final Exception exp) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+
+ @Test
+ public void typeErrorForGlobalThisCallTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ try {
+ e.eval("try { this.foo() } catch(e) { if (! (e instanceof TypeError)) throw 'no type error' }");
+ } catch (final Exception exp) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+
+ @Test
+ public void refErrorForUndeclaredCallTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ try {
+ e.eval("try { foo() } catch(e) { if (! (e instanceof ReferenceError)) throw 'no ref error' }");
+ } catch (final Exception exp) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+
+ @Test
+ // check that print function prints arg followed by newline char
+ public void printTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final StringWriter sw = new StringWriter();
+ e.getContext().setWriter(sw);
+ try {
+ e.eval("print('hello')");
+ } catch (final Throwable t) {
+ t.printStackTrace();
+ fail(t.getMessage());
+ }
+
+ assertEquals(sw.toString(), println("hello"));
+ }
+
+ @Test
+ // check that print prints all arguments (more than one)
+ public void printManyTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final StringWriter sw = new StringWriter();
+ e.getContext().setWriter(sw);
+ try {
+ e.eval("print(34, true, 'hello')");
+ } catch (final Throwable t) {
+ t.printStackTrace();
+ fail(t.getMessage());
+ }
+
+ assertEquals(sw.toString(), println("34 true hello"));
+ }
+
+ @Test
+ public void scriptObjectAutoConversionTest() throws ScriptException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ e.eval("obj = { foo: 'hello' }");
+ e.put("Window", e.eval("Packages.jdk.nashorn.api.scripting.test.Window"));
+ assertEquals(e.eval("Window.funcJSObject(obj)"), "hello");
+ assertEquals(e.eval("Window.funcScriptObjectMirror(obj)"), "hello");
+ assertEquals(e.eval("Window.funcMap(obj)"), "hello");
+ assertEquals(e.eval("Window.funcJSObject(obj)"), "hello");
+ }
+
+ // @bug 8032948: Nashorn linkages awry
+ @Test
+ public void checkProxyAccess() throws ScriptException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final boolean[] reached = new boolean[1];
+ final Runnable r = (Runnable)Proxy.newProxyInstance(
+ ScriptEngineTest.class.getClassLoader(),
+ new Class[] { Runnable.class },
+ new InvocationHandler() {
+ @Override
+ public Object invoke(final Object p, final Method mtd, final Object[] a) {
+ reached[0] = true;
+ return null;
+ }
+ });
+
+ e.put("r", r);
+ e.eval("r.run()");
+
+ assertTrue(reached[0]);
+ }
+
+ // properties that can be read by any code
+ private static String[] propNames = {
+ "java.version",
+ "java.vendor",
+ "java.vendor.url",
+ "java.class.version",
+ "os.name",
+ "os.version",
+ "os.arch",
+ "file.separator",
+ "path.separator",
+ "line.separator",
+ "java.specification.version",
+ "java.specification.vendor",
+ "java.specification.name",
+ "java.vm.specification.version",
+ "java.vm.specification.vendor",
+ "java.vm.specification.name",
+ "java.vm.version",
+ "java.vm.vendor",
+ "java.vm.name"
+ };
+
+ // @bug 8033924: Default permissions are not given for eval code
+ @Test
+ public void checkPropertyReadPermissions() throws ScriptException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+
+ for (final String name : propNames) {
+ checkProperty(e, name);
+ }
+ }
+
+ // @bug 8046013: TypeError: Cannot apply "with" to non script object
+ @Test
+ public void withOnMirrorTest() throws ScriptException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+
+ final Object obj = e.eval("({ foo: 'hello'})");
+ final Object[] arr = new Object[1];
+ arr[0] = obj;
+ e.put("arr", arr);
+ final Object res = e.eval("var res; with(arr[0]) { res = foo; }; res");
+ assertEquals(res, "hello");
+ }
+
+ // @bug 8054223: Nashorn: AssertionError when use __DIR__ and ScriptEngine.eval()
+ @Test
+ public void check__DIR__Test() throws ScriptException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ e.eval("__DIR__");
+ }
+
+ // @bug 8050432:javax.script.filename variable should not be enumerable
+ // with nashorn engine's ENGINE_SCOPE bindings
+ @Test
+ public void enumerableGlobalsTest() throws ScriptException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+
+ e.put(ScriptEngine.FILENAME, "test");
+ final Object enumerable = e.eval(
+ "Object.getOwnPropertyDescriptor(this, " +
+ " 'javax.script.filename').enumerable");
+ assertEquals(enumerable, Boolean.FALSE);
+ }
+
+ public static class Context {
+ private Object myobj;
+
+ public void set(final Object o) {
+ myobj = o;
+ }
+
+ public Object get() {
+ return myobj;
+ }
+ }
+
+ // @bug 8050977: Java8 Javascript Nashorn exception:
+ // no current Global instance for nashorn
+ @Test
+ public void currentGlobalMissingTest() throws Exception {
+ final ScriptEngineManager manager = new ScriptEngineManager();
+ final ScriptEngine e = manager.getEngineByName("nashorn");
+
+ final Context ctx = new Context();
+ e.put("ctx", ctx);
+ e.eval("var obj = { foo: function(str) { return str.toUpperCase() } }");
+ e.eval("ctx.set(obj)");
+ final Invocable inv = (Invocable)e;
+ assertEquals("HELLO", inv.invokeMethod(ctx.get(), "foo", "hello"));
+ // try object literal
+ e.eval("ctx.set({ bar: function(str) { return str.toLowerCase() } })");
+ assertEquals("hello", inv.invokeMethod(ctx.get(), "bar", "HELLO"));
+ // try array literal
+ e.eval("var arr = [ 'hello', 'world' ]");
+ e.eval("ctx.set(arr)");
+ assertEquals("helloworld", inv.invokeMethod(ctx.get(), "join", ""));
+ }
+
+ // @bug 8068524: NashornScriptEngineFactory.getParameter() throws IAE
+ // for an unknown key, doesn't conform to the general spec
+ @Test
+ public void getParameterInvalidKeyTest() throws Exception {
+ final ScriptEngineManager manager = new ScriptEngineManager();
+ final ScriptEngine e = manager.getEngineByName("nashorn");
+ // no exception expected here!
+ Object value = e.getFactory().getParameter("no value assigned to this key");
+ assertNull(value);
+ }
+
+ // @bug JDK-8068889: ConsString arguments to a functional interface wasn't converted to string.
+ @Test
+ public void functionalInterfaceStringTest() throws Exception {
+ final ScriptEngineManager manager = new ScriptEngineManager();
+ final ScriptEngine e = manager.getEngineByName("nashorn");
+ final AtomicBoolean invoked = new AtomicBoolean(false);
+ e.put("f", new Function<String, String>() {
+ @Override
+ public String apply(String t) {
+ invoked.set(true);
+ return t;
+ }
+ });
+ assertEquals(e.eval("var x = 'a'; x += 'b'; f(x)"), "ab");
+ assertTrue(invoked.get());
+ }
+
+ // @bug JDK-8068889: ScriptObject arguments to a functional interface wasn't converted to a mirror.
+ @Test
+ public void functionalInterfaceObjectTest() throws Exception {
+ final ScriptEngineManager manager = new ScriptEngineManager();
+ final ScriptEngine e = manager.getEngineByName("nashorn");
+ final AtomicBoolean invoked = new AtomicBoolean(false);
+ e.put("c", new Consumer<Object>() {
+ @Override
+ public void accept(Object t) {
+ assertTrue(t instanceof ScriptObjectMirror);
+ assertEquals(((ScriptObjectMirror)t).get("a"), "xyz");
+ invoked.set(true);
+ }
+ });
+ e.eval("var x = 'xy'; x += 'z';c({a:x})");
+ assertTrue(invoked.get());
+ }
+
+ @Test
+ public void testLengthOnArrayLikeObjects() throws Exception {
+ final ScriptEngine e = new ScriptEngineManager().getEngineByName("nashorn");
+ final Object val = e.eval("var arr = { length: 1, 0: 1}; arr.length");
+
+ assertTrue(Number.class.isAssignableFrom(val.getClass()));
+ assertTrue(((Number)val).intValue() == 1);
+ }
+
+ // @bug JDK-8068603: NashornScriptEngine.put/get() impls don't conform to NPE, IAE spec assertions
+ @Test
+ public void illegalBindingsValuesTest() throws Exception {
+ final ScriptEngineManager manager = new ScriptEngineManager();
+ final ScriptEngine e = manager.getEngineByName("nashorn");
+
+ try {
+ e.put(null, "null-value");
+ fail();
+ } catch (NullPointerException x) {
+ // expected
+ }
+
+ try {
+ e.put("", "empty-value");
+ fail();
+ } catch (IllegalArgumentException x) {
+ // expected
+ }
+
+ final Bindings b = e.getBindings(ScriptContext.ENGINE_SCOPE);
+ assertTrue(b instanceof ScriptObjectMirror);
+
+ try {
+ b.put(null, "null-value");
+ fail();
+ } catch (NullPointerException x) {
+ // expected
+ }
+
+ try {
+ b.put("", "empty-value");
+ fail();
+ } catch (IllegalArgumentException x) {
+ // expected
+ }
+
+ try {
+ b.get(null);
+ fail();
+ } catch (NullPointerException x) {
+ // expected
+ }
+
+ try {
+ b.get("");
+ fail();
+ } catch (IllegalArgumentException x) {
+ // expected
+ }
+
+ try {
+ b.get(1);
+ fail();
+ } catch (ClassCastException x) {
+ // expected
+ }
+
+ try {
+ b.remove(null);
+ fail();
+ } catch (NullPointerException x) {
+ // expected
+ }
+
+ try {
+ b.remove("");
+ fail();
+ } catch (IllegalArgumentException x) {
+ // expected
+ }
+
+ try {
+ b.remove(1);
+ fail();
+ } catch (ClassCastException x) {
+ // expected
+ }
+
+ try {
+ b.containsKey(null);
+ fail();
+ } catch (NullPointerException x) {
+ // expected
+ }
+
+ try {
+ b.containsKey("");
+ fail();
+ } catch (IllegalArgumentException x) {
+ // expected
+ }
+
+ try {
+ b.containsKey(1);
+ fail();
+ } catch (ClassCastException x) {
+ // expected
+ }
+
+ try {
+ b.putAll(null);
+ fail();
+ } catch (NullPointerException x) {
+ // expected
+ }
+
+ try {
+ b.putAll(Collections.singletonMap((String)null, "null-value"));
+ fail();
+ } catch (NullPointerException x) {
+ // expected
+ }
+
+ try {
+ b.putAll(Collections.singletonMap("", "empty-value"));
+ fail();
+ } catch (IllegalArgumentException x) {
+ // expected
+ }
+ }
+
+ // @bug 8071989: NashornScriptEngine returns javax.script.ScriptContext instance
+ // with insonsistent get/remove methods behavior for undefined attributes
+ @Test
+ public void testScriptContextGetRemoveUndefined() throws Exception {
+ final ScriptEngineManager manager = new ScriptEngineManager();
+ final ScriptEngine e = manager.getEngineByName("nashorn");
+ final ScriptContext ctx = e.getContext();
+ assertNull(ctx.getAttribute("undefinedname", ScriptContext.ENGINE_SCOPE));
+ assertNull(ctx.removeAttribute("undefinedname", ScriptContext.ENGINE_SCOPE));
+ }
+
+ private static void checkProperty(final ScriptEngine e, final String name)
+ throws ScriptException {
+ final String value = System.getProperty(name);
+ e.put("name", name);
+ assertEquals(value, e.eval("java.lang.System.getProperty(name)"));
+ }
+
+ private static final String LINE_SEPARATOR = System.getProperty("line.separator");
+
+ // Returns String that would be the result of calling PrintWriter.println
+ // of the given String. (This is to handle platform specific newline).
+ private static String println(final String str) {
+ return str + LINE_SEPARATOR;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/api/scripting/test/ScriptObjectMirrorTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,389 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.scripting.test;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+import java.nio.ByteBuffer;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+import javax.script.Bindings;
+import javax.script.Invocable;
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import jdk.nashorn.api.scripting.JSObject;
+import jdk.nashorn.api.scripting.ScriptObjectMirror;
+import org.testng.annotations.Test;
+
+/**
+ * Tests to check jdk.nashorn.api.scripting.ScriptObjectMirror API.
+ */
+@SuppressWarnings("javadoc")
+public class ScriptObjectMirrorTest {
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void reflectionTest() throws ScriptException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+
+ e.eval("var obj = { x: 344, y: 'nashorn' }");
+
+ int count = 0;
+ Map<Object, Object> map = (Map<Object, Object>) e.get("obj");
+ assertFalse(map.isEmpty());
+ assertTrue(map.keySet().contains("x"));
+ assertTrue(map.containsKey("x"));
+ assertTrue(map.values().contains("nashorn"));
+ assertTrue(map.containsValue("nashorn"));
+ for (final Map.Entry<?, ?> ex : map.entrySet()) {
+ final Object key = ex.getKey();
+ if (key.equals("x")) {
+ assertTrue(344 == ((Number) ex.getValue()).doubleValue());
+ count++;
+ } else if (key.equals("y")) {
+ assertEquals(ex.getValue(), "nashorn");
+ count++;
+ }
+ }
+ assertEquals(2, count);
+ assertEquals(2, map.size());
+
+ // add property
+ map.put("z", "hello");
+ assertEquals(e.eval("obj.z"), "hello");
+ assertEquals(map.get("z"), "hello");
+ assertTrue(map.keySet().contains("z"));
+ assertTrue(map.containsKey("z"));
+ assertTrue(map.values().contains("hello"));
+ assertTrue(map.containsValue("hello"));
+ assertEquals(map.size(), 3);
+
+ final Map<Object, Object> newMap = new HashMap<>();
+ newMap.put("foo", 23.0);
+ newMap.put("bar", true);
+ map.putAll(newMap);
+
+ assertEquals(e.eval("obj.foo"), 23.0);
+ assertEquals(e.eval("obj.bar"), true);
+
+ // remove using map method
+ map.remove("foo");
+ assertEquals(e.eval("typeof obj.foo"), "undefined");
+
+ count = 0;
+ e.eval("var arr = [ true, 'hello' ]");
+ map = (Map<Object, Object>) e.get("arr");
+ assertFalse(map.isEmpty());
+ assertTrue(map.containsKey("length"));
+ assertTrue(map.containsValue("hello"));
+ for (final Map.Entry<?, ?> ex : map.entrySet()) {
+ final Object key = ex.getKey();
+ if (key.equals("0")) {
+ assertEquals(ex.getValue(), Boolean.TRUE);
+ count++;
+ } else if (key.equals("1")) {
+ assertEquals(ex.getValue(), "hello");
+ count++;
+ }
+ }
+ assertEquals(count, 2);
+ assertEquals(map.size(), 2);
+
+ // add element
+ map.put("2", "world");
+ assertEquals(map.get("2"), "world");
+ assertEquals(map.size(), 3);
+
+ // remove all
+ map.clear();
+ assertTrue(map.isEmpty());
+ assertEquals(e.eval("typeof arr[0]"), "undefined");
+ assertEquals(e.eval("typeof arr[1]"), "undefined");
+ assertEquals(e.eval("typeof arr[2]"), "undefined");
+ }
+
+ @Test
+ public void jsobjectTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ try {
+ e.eval("var obj = { '1': 'world', func: function() { return this.bar; }, bar: 'hello' }");
+ final ScriptObjectMirror obj = (ScriptObjectMirror) e.get("obj");
+
+ // try basic get on existing properties
+ if (!obj.getMember("bar").equals("hello")) {
+ fail("obj.bar != 'hello'");
+ }
+
+ if (!obj.getSlot(1).equals("world")) {
+ fail("obj[1] != 'world'");
+ }
+
+ if (!obj.callMember("func", new Object[0]).equals("hello")) {
+ fail("obj.func() != 'hello'");
+ }
+
+ // try setting properties
+ obj.setMember("bar", "new-bar");
+ obj.setSlot(1, "new-element-1");
+ if (!obj.getMember("bar").equals("new-bar")) {
+ fail("obj.bar != 'new-bar'");
+ }
+
+ if (!obj.getSlot(1).equals("new-element-1")) {
+ fail("obj[1] != 'new-element-1'");
+ }
+
+ // try adding properties
+ obj.setMember("prop", "prop-value");
+ obj.setSlot(12, "element-12");
+ if (!obj.getMember("prop").equals("prop-value")) {
+ fail("obj.prop != 'prop-value'");
+ }
+
+ if (!obj.getSlot(12).equals("element-12")) {
+ fail("obj[12] != 'element-12'");
+ }
+
+ // delete properties
+ obj.removeMember("prop");
+ if ("prop-value".equals(obj.getMember("prop"))) {
+ fail("obj.prop is not deleted!");
+ }
+
+ // Simple eval tests
+ assertEquals(obj.eval("typeof Object"), "function");
+ assertEquals(obj.eval("'nashorn'.substring(3)"), "horn");
+ } catch (final Exception exp) {
+ exp.printStackTrace();
+ fail(exp.getMessage());
+ }
+ }
+
+ @Test
+ public void scriptObjectMirrorToStringTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ try {
+ final Object obj = e.eval("new TypeError('wrong type')");
+ assertEquals(obj.toString(), "TypeError: wrong type", "toString returns wrong value");
+ } catch (final Throwable t) {
+ t.printStackTrace();
+ fail(t.getMessage());
+ }
+
+ try {
+ final Object obj = e.eval("function func() { print('hello'); }");
+ assertEquals(obj.toString(), "function func() { print('hello'); }", "toString returns wrong value");
+ } catch (final Throwable t) {
+ t.printStackTrace();
+ fail(t.getMessage());
+ }
+ }
+
+ @Test
+ public void mirrorNewObjectGlobalFunctionTest() throws ScriptException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final ScriptEngine e2 = m.getEngineByName("nashorn");
+
+ e.eval("function func() {}");
+ e2.put("foo", e.get("func"));
+ final ScriptObjectMirror e2global = (ScriptObjectMirror)e2.eval("this");
+ final Object newObj = ((ScriptObjectMirror)e2global.getMember("foo")).newObject();
+ assertTrue(newObj instanceof ScriptObjectMirror);
+ }
+
+ @Test
+ public void mirrorNewObjectInstanceFunctionTest() throws ScriptException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final ScriptEngine e2 = m.getEngineByName("nashorn");
+
+ e.eval("function func() {}");
+ e2.put("func", e.get("func"));
+ final ScriptObjectMirror e2obj = (ScriptObjectMirror)e2.eval("({ foo: func })");
+ final Object newObj = ((ScriptObjectMirror)e2obj.getMember("foo")).newObject();
+ assertTrue(newObj instanceof ScriptObjectMirror);
+ }
+
+ @Test
+ public void indexPropertiesExternalBufferTest() throws ScriptException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final ScriptObjectMirror obj = (ScriptObjectMirror)e.eval("var obj = {}; obj");
+ final ByteBuffer buf = ByteBuffer.allocate(5);
+ int i;
+ for (i = 0; i < 5; i++) {
+ buf.put(i, (byte)(i+10));
+ }
+ obj.setIndexedPropertiesToExternalArrayData(buf);
+
+ for (i = 0; i < 5; i++) {
+ assertEquals((byte)(i+10), ((Number)e.eval("obj[" + i + "]")).byteValue());
+ }
+
+ e.eval("for (i = 0; i < 5; i++) obj[i] = 0");
+ for (i = 0; i < 5; i++) {
+ assertEquals((byte)0, ((Number)e.eval("obj[" + i + "]")).byteValue());
+ assertEquals((byte)0, buf.get(i));
+ }
+ }
+
+ @Test
+ public void conversionTest() throws ScriptException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final ScriptObjectMirror arr = (ScriptObjectMirror)e.eval("[33, 45, 23]");
+ final int[] intArr = arr.to(int[].class);
+ assertEquals(intArr[0], 33);
+ assertEquals(intArr[1], 45);
+ assertEquals(intArr[2], 23);
+
+ final List<?> list = arr.to(List.class);
+ assertEquals(list.get(0), 33);
+ assertEquals(list.get(1), 45);
+ assertEquals(list.get(2), 23);
+
+ ScriptObjectMirror obj = (ScriptObjectMirror)e.eval(
+ "({ valueOf: function() { return 42 } })");
+ assertEquals(Double.valueOf(42.0), obj.to(Double.class));
+
+ obj = (ScriptObjectMirror)e.eval(
+ "({ toString: function() { return 'foo' } })");
+ assertEquals("foo", obj.to(String.class));
+ }
+
+ // @bug 8044000: Access to undefined property yields "null" instead of "undefined"
+ @Test
+ public void mapScriptObjectMirrorCallsiteTest() throws ScriptException {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine engine = m.getEngineByName("nashorn");
+ final String TEST_SCRIPT = "typeof obj.foo";
+
+ final Bindings global = engine.getContext().getBindings(ScriptContext.ENGINE_SCOPE);
+ engine.eval("var obj = java.util.Collections.emptyMap()");
+ // this will drive callsite "obj.foo" of TEST_SCRIPT
+ // to use "obj instanceof Map" as it's guard
+ engine.eval(TEST_SCRIPT, global);
+ // redefine 'obj' to be a script object
+ engine.eval("obj = {}");
+
+ final Bindings newGlobal = engine.createBindings();
+ // transfer 'obj' from default global to new global
+ // new global will get a ScriptObjectMirror wrapping 'obj'
+ newGlobal.put("obj", global.get("obj"));
+
+ // Every ScriptObjectMirror is a Map! If callsite "obj.foo"
+ // does not see the new 'obj' is a ScriptObjectMirror, it'll
+ // continue to use Map's get("obj.foo") instead of ScriptObjectMirror's
+ // getMember("obj.foo") - thereby getting null instead of undefined
+ assertEquals("undefined", engine.eval(TEST_SCRIPT, newGlobal));
+ }
+
+ public interface MirrorCheckExample {
+ Object test1(Object arg);
+ Object test2(Object arg);
+ boolean compare(Object o1, Object o2);
+ }
+
+ // @bug 8053910: ScriptObjectMirror causing havoc with Invocation interface
+ @Test
+ public void checkMirrorToObject() throws Exception {
+ final ScriptEngineManager engineManager = new ScriptEngineManager();
+ final ScriptEngine engine = engineManager.getEngineByName("nashorn");
+ final Invocable invocable = (Invocable)engine;
+
+ engine.eval("function test1(arg) { return { arg: arg }; }");
+ engine.eval("function test2(arg) { return arg; }");
+ engine.eval("function compare(arg1, arg2) { return arg1 == arg2; }");
+
+ final Map<String, Object> map = new HashMap<>();
+ map.put("option", true);
+
+ final MirrorCheckExample example = invocable.getInterface(MirrorCheckExample.class);
+
+ final Object value1 = invocable.invokeFunction("test1", map);
+ final Object value2 = example.test1(map);
+ final Object value3 = invocable.invokeFunction("test2", value2);
+ final Object value4 = example.test2(value2);
+
+ // check that Object type argument receives a ScriptObjectMirror
+ // when ScriptObject is passed
+ assertEquals(ScriptObjectMirror.class, value1.getClass());
+ assertEquals(ScriptObjectMirror.class, value2.getClass());
+ assertEquals(ScriptObjectMirror.class, value3.getClass());
+ assertEquals(ScriptObjectMirror.class, value4.getClass());
+ assertTrue((boolean)invocable.invokeFunction("compare", value1, value1));
+ assertTrue(example.compare(value1, value1));
+ assertTrue((boolean)invocable.invokeFunction("compare", value3, value4));
+ assertTrue(example.compare(value3, value4));
+ }
+
+ // @bug 8053910: ScriptObjectMirror causing havoc with Invocation interface
+ @Test
+ public void mirrorUnwrapInterfaceMethod() throws Exception {
+ final ScriptEngineManager engineManager = new ScriptEngineManager();
+ final ScriptEngine engine = engineManager.getEngineByName("nashorn");
+ final Invocable invocable = (Invocable)engine;
+ engine.eval("function apply(obj) { " +
+ " return obj instanceof Packages.jdk.nashorn.api.scripting.ScriptObjectMirror; " +
+ "}");
+ @SuppressWarnings("unchecked")
+ final Function<Object,Object> func = invocable.getInterface(Function.class);
+ assertFalse((boolean)func.apply(engine.eval("({ x: 2 })")));
+ }
+
+ // @bug 8055687: Wrong "this" passed to JSObject.eval call
+ @Test
+ public void checkThisForJSObjectEval() throws Exception {
+ final ScriptEngineManager engineManager = new ScriptEngineManager();
+ final ScriptEngine e = engineManager.getEngineByName("nashorn");
+ final JSObject jsobj = (JSObject)e.eval("({foo: 23, bar: 'hello' })");
+ assertEquals(((Number)jsobj.eval("this.foo")).intValue(), 23);
+ assertEquals(jsobj.eval("this.bar"), "hello");
+ assertEquals(jsobj.eval("String(this)"), "[object Object]");
+ final Object global = e.eval("this");
+ assertFalse(global.equals(jsobj.eval("this")));
+ }
+
+ @Test
+ public void topLevelAnonFuncStatement() throws Exception {
+ final ScriptEngineManager engineManager = new ScriptEngineManager();
+ final ScriptEngine e = engineManager.getEngineByName("nashorn");
+ final JSObject func = (JSObject)e.eval("function(x) { return x + ' world' }");
+ assertTrue(func.isFunction());
+ assertEquals(func.call(e.eval("this"), "hello"), "hello world");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/api/scripting/test/VariableArityTestInterface.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.scripting.test;
+
+@SuppressWarnings("javadoc")
+public interface VariableArityTestInterface {
+ public String test1(int i, String... strings);
+ public String test2(int i, String... strings);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/api/scripting/test/Window.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.scripting.test;
+
+import java.util.Map;
+import javax.script.Bindings;
+import jdk.nashorn.api.scripting.JSObject;
+import jdk.nashorn.api.scripting.ScriptObjectMirror;
+
+@SuppressWarnings("javadoc")
+public class Window {
+
+ private String location = "http://localhost:8080/window";
+
+ private WindowEventHandler onload = null;
+
+ public void alert(final String message) {
+ System.out.println("alert: " + message);
+ }
+
+ public String getLocation() {
+ return location;
+ }
+
+ public void setLocation(final String location) {
+ this.location = location;
+ }
+
+ public String item(final int index) {
+ return Integer.toHexString(index);
+ }
+
+ public WindowEventHandler getOnload() {
+ return onload;
+ }
+
+ public void setOnload(final WindowEventHandler onload) {
+ this.onload = onload;
+ }
+
+ public static int setTimeout(final Window self, final String code, final int delay) {
+ return self.setTimeout(code, delay);
+ }
+
+ public int setTimeout(final String code, final int delay) {
+ System.out.println("window.setTimeout: " + delay + ", code: " + code);
+ return 0;
+ }
+
+ public static Object funcJSObject(final JSObject jsobj) {
+ return jsobj.getMember("foo");
+ }
+
+ public static Object funcScriptObjectMirror(final ScriptObjectMirror sobj) {
+ return sobj.get("foo");
+ }
+
+ public static Object funcMap(final Map<?,?> map) {
+ return map.get("foo");
+ }
+
+ public static Object funcBindings(final Bindings bindings) {
+ return bindings.get("foo");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/api/scripting/test/WindowEventHandler.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.scripting.test;
+
+@SuppressWarnings("javadoc")
+public interface WindowEventHandler {
+ public boolean loaded();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/api/scripting/test/resources/func.js Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// This script is loaded from jdk.nashorn.api.scripting.ScopeTest to test script class sharing and reuse.
+
+var scopeVar = 1;
+var global = this;
+undefGlobal = this;
+
+function scopeTest() {
+ if (this !== global) {
+ throw new Error("this !== global");
+ }
+ if (this !== undefGlobal) {
+ throw new Error("this !== undefinedGlobal")
+ }
+ return scopeVar;
+}
+
+scopeTest();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/api/scripting/test/resources/gettersetter.js Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// This script is loaded from jdk.nashorn.api.scripting.ScopeTest to test script class sharing and reuse.
+
+var v;
+
+Object.defineProperty(this, "accessor1", {
+ get: function() { return v; },
+ set: function(n) { v = n; }
+});
+
+Object.defineProperty(this, "accessor2", {
+ get: function() { return x; },
+ set: function(n) { x = n; }
+});
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/api/scripting/test/resources/witheval.js Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// This script is loaded from jdk.nashorn.api.scripting.ScopeTest to test script class sharing and reuse.
+
+var a;
+
+function outer(p, e) {
+ eval(e);
+ with(p) {
+ function inner() {
+ a = 1;
+ c = 10;
+ if (a !== 1) {
+ throw new Error("a !== 1");
+ }
+ if (b !== 3) {
+ throw new Error("b !== 3");
+ }
+ if (c !== 10) {
+ throw new Error("c !== 10");
+ }
+ }
+ inner();
+ }
+}
+
+outer({}, "b = 3;");
+
+if (a !== 1) {
+ throw new Error("a !== 1");
+}
+if (b !== 3) {
+ throw new Error("b !== 3");
+}
+if (c !== 10) {
+ throw new Error("c !== 10");
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/api/test/NashornSQLDriver.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.test;
+
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.DriverPropertyInfo;
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+import java.util.Properties;
+import java.util.logging.Logger;
+
+/**
+ * A dummy SQL driver for testing purpose.
+ */
+public final class NashornSQLDriver implements Driver {
+ static {
+ try {
+ DriverManager.registerDriver(new NashornSQLDriver(), null);
+ } catch (final SQLException se) {
+ throw new RuntimeException(se);
+ }
+ }
+
+ @Override
+ public boolean acceptsURL(final String url) {
+ return url.startsWith("jdbc:nashorn:");
+ }
+
+ @Override
+ public Connection connect(final String url, final Properties info) {
+ throw new UnsupportedOperationException("I am a dummy!!");
+ }
+
+ @Override
+ public int getMajorVersion() {
+ return -1;
+ }
+
+ @Override
+ public int getMinorVersion() {
+ return -1;
+ }
+
+ @Override
+ public DriverPropertyInfo[] getPropertyInfo(final String url, final Properties info) {
+ return new DriverPropertyInfo[0];
+ }
+
+ @Override
+ public boolean jdbcCompliant() {
+ // no way!
+ return false;
+ }
+
+ @Override
+ public Logger getParentLogger() throws SQLFeatureNotSupportedException {
+ throw new SQLFeatureNotSupportedException();
+ }
+}
--- a/nashorn/test/src/jdk/nashorn/api/tree/ParseAPITest.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,188 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package jdk.nashorn.api.tree;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-/**
- * Test for nashorn Parser API (jdk.nashorn.api.tree.*)
- */
-public class ParseAPITest {
-
- private static final boolean VERBOSE = Boolean.valueOf(System.getProperty("parserapitest.verbose"));
- private static final boolean TEST262 = Boolean.valueOf(System.getProperty("parserapitest.test262"));
-
- private static final String TEST_BASIC_DIR = System.getProperty("test.basic.dir");
- private static final String TEST_MAPTESTS_DIR = System.getProperty("test.maptests.dir");
- private static final String TEST_SANDBOX_DIR = System.getProperty("test.sandbox.dir");
- private static final String TEST_TRUSTED_DIR = System.getProperty("test.trusted.dir");
- private static final String TEST262_SUITE_DIR = System.getProperty("test262.suite.dir");
-
- interface TestFilter {
- public boolean exclude(File file, String content);
- }
-
- private void log(String msg) {
- org.testng.Reporter.log(msg, true);
- }
-
- private static final String[] options = new String[] {
- "-scripting", "--const-as-var"
- };
-
- @Test
- public void parseAllTests() {
- if (TEST262) {
- parseTestSet(TEST262_SUITE_DIR, new TestFilter() {
- @Override
- public boolean exclude(final File file, final String content) {
- return content.indexOf("@negative") != -1;
- }
- });
- }
- parseTestSet(TEST_BASIC_DIR, new TestFilter() {
- @Override
- public boolean exclude(final File file, final String content) {
- return file.getParentFile().getName().equals("es6");
- }
- });
- parseTestSet(TEST_MAPTESTS_DIR, null);
- parseTestSet(TEST_SANDBOX_DIR, null);
- parseTestSet(TEST_TRUSTED_DIR, null);
- }
-
- private void parseTestSet(final String testSet, final TestFilter filter) {
- passed = 0;
- failed = 0;
- skipped = 0;
-
- final File testSetDir = new File(testSet);
- if (! testSetDir.isDirectory()) {
- log("WARNING: " + testSetDir + " not found or not a directory");
- return;
- }
- log(testSetDir.getAbsolutePath());
- parseJSDirectory(testSetDir, filter);
-
- log(testSet + " parse API done!");
- log("parse API ok: " + passed);
- log("parse API failed: " + failed);
- log("parse API skipped: " + skipped);
- if (failed != 0) {
- Assert.fail(failed + " tests failed to parse in " + testSetDir.getAbsolutePath());
- }
- }
-
- // number of scripts that parsed fine
- private int passed;
- // number of scripts resulting in parse failure
- private int failed;
- // scripts that were skipped - all tests with @negative are
- // skipped for now.
- private int skipped;
-
- private void parseJSDirectory(final File dir, final TestFilter filter) {
- for (final File f : dir.listFiles()) {
- if (f.isDirectory()) {
- parseJSDirectory(f, filter);
- } else if (f.getName().endsWith(".js")) {
- parseJSFile(f, filter);
- }
- }
- }
-
- private void parseJSFile(final File file, final TestFilter filter) {
- if (VERBOSE) {
- log("Begin parsing " + file.getAbsolutePath());
- }
-
- try {
- final char[] buffer = readFully(file);
- final String content = new String(buffer);
- boolean excluded = false;
- if (filter != null) {
- excluded = filter.exclude(file, content);
- }
-
- if (excluded) {
- if (VERBOSE) {
- log("Skipping " + file.getAbsolutePath());
- }
- skipped++;
- return;
- }
-
- final Parser parser = Parser.create(options);
- final Tree tree = parser.parse(file.getAbsolutePath(), content, null);
- tree.accept(new SimpleTreeVisitorES5_1<Void, Void>(), null);
- passed++;
- } catch (final Throwable exp) {
- log("Parse API failed: " + file.getAbsolutePath() + " : " + exp);
- //if (VERBOSE) {
- exp.printStackTrace(System.out);
- //}
- failed++;
- }
-
- if (VERBOSE) {
- log("Done parsing via parser API " + file.getAbsolutePath());
- }
- }
-
- private static char[] byteToCharArray(final byte[] bytes) {
- Charset cs = StandardCharsets.UTF_8;
- int start = 0;
- // BOM detection.
- if (bytes.length > 1 && bytes[0] == (byte) 0xFE && bytes[1] == (byte) 0xFF) {
- start = 2;
- cs = StandardCharsets.UTF_16BE;
- } else if (bytes.length > 1 && bytes[0] == (byte) 0xFF && bytes[1] == (byte) 0xFE) {
- start = 2;
- cs = StandardCharsets.UTF_16LE;
- } else if (bytes.length > 2 && bytes[0] == (byte) 0xEF && bytes[1] == (byte) 0xBB && bytes[2] == (byte) 0xBF) {
- start = 3;
- cs = StandardCharsets.UTF_8;
- } else if (bytes.length > 3 && bytes[0] == (byte) 0xFF && bytes[1] == (byte) 0xFE && bytes[2] == 0 && bytes[3] == 0) {
- start = 4;
- cs = Charset.forName("UTF-32LE");
- } else if (bytes.length > 3 && bytes[0] == 0 && bytes[1] == 0 && bytes[2] == (byte) 0xFE && bytes[3] == (byte) 0xFF) {
- start = 4;
- cs = Charset.forName("UTF-32BE");
- }
-
- return new String(bytes, start, bytes.length - start, cs).toCharArray();
- }
-
- private static char[] readFully(final File file) throws IOException {
- final byte[] buf = Files.readAllBytes(file.toPath());
- return byteToCharArray(buf);
- }
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/api/tree/test/ParseAPITest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,191 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.nashorn.api.tree.test;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import jdk.nashorn.api.tree.Parser;
+import jdk.nashorn.api.tree.SimpleTreeVisitorES5_1;
+import jdk.nashorn.api.tree.Tree;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * Test for nashorn Parser API (jdk.nashorn.api.tree.*)
+ */
+public class ParseAPITest {
+
+ private static final boolean VERBOSE = Boolean.valueOf(System.getProperty("parserapitest.verbose"));
+ private static final boolean TEST262 = Boolean.valueOf(System.getProperty("parserapitest.test262"));
+
+ private static final String TEST_BASIC_DIR = System.getProperty("test.basic.dir");
+ private static final String TEST_MAPTESTS_DIR = System.getProperty("test.maptests.dir");
+ private static final String TEST_SANDBOX_DIR = System.getProperty("test.sandbox.dir");
+ private static final String TEST_TRUSTED_DIR = System.getProperty("test.trusted.dir");
+ private static final String TEST262_SUITE_DIR = System.getProperty("test262.suite.dir");
+
+ interface TestFilter {
+ public boolean exclude(File file, String content);
+ }
+
+ private void log(String msg) {
+ org.testng.Reporter.log(msg, true);
+ }
+
+ private static final String[] options = new String[] {
+ "-scripting", "--const-as-var"
+ };
+
+ @Test
+ public void parseAllTests() {
+ if (TEST262) {
+ parseTestSet(TEST262_SUITE_DIR, new TestFilter() {
+ @Override
+ public boolean exclude(final File file, final String content) {
+ return content.indexOf("@negative") != -1;
+ }
+ });
+ }
+ parseTestSet(TEST_BASIC_DIR, new TestFilter() {
+ @Override
+ public boolean exclude(final File file, final String content) {
+ return file.getParentFile().getName().equals("es6");
+ }
+ });
+ parseTestSet(TEST_MAPTESTS_DIR, null);
+ parseTestSet(TEST_SANDBOX_DIR, null);
+ parseTestSet(TEST_TRUSTED_DIR, null);
+ }
+
+ private void parseTestSet(final String testSet, final TestFilter filter) {
+ passed = 0;
+ failed = 0;
+ skipped = 0;
+
+ final File testSetDir = new File(testSet);
+ if (! testSetDir.isDirectory()) {
+ log("WARNING: " + testSetDir + " not found or not a directory");
+ return;
+ }
+ log(testSetDir.getAbsolutePath());
+ parseJSDirectory(testSetDir, filter);
+
+ log(testSet + " parse API done!");
+ log("parse API ok: " + passed);
+ log("parse API failed: " + failed);
+ log("parse API skipped: " + skipped);
+ if (failed != 0) {
+ Assert.fail(failed + " tests failed to parse in " + testSetDir.getAbsolutePath());
+ }
+ }
+
+ // number of scripts that parsed fine
+ private int passed;
+ // number of scripts resulting in parse failure
+ private int failed;
+ // scripts that were skipped - all tests with @negative are
+ // skipped for now.
+ private int skipped;
+
+ private void parseJSDirectory(final File dir, final TestFilter filter) {
+ for (final File f : dir.listFiles()) {
+ if (f.isDirectory()) {
+ parseJSDirectory(f, filter);
+ } else if (f.getName().endsWith(".js")) {
+ parseJSFile(f, filter);
+ }
+ }
+ }
+
+ private void parseJSFile(final File file, final TestFilter filter) {
+ if (VERBOSE) {
+ log("Begin parsing " + file.getAbsolutePath());
+ }
+
+ try {
+ final char[] buffer = readFully(file);
+ final String content = new String(buffer);
+ boolean excluded = false;
+ if (filter != null) {
+ excluded = filter.exclude(file, content);
+ }
+
+ if (excluded) {
+ if (VERBOSE) {
+ log("Skipping " + file.getAbsolutePath());
+ }
+ skipped++;
+ return;
+ }
+
+ final Parser parser = Parser.create(options);
+ final Tree tree = parser.parse(file.getAbsolutePath(), content, null);
+ tree.accept(new SimpleTreeVisitorES5_1<Void, Void>(), null);
+ passed++;
+ } catch (final Throwable exp) {
+ log("Parse API failed: " + file.getAbsolutePath() + " : " + exp);
+ //if (VERBOSE) {
+ exp.printStackTrace(System.out);
+ //}
+ failed++;
+ }
+
+ if (VERBOSE) {
+ log("Done parsing via parser API " + file.getAbsolutePath());
+ }
+ }
+
+ private static char[] byteToCharArray(final byte[] bytes) {
+ Charset cs = StandardCharsets.UTF_8;
+ int start = 0;
+ // BOM detection.
+ if (bytes.length > 1 && bytes[0] == (byte) 0xFE && bytes[1] == (byte) 0xFF) {
+ start = 2;
+ cs = StandardCharsets.UTF_16BE;
+ } else if (bytes.length > 1 && bytes[0] == (byte) 0xFF && bytes[1] == (byte) 0xFE) {
+ start = 2;
+ cs = StandardCharsets.UTF_16LE;
+ } else if (bytes.length > 2 && bytes[0] == (byte) 0xEF && bytes[1] == (byte) 0xBB && bytes[2] == (byte) 0xBF) {
+ start = 3;
+ cs = StandardCharsets.UTF_8;
+ } else if (bytes.length > 3 && bytes[0] == (byte) 0xFF && bytes[1] == (byte) 0xFE && bytes[2] == 0 && bytes[3] == 0) {
+ start = 4;
+ cs = Charset.forName("UTF-32LE");
+ } else if (bytes.length > 3 && bytes[0] == 0 && bytes[1] == 0 && bytes[2] == (byte) 0xFE && bytes[3] == (byte) 0xFF) {
+ start = 4;
+ cs = Charset.forName("UTF-32BE");
+ }
+
+ return new String(bytes, start, bytes.length - start, cs).toCharArray();
+ }
+
+ private static char[] readFully(final File file) throws IOException {
+ final byte[] buf = Files.readAllBytes(file.toPath());
+ return byteToCharArray(buf);
+ }
+}
--- a/nashorn/test/src/jdk/nashorn/internal/codegen/CompilerTest.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,208 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.codegen;
-
-import static jdk.nashorn.internal.runtime.Source.readFully;
-import static jdk.nashorn.internal.runtime.Source.sourceFor;
-import java.io.File;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import jdk.nashorn.internal.objects.Global;
-import jdk.nashorn.internal.runtime.Context;
-import jdk.nashorn.internal.runtime.ErrorManager;
-import jdk.nashorn.internal.runtime.ScriptFunction;
-import jdk.nashorn.internal.runtime.Source;
-import jdk.nashorn.internal.runtime.options.Options;
-import org.testng.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- * Tests to check Nashorn JS compiler - just compiler and not execution of scripts.
- */
-@SuppressWarnings("javadoc")
-public class CompilerTest {
- private static final boolean VERBOSE = Boolean.valueOf(System.getProperty("compilertest.verbose"));
- private static final boolean TEST262 = Boolean.valueOf(System.getProperty("compilertest.test262"));
- private static final String TEST_BASIC_DIR = System.getProperty("test.basic.dir");
- private static final String TEST_NODE_DIR = System.getProperty("test.node.dir");
- private static final String TEST262_SUITE_DIR = System.getProperty("test262.suite.dir");
-
- interface TestFilter {
- public boolean exclude(File file, String content);
- }
-
- private static void log(final String msg) {
- org.testng.Reporter.log(msg, true);
- }
-
- private Context context;
- private Global global;
-
- @BeforeClass
- public void setupTest() {
- final Options options = new Options("nashorn");
- options.set("compile.only", true);
- options.set("print.ast", true);
- options.set("print.parse", true);
- options.set("scripting", true);
- options.set("const.as.var", true);
- options.set("verify.code", true);
-
- final ErrorManager errors = new ErrorManager() {
- @Override
- public void error(final String msg) {
- log(msg);
- }
- };
-
- final StringWriter sw = new StringWriter();
- final PrintWriter pw = new PrintWriter(sw);
- this.context = new Context(options, errors, pw, pw, Thread.currentThread().getContextClassLoader());
- this.global = context.createGlobal();
- }
-
- @AfterClass
- public void tearDownTest() {
- this.context = null;
- this.global = null;
- }
-
- @Test
- public void compileAllTests() {
- if (TEST262) {
- compileTestSet(new File(TEST262_SUITE_DIR), new TestFilter() {
- @Override
- public boolean exclude(final File file, final String content) {
- return content != null && content.contains("@negative");
- }
- });
- }
- compileTestSet(new File(TEST_BASIC_DIR), new TestFilter() {
- @Override
- public boolean exclude(final File file, final String content) {
- return file.getName().equals("es6");
- }
- });
- compileTestSet(new File(TEST_NODE_DIR, "node"), null);
- compileTestSet(new File(TEST_NODE_DIR, "src"), null);
- }
-
- private void compileTestSet(final File testSetDir, final TestFilter filter) {
- passed = 0;
- failed = 0;
- skipped = 0;
- if (! testSetDir.isDirectory()) {
- log("WARNING: " + testSetDir + " not found or not a directory");
- return;
- }
- log(testSetDir.getAbsolutePath());
- compileJSDirectory(testSetDir, filter);
-
- log(testSetDir + " compile done!");
- log("compile ok: " + passed);
- log("compile failed: " + failed);
- log("compile skipped: " + skipped);
- if (failed != 0) {
- Assert.fail(failed + " tests failed to compile in " + testSetDir.getAbsolutePath());
- }
- }
-
- // number of scripts that compiled fine
- private int passed;
- // number of scripts resulting in compile failure
- private int failed;
- // scripts that were skipped - all tests with @negative are
- // skipped for now.
- private int skipped;
-
- private void compileJSDirectory(final File dir, final TestFilter filter) {
- if (filter != null && filter.exclude(dir, null)) {
- return;
- }
- for (final File f : dir.listFiles()) {
- if (f.isDirectory()) {
- compileJSDirectory(f, filter);
- } else if (f.getName().endsWith(".js")) {
- compileJSFile(f, filter);
- }
- }
- }
-
- private void compileJSFile(final File file, final TestFilter filter) {
- if (VERBOSE) {
- log("Begin compiling " + file.getAbsolutePath());
- }
-
- final Global oldGlobal = Context.getGlobal();
- final boolean globalChanged = (oldGlobal != global);
-
- try {
- final char[] buffer = readFully(file);
- boolean excluded = false;
-
- if (filter != null) {
- final String content = new String(buffer);
- excluded = filter.exclude(file, content);
- }
-
- if (excluded) {
- if (VERBOSE) {
- log("Skipping " + file.getAbsolutePath());
- }
- skipped++;
- return;
- }
-
- if (globalChanged) {
- Context.setGlobal(global);
- }
- final Source source = sourceFor(file.getAbsolutePath(), buffer);
- final ScriptFunction script = context.compileScript(source, global);
- if (script == null || context.getErrorManager().getNumberOfErrors() > 0) {
- log("Compile failed: " + file.getAbsolutePath());
- failed++;
- } else {
- passed++;
- }
- } catch (final Throwable t) {
- log("Compile failed: " + file.getAbsolutePath() + " : " + t);
- if (VERBOSE) {
- t.printStackTrace(System.out);
- }
- failed++;
- } finally {
- if (globalChanged) {
- Context.setGlobal(oldGlobal);
- }
- }
-
- if (VERBOSE) {
- log("Done compiling " + file.getAbsolutePath());
- }
- }
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/internal/codegen/test/CompilerTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,208 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.codegen.test;
+
+import static jdk.nashorn.internal.runtime.Source.readFully;
+import static jdk.nashorn.internal.runtime.Source.sourceFor;
+import java.io.File;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import jdk.nashorn.internal.objects.Global;
+import jdk.nashorn.internal.runtime.Context;
+import jdk.nashorn.internal.runtime.ErrorManager;
+import jdk.nashorn.internal.runtime.ScriptFunction;
+import jdk.nashorn.internal.runtime.Source;
+import jdk.nashorn.internal.runtime.options.Options;
+import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * Tests to check Nashorn JS compiler - just compiler and not execution of scripts.
+ */
+@SuppressWarnings("javadoc")
+public class CompilerTest {
+ private static final boolean VERBOSE = Boolean.valueOf(System.getProperty("compilertest.verbose"));
+ private static final boolean TEST262 = Boolean.valueOf(System.getProperty("compilertest.test262"));
+ private static final String TEST_BASIC_DIR = System.getProperty("test.basic.dir");
+ private static final String TEST_NODE_DIR = System.getProperty("test.node.dir");
+ private static final String TEST262_SUITE_DIR = System.getProperty("test262.suite.dir");
+
+ interface TestFilter {
+ public boolean exclude(File file, String content);
+ }
+
+ private static void log(final String msg) {
+ org.testng.Reporter.log(msg, true);
+ }
+
+ private Context context;
+ private Global global;
+
+ @BeforeClass
+ public void setupTest() {
+ final Options options = new Options("nashorn");
+ options.set("compile.only", true);
+ options.set("print.ast", true);
+ options.set("print.parse", true);
+ options.set("scripting", true);
+ options.set("const.as.var", true);
+ options.set("verify.code", true);
+
+ final ErrorManager errors = new ErrorManager() {
+ @Override
+ public void error(final String msg) {
+ log(msg);
+ }
+ };
+
+ final StringWriter sw = new StringWriter();
+ final PrintWriter pw = new PrintWriter(sw);
+ this.context = new Context(options, errors, pw, pw, Thread.currentThread().getContextClassLoader());
+ this.global = context.createGlobal();
+ }
+
+ @AfterClass
+ public void tearDownTest() {
+ this.context = null;
+ this.global = null;
+ }
+
+ @Test
+ public void compileAllTests() {
+ if (TEST262) {
+ compileTestSet(new File(TEST262_SUITE_DIR), new TestFilter() {
+ @Override
+ public boolean exclude(final File file, final String content) {
+ return content != null && content.contains("@negative");
+ }
+ });
+ }
+ compileTestSet(new File(TEST_BASIC_DIR), new TestFilter() {
+ @Override
+ public boolean exclude(final File file, final String content) {
+ return file.getName().equals("es6");
+ }
+ });
+ compileTestSet(new File(TEST_NODE_DIR, "node"), null);
+ compileTestSet(new File(TEST_NODE_DIR, "src"), null);
+ }
+
+ private void compileTestSet(final File testSetDir, final TestFilter filter) {
+ passed = 0;
+ failed = 0;
+ skipped = 0;
+ if (! testSetDir.isDirectory()) {
+ log("WARNING: " + testSetDir + " not found or not a directory");
+ return;
+ }
+ log(testSetDir.getAbsolutePath());
+ compileJSDirectory(testSetDir, filter);
+
+ log(testSetDir + " compile done!");
+ log("compile ok: " + passed);
+ log("compile failed: " + failed);
+ log("compile skipped: " + skipped);
+ if (failed != 0) {
+ Assert.fail(failed + " tests failed to compile in " + testSetDir.getAbsolutePath());
+ }
+ }
+
+ // number of scripts that compiled fine
+ private int passed;
+ // number of scripts resulting in compile failure
+ private int failed;
+ // scripts that were skipped - all tests with @negative are
+ // skipped for now.
+ private int skipped;
+
+ private void compileJSDirectory(final File dir, final TestFilter filter) {
+ if (filter != null && filter.exclude(dir, null)) {
+ return;
+ }
+ for (final File f : dir.listFiles()) {
+ if (f.isDirectory()) {
+ compileJSDirectory(f, filter);
+ } else if (f.getName().endsWith(".js")) {
+ compileJSFile(f, filter);
+ }
+ }
+ }
+
+ private void compileJSFile(final File file, final TestFilter filter) {
+ if (VERBOSE) {
+ log("Begin compiling " + file.getAbsolutePath());
+ }
+
+ final Global oldGlobal = Context.getGlobal();
+ final boolean globalChanged = (oldGlobal != global);
+
+ try {
+ final char[] buffer = readFully(file);
+ boolean excluded = false;
+
+ if (filter != null) {
+ final String content = new String(buffer);
+ excluded = filter.exclude(file, content);
+ }
+
+ if (excluded) {
+ if (VERBOSE) {
+ log("Skipping " + file.getAbsolutePath());
+ }
+ skipped++;
+ return;
+ }
+
+ if (globalChanged) {
+ Context.setGlobal(global);
+ }
+ final Source source = sourceFor(file.getAbsolutePath(), buffer);
+ final ScriptFunction script = context.compileScript(source, global);
+ if (script == null || context.getErrorManager().getNumberOfErrors() > 0) {
+ log("Compile failed: " + file.getAbsolutePath());
+ failed++;
+ } else {
+ passed++;
+ }
+ } catch (final Throwable t) {
+ log("Compile failed: " + file.getAbsolutePath() + " : " + t);
+ if (VERBOSE) {
+ t.printStackTrace(System.out);
+ }
+ failed++;
+ } finally {
+ if (globalChanged) {
+ Context.setGlobal(oldGlobal);
+ }
+ }
+
+ if (VERBOSE) {
+ log("Done compiling " + file.getAbsolutePath());
+ }
+ }
+}
--- a/nashorn/test/src/jdk/nashorn/internal/parser/ParserTest.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,188 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.parser;
-
-import static jdk.nashorn.internal.runtime.Source.readFully;
-import static jdk.nashorn.internal.runtime.Source.sourceFor;
-import java.io.File;
-import jdk.nashorn.internal.runtime.Context;
-import jdk.nashorn.internal.runtime.ErrorManager;
-import jdk.nashorn.internal.runtime.Source;
-import jdk.nashorn.internal.runtime.options.Options;
-import org.testng.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- * Run tests to check Nashorn's parser.
- */
-@SuppressWarnings("javadoc")
-public class ParserTest {
- private static final boolean VERBOSE = Boolean.valueOf(System.getProperty("parsertest.verbose"));
- private static final boolean TEST262 = Boolean.valueOf(System.getProperty("parsertest.test262"));
-
- private static final String TEST_BASIC_DIR = System.getProperty("test.basic.dir");
- private static final String TEST262_SUITE_DIR = System.getProperty("test262.suite.dir");
-
-
- interface TestFilter {
- public boolean exclude(File file, String content);
- }
-
- private static void log(final String msg) {
- org.testng.Reporter.log(msg, true);
- }
-
- private Context context;
-
- @BeforeClass
- public void setupTest() {
- final Options options = new Options("nashorn");
- options.set("parse.only", true);
- options.set("scripting", true);
- options.set("const.as.var", true);
-
- final ErrorManager errors = new ErrorManager();
- this.context = new Context(options, errors, Thread.currentThread().getContextClassLoader());
- }
-
- @AfterClass
- public void tearDownTest() {
- this.context = null;
- }
-
- @Test
- public void parseAllTests() {
- if (TEST262) {
- parseTestSet(TEST262_SUITE_DIR, new TestFilter() {
- @Override
- public boolean exclude(final File file, final String content) {
- return content != null && content.contains("@negative");
- }
- });
- }
- parseTestSet(TEST_BASIC_DIR, new TestFilter() {
- @Override
- public boolean exclude(final File file, final String content) {
- return file.getName().equals("es6");
- }
- });
- }
-
- private void parseTestSet(final String testSet, final TestFilter filter) {
- passed = 0;
- failed = 0;
- skipped = 0;
-
- final File testSetDir = new File(testSet);
- if (! testSetDir.isDirectory()) {
- log("WARNING: " + testSetDir + " not found or not a directory");
- return;
- }
- log(testSetDir.getAbsolutePath());
- parseJSDirectory(testSetDir, filter);
-
- log(testSet + " parse done!");
- log("parse ok: " + passed);
- log("parse failed: " + failed);
- log("parse skipped: " + skipped);
- if (failed != 0) {
- Assert.fail(failed + " tests failed to compile in " + testSetDir.getAbsolutePath());
- }
- }
-
- // number of scripts that parsed fine
- private int passed;
- // number of scripts resulting in parse failure
- private int failed;
- // scripts that were skipped - all tests with @negative are
- // skipped for now.
- private int skipped;
-
- private void parseJSDirectory(final File dir, final TestFilter filter) {
- if (filter != null && filter.exclude(dir, null)) {
- return;
- }
- for (final File f : dir.listFiles()) {
- if (f.isDirectory()) {
- parseJSDirectory(f, filter);
- } else if (f.getName().endsWith(".js")) {
- parseJSFile(f, filter);
- }
- }
- }
-
- private void parseJSFile(final File file, final TestFilter filter) {
- if (VERBOSE) {
- log("Begin parsing " + file.getAbsolutePath());
- }
-
- try {
- final char[] buffer = readFully(file);
- boolean excluded = false;
- if (filter != null) {
- final String content = new String(buffer);
- excluded = filter.exclude(file, content);
- }
-
- if (excluded) {
- if (VERBOSE) {
- log("Skipping " + file.getAbsolutePath());
- }
- skipped++;
- return;
- }
-
- final ErrorManager errors = new ErrorManager() {
- @Override
- public void error(final String msg) {
- log(msg);
- }
- };
- errors.setLimit(0);
- final Source source = sourceFor(file.getAbsolutePath(), buffer);
- new Parser(context.getEnv(), source, errors, context.getEnv()._strict, null).parse();
- if (errors.getNumberOfErrors() > 0) {
- log("Parse failed: " + file.getAbsolutePath());
- failed++;
- } else {
- passed++;
- }
- } catch (final Throwable exp) {
- exp.printStackTrace();
- log("Parse failed: " + file.getAbsolutePath() + " : " + exp);
- if (VERBOSE) {
- exp.printStackTrace(System.out);
- }
- failed++;
- }
-
- if (VERBOSE) {
- log("Done parsing " + file.getAbsolutePath());
- }
- }
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/internal/parser/test/ParserTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,189 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.parser.test;
+
+import static jdk.nashorn.internal.runtime.Source.readFully;
+import static jdk.nashorn.internal.runtime.Source.sourceFor;
+import java.io.File;
+import jdk.nashorn.internal.parser.Parser;
+import jdk.nashorn.internal.runtime.Context;
+import jdk.nashorn.internal.runtime.ErrorManager;
+import jdk.nashorn.internal.runtime.Source;
+import jdk.nashorn.internal.runtime.options.Options;
+import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * Run tests to check Nashorn's parser.
+ */
+@SuppressWarnings("javadoc")
+public class ParserTest {
+ private static final boolean VERBOSE = Boolean.valueOf(System.getProperty("parsertest.verbose"));
+ private static final boolean TEST262 = Boolean.valueOf(System.getProperty("parsertest.test262"));
+
+ private static final String TEST_BASIC_DIR = System.getProperty("test.basic.dir");
+ private static final String TEST262_SUITE_DIR = System.getProperty("test262.suite.dir");
+
+
+ interface TestFilter {
+ public boolean exclude(File file, String content);
+ }
+
+ private static void log(final String msg) {
+ org.testng.Reporter.log(msg, true);
+ }
+
+ private Context context;
+
+ @BeforeClass
+ public void setupTest() {
+ final Options options = new Options("nashorn");
+ options.set("parse.only", true);
+ options.set("scripting", true);
+ options.set("const.as.var", true);
+
+ final ErrorManager errors = new ErrorManager();
+ this.context = new Context(options, errors, Thread.currentThread().getContextClassLoader());
+ }
+
+ @AfterClass
+ public void tearDownTest() {
+ this.context = null;
+ }
+
+ @Test
+ public void parseAllTests() {
+ if (TEST262) {
+ parseTestSet(TEST262_SUITE_DIR, new TestFilter() {
+ @Override
+ public boolean exclude(final File file, final String content) {
+ return content != null && content.contains("@negative");
+ }
+ });
+ }
+ parseTestSet(TEST_BASIC_DIR, new TestFilter() {
+ @Override
+ public boolean exclude(final File file, final String content) {
+ return file.getName().equals("es6");
+ }
+ });
+ }
+
+ private void parseTestSet(final String testSet, final TestFilter filter) {
+ passed = 0;
+ failed = 0;
+ skipped = 0;
+
+ final File testSetDir = new File(testSet);
+ if (! testSetDir.isDirectory()) {
+ log("WARNING: " + testSetDir + " not found or not a directory");
+ return;
+ }
+ log(testSetDir.getAbsolutePath());
+ parseJSDirectory(testSetDir, filter);
+
+ log(testSet + " parse done!");
+ log("parse ok: " + passed);
+ log("parse failed: " + failed);
+ log("parse skipped: " + skipped);
+ if (failed != 0) {
+ Assert.fail(failed + " tests failed to compile in " + testSetDir.getAbsolutePath());
+ }
+ }
+
+ // number of scripts that parsed fine
+ private int passed;
+ // number of scripts resulting in parse failure
+ private int failed;
+ // scripts that were skipped - all tests with @negative are
+ // skipped for now.
+ private int skipped;
+
+ private void parseJSDirectory(final File dir, final TestFilter filter) {
+ if (filter != null && filter.exclude(dir, null)) {
+ return;
+ }
+ for (final File f : dir.listFiles()) {
+ if (f.isDirectory()) {
+ parseJSDirectory(f, filter);
+ } else if (f.getName().endsWith(".js")) {
+ parseJSFile(f, filter);
+ }
+ }
+ }
+
+ private void parseJSFile(final File file, final TestFilter filter) {
+ if (VERBOSE) {
+ log("Begin parsing " + file.getAbsolutePath());
+ }
+
+ try {
+ final char[] buffer = readFully(file);
+ boolean excluded = false;
+ if (filter != null) {
+ final String content = new String(buffer);
+ excluded = filter.exclude(file, content);
+ }
+
+ if (excluded) {
+ if (VERBOSE) {
+ log("Skipping " + file.getAbsolutePath());
+ }
+ skipped++;
+ return;
+ }
+
+ final ErrorManager errors = new ErrorManager() {
+ @Override
+ public void error(final String msg) {
+ log(msg);
+ }
+ };
+ errors.setLimit(0);
+ final Source source = sourceFor(file.getAbsolutePath(), buffer);
+ new Parser(context.getEnv(), source, errors, context.getEnv()._strict, null).parse();
+ if (errors.getNumberOfErrors() > 0) {
+ log("Parse failed: " + file.getAbsolutePath());
+ failed++;
+ } else {
+ passed++;
+ }
+ } catch (final Throwable exp) {
+ exp.printStackTrace();
+ log("Parse failed: " + file.getAbsolutePath() + " : " + exp);
+ if (VERBOSE) {
+ exp.printStackTrace(System.out);
+ }
+ failed++;
+ }
+
+ if (VERBOSE) {
+ log("Done parsing " + file.getAbsolutePath());
+ }
+ }
+}
--- a/nashorn/test/src/jdk/nashorn/internal/runtime/ClassFilterTest.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,185 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.runtime;
-
-import static org.testng.Assert.fail;
-import java.io.File;
-import javax.script.ScriptEngine;
-import javax.script.ScriptException;
-import jdk.nashorn.api.scripting.ClassFilter;
-import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
-import jdk.nashorn.api.scripting.URLReader;
-import jdk.nashorn.internal.test.framework.TestFinder;
-import org.testng.annotations.Test;
-
-@SuppressWarnings("javadoc")
-public class ClassFilterTest {
- private static final String NASHORN_CODE_CACHE = "nashorn.persistent.code.cache";
- private static final String CLASSFILTER_CODE_CACHE = "build/classfilter_nashorn_code_cache";
-
- // @Test
- // This test takes too much time for basic "ant clean test" run.
- // Given that "allow-all-java-classes" is equivalent to no java class
- // filter and external tests don't access any java, not sure if this
- // test contributes much. We need faster "ant clean test" cycle for
- // developers.
- public void runExternalJsTest() {
- final String[] paths = new String[]{
- "test/script/basic/compile-octane.js",
- "test/script/basic/jquery.js",
- "test/script/basic/prototype.js",
- "test/script/basic/runsunspider.js",
- "test/script/basic/underscore.js",
- "test/script/basic/yui.js",
- "test/script/basic/run-octane.js"
- };
- final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
- for (final String path : paths) {
- final ScriptEngine engine = factory.getScriptEngine(new String[]{"-scripting"}, getClass().getClassLoader(), getClassFilter());
- try {
- engine.eval(new URLReader(new File(path).toURI().toURL()));
- } catch (final Exception e) {
- fail("Script " + path + " fails with exception :" + e.getMessage());
- }
- }
- }
-
- @Test
- public void noJavaOptionTest() {
- final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
- final ScriptEngine engine = factory.getScriptEngine(new String[]{"--no-java"}, getClass().getClassLoader(), getClassFilter());
- try {
- engine.eval("var str = Java.type('java.lang.String');");
- fail("TypeError should have been thrown");
- } catch (final ScriptException e) {
- //emtpy
- }
- }
-
- @Test
- public void securityTest() {
- if (System.getSecurityManager() == null) {
- return;
- }
-
- final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
- final ScriptEngine engine = factory.getScriptEngine(getClassFilter());
- try {
- engine.eval("var thread = Java.type('sun.misc.Unsafe')");
- fail("SecurityException should have been thrown");
- } catch (final Exception e) {
- //empty
- }
- try {
- engine.eval("var thread = new sun.misc.Unsafe()");
- fail("SecurityException should have been thrown");
- } catch (final Exception e) {
- //empty
- }
- try {
- engine.eval("var thread = Java.extend(sun.misc.Unsafe, {})");
- fail("TypeError should have been thrown");
- } catch (final Exception e) {
- //empty
- }
- try {
- engine.eval("java.lang.System.exit(0)");
- fail("SecurityException should have been thrown");
- } catch (final Exception e) {
- //empty
- }
-
- }
-
- @Test
- public void persistentCacheTest() {
- final String oldCodeCache = System.getProperty(NASHORN_CODE_CACHE);
- System.setProperty(NASHORN_CODE_CACHE, CLASSFILTER_CODE_CACHE);
- try {
- persistentCacheTestImpl();
- } finally {
- if (oldCodeCache != null) {
- System.setProperty(NASHORN_CODE_CACHE, oldCodeCache);
- }
- }
- }
-
- private void persistentCacheTestImpl() {
- final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
- final ScriptEngine engine = factory.getScriptEngine(
- TestFinder.addExplicitOptimisticTypes(new String[]{"--persistent-code-cache", "--optimistic-types=true"}),
- getClass().getClassLoader(),
- getClassFilter()
- );
- final String testScript = "var a = Java.type('java.lang.String');" + generateCodeForPersistentStore();
- try {
- engine.eval(testScript);
- } catch (final ScriptException exc) {
- fail(exc.getMessage());
- }
- final ScriptEngine engineSafe = factory.getScriptEngine(
- TestFinder.addExplicitOptimisticTypes(new String[]{"--persistent-code-cache", "--optimistic-types=true"}),
- getClass().getClassLoader(),
- new ClassFilter() {
- @Override
- public boolean exposeToScripts(final String s) {
- return false;
- }
- }
- );
- try {
- engineSafe.eval(testScript);
- fail("ClassNotFoundException should have been thrown");
- } catch (final Exception exc) {
- if (!(exc.getCause() instanceof ClassNotFoundException)) {
- fail("ClassNotFoundException expected, got " + exc.getClass());
- }
- }
- }
-
- private static String generateCodeForPersistentStore() {
- final StringBuilder stringBuilder = new StringBuilder();
- for (int i=0; i < 100; i++) {
- stringBuilder.append("function i")
- .append(i)
- .append("(y, z) { var x")
- .append(i)
- .append(" = ")
- .append(i)
- .append(";}");
- }
- return stringBuilder.toString();
- }
-
- private static ClassFilter getClassFilter() {
- return new ClassFilter() {
- @Override
- public boolean exposeToScripts(final String s) {
- return true;
- }
- };
- }
-}
--- a/nashorn/test/src/jdk/nashorn/internal/runtime/CodeStoreAndPathTest.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,188 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package jdk.nashorn.internal.runtime;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.DirectoryStream;
-import java.nio.file.FileSystems;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import javax.script.ScriptEngine;
-import javax.script.ScriptException;
-import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
-import org.testng.annotations.Test;
-
-/**
- * @test
- * @bug 8039185 8039403
- * @summary Test for persistent code cache and path handling
- * @run testng jdk.nashorn.internal.runtime.CodeStoreAndPathTest
- */
-@SuppressWarnings("javadoc")
-public class CodeStoreAndPathTest {
-
- final String code1 = "var code1; var x = 'Hello Script'; var x1 = 'Hello Script'; "
- + "var x2 = 'Hello Script'; var x3 = 'Hello Script'; "
- + "var x4 = 'Hello Script'; var x5 = 'Hello Script';"
- + "var x6 = 'Hello Script'; var x7 = 'Hello Script'; "
- + "var x8 = 'Hello Script'; var x9 = 'Hello Script'; "
- + "var x10 = 'Hello Script';"
- + "function f() {x ='Bye Script'; x1 ='Bye Script'; x2='Bye Script';"
- + "x3='Bye Script'; x4='Bye Script'; x5='Bye Script'; x6='Bye Script';"
- + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; "
- + "var x10 = 'Hello Script';}"
- + "function g() {x ='Bye Script'; x1 ='Bye Script'; x2='Bye Script';"
- + "x3='Bye Script'; x4='Bye Script'; x5='Bye Script'; x6='Bye Script';"
- + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; "
- + "var x10 = 'Hello Script';}"
- + "function h() {x ='Bye Script'; x1 ='Bye Script'; x2='Bye Script';"
- + "x3='Bye Script'; x4='Bye Script'; x5='Bye Script'; x6='Bye Script';"
- + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; "
- + "var x10 = 'Hello Script';}"
- + "function i() {x ='Bye Script'; x1 ='Bye Script'; x2='Bye Script';"
- + "x3='Bye Script'; x4='Bye Script'; x5='Bye Script'; x6='Bye Script';"
- + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; "
- + "var x10 = 'Hello Script';}";
- final String code2 = "var code2; var x = 'Hello Script'; var x1 = 'Hello Script'; "
- + "var x2 = 'Hello Script'; var x3 = 'Hello Script'; "
- + "var x4 = 'Hello Script'; var x5 = 'Hello Script';"
- + "var x6 = 'Hello Script'; var x7 = 'Hello Script'; "
- + "var x8 = 'Hello Script'; var x9 = 'Hello Script'; "
- + "var x10 = 'Hello Script';"
- + "function f() {x ='Bye Script'; x1 ='Bye Script'; x2='Bye Script';"
- + "x3='Bye Script'; x4='Bye Script'; x5='Bye Script'; x6='Bye Script';"
- + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; "
- + "var x10 = 'Hello Script';}"
- + "function g() {x ='Bye Script'; x1 ='Bye Script'; x2='Bye Script';"
- + "x3='Bye Script'; x4='Bye Script'; x5='Bye Script'; x6='Bye Script';"
- + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; "
- + "var x10 = 'Hello Script';}"
- + "function h() {x ='Bye Script'; x1 ='Bye Script'; x2='Bye Script';"
- + "x3='Bye Script'; x4='Bye Script'; x5='Bye Script'; x6='Bye Script';"
- + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; "
- + "var x10 = 'Hello Script';}"
- + "function i() {x ='Bye Script'; x1 ='Bye Script'; x2='Bye Script';"
- + "x3='Bye Script'; x4='Bye Script'; x5='Bye Script'; x6='Bye Script';"
- + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; "
- + "var x10 = 'Hello Script';}";
- // Script size < Default minimum size for storing a compiled script class
- final String code3 = "var code3; var x = 'Hello Script'; var x1 = 'Hello Script'; ";
- final String codeCache = "build/nashorn_code_cache";
- final String oldUserDir = System.getProperty("user.dir");
-
- private static final String[] ENGINE_OPTIONS_OPT = new String[]{"--persistent-code-cache", "--optimistic-types=true"};
- private static final String[] ENGINE_OPTIONS_NOOPT = new String[]{"--persistent-code-cache", "--optimistic-types=false"};
-
- @Test
- public void pathHandlingTest() {
- System.setProperty("nashorn.persistent.code.cache", codeCache);
- final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
-
- fac.getScriptEngine(ENGINE_OPTIONS_NOOPT);
-
- final Path expectedCodeCachePath = FileSystems.getDefault().getPath(oldUserDir + File.separator + codeCache);
- final Path actualCodeCachePath = FileSystems.getDefault().getPath(System.getProperty(
- "nashorn.persistent.code.cache")).toAbsolutePath();
- // Check that nashorn code cache is created in current working directory
- assertEquals(actualCodeCachePath, expectedCodeCachePath);
- // Check that code cache dir exists and it's not empty
- final File file = new File(actualCodeCachePath.toUri());
- assertFalse(!file.isDirectory(), "No code cache directory was created!");
- assertFalse(file.list().length == 0, "Code cache directory is empty!");
- }
-
- @Test
- public void changeUserDirTest() throws ScriptException, IOException {
- System.setProperty("nashorn.persistent.code.cache", codeCache);
- final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
- final ScriptEngine e = fac.getScriptEngine(ENGINE_OPTIONS_NOOPT);
- final Path codeCachePath = getCodeCachePath(false);
- final String newUserDir = "build/newUserDir";
- // Now changing current working directory
- System.setProperty("user.dir", System.getProperty("user.dir") + File.separator + newUserDir);
- try {
- // Check that a new compiled script is stored in existing code cache
- e.eval(code1);
- final DirectoryStream<Path> stream = Files.newDirectoryStream(codeCachePath);
- checkCompiledScripts(stream, 1);
- // Setting to default current working dir
- } finally {
- System.setProperty("user.dir", oldUserDir);
- }
- }
-
- @Test
- public void codeCacheTest() throws ScriptException, IOException {
- System.setProperty("nashorn.persistent.code.cache", codeCache);
- final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
- final ScriptEngine e = fac.getScriptEngine(ENGINE_OPTIONS_NOOPT);
- final Path codeCachePath = getCodeCachePath(false);
- e.eval(code1);
- e.eval(code2);
- e.eval(code3);// less than minimum size for storing
- // adding code1 and code2.
- final DirectoryStream<Path> stream = Files.newDirectoryStream(codeCachePath);
- checkCompiledScripts(stream, 2);
- }
-
- @Test
- public void codeCacheTestOpt() throws ScriptException, IOException {
- System.setProperty("nashorn.persistent.code.cache", codeCache);
- final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
- final ScriptEngine e = fac.getScriptEngine(ENGINE_OPTIONS_OPT);
- final Path codeCachePath = getCodeCachePath(true);
- e.eval(code1);
- e.eval(code2);
- e.eval(code3);// less than minimum size for storing
- // adding code1 and code2.
- final DirectoryStream<Path> stream = Files.newDirectoryStream(codeCachePath);
- checkCompiledScripts(stream, 2);
- }
-
- private static Path getCodeCachePath(final boolean optimistic) {
- final String codeCache = System.getProperty("nashorn.persistent.code.cache");
- final Path codeCachePath = FileSystems.getDefault().getPath(codeCache).toAbsolutePath();
- final String[] files = codeCachePath.toFile().list();
- for (final String file : files) {
- if (file.endsWith("_opt") == optimistic) {
- return codeCachePath.resolve(file);
- }
- }
- throw new AssertionError("Code cache path not found");
- }
-
- private static void checkCompiledScripts(final DirectoryStream<Path> stream, final int numberOfScripts) throws IOException {
- int n = numberOfScripts;
- for (@SuppressWarnings("unused") final Path file : stream) {
- n--;
- }
- stream.close();
- assertEquals(n, 0);
- }
-
-}
--- a/nashorn/test/src/jdk/nashorn/internal/runtime/ConsStringTest.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,131 +0,0 @@
-/*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.runtime;
-
-import static org.testng.Assert.assertEquals;
-
-import org.testng.annotations.Test;
-
-/**
- * Tests for JSType methods.
- *
- * @test
- * @run testng jdk.nashorn.internal.runtime.ConsStringTest
- */
-public class ConsStringTest {
-
- /**
- * Test toString conversion
- */
- @Test
- public void testConsStringToString() {
- final ConsString cs1 = new ConsString("b", "c");
- final ConsString cs2 = new ConsString("d", "e");
- final ConsString cs3 = new ConsString(cs1, cs2);
- final ConsString cs4 = new ConsString(cs3, "f");
- final ConsString cs5 = new ConsString("a", cs4);
- assertEquals(cs5.toString(), "abcdef");
- assertEquals(cs4.toString(), "bcdef");
- assertEquals(cs3.toString(), "bcde");
- assertEquals(cs2.toString(), "de");
- assertEquals(cs1.toString(), "bc");
- // ConsStrings should be flattened now
- assertEquals(cs1.getComponents()[0], "bc");
- assertEquals(cs1.getComponents()[1], "");
- assertEquals(cs2.getComponents()[0], "de");
- assertEquals(cs2.getComponents()[1], "");
- assertEquals(cs3.getComponents()[0], "bcde");
- assertEquals(cs3.getComponents()[1], "");
- assertEquals(cs4.getComponents()[0], "bcdef");
- assertEquals(cs4.getComponents()[1], "");
- assertEquals(cs5.getComponents()[0], "abcdef");
- assertEquals(cs5.getComponents()[1], "");
- }
-
- /**
- * Test charAt
- */
- @Test
- public void testConsStringCharAt() {
- final ConsString cs1 = new ConsString("b", "c");
- final ConsString cs2 = new ConsString("d", "e");
- final ConsString cs3 = new ConsString(cs1, cs2);
- final ConsString cs4 = new ConsString(cs3, "f");
- final ConsString cs5 = new ConsString("a", cs4);
- assertEquals(cs1.charAt(1), 'c');
- assertEquals(cs2.charAt(0), 'd');
- assertEquals(cs3.charAt(3), 'e');
- assertEquals(cs4.charAt(1), 'c');
- assertEquals(cs5.charAt(2), 'c');
- // ConsStrings should be flattened now
- assertEquals(cs1.getComponents()[0], "bc");
- assertEquals(cs1.getComponents()[1], "");
- assertEquals(cs2.getComponents()[0], "de");
- assertEquals(cs2.getComponents()[1], "");
- assertEquals(cs3.getComponents()[0], "bcde");
- assertEquals(cs3.getComponents()[1], "");
- assertEquals(cs4.getComponents()[0], "bcdef");
- assertEquals(cs4.getComponents()[1], "");
- assertEquals(cs5.getComponents()[0], "abcdef");
- assertEquals(cs5.getComponents()[1], "");
- }
-
-
- /**
- * Test flattening of top-level and internal ConsStrings
- */
- @Test
- public void testConsStringFlattening() {
- final ConsString cs1 = new ConsString("b", "c");
- final ConsString cs2 = new ConsString("d", "e");
- final ConsString cs3 = new ConsString(cs1, cs2);
- final ConsString cs4 = new ConsString(cs3, "f");
-
- final ConsString cs5 = new ConsString("a", cs4);
- // top-level ConsString should not yet be flattened
- assert(cs5.getComponents()[0] == "a");
- assert(cs5.getComponents()[1] == cs4);
- assertEquals(cs5.toString(), "abcdef");
- // top-level ConsString should be flattened
- assertEquals(cs5.getComponents()[0], "abcdef");
- assertEquals(cs5.getComponents()[1], "");
- // internal ConsString should not yet be flattened after first traversal
- assertEquals(cs4.getComponents()[0], cs3);
- assertEquals(cs4.getComponents()[1], "f");
-
- final ConsString cs6 = new ConsString("a", cs4);
- // top-level ConsString should not yet be flattened
- assertEquals(cs6.getComponents()[0], "a");
- assertEquals(cs6.getComponents()[1], cs4);
- assertEquals(cs6.toString(), "abcdef");
- // top-level ConsString should be flattened
- assertEquals(cs6.getComponents()[0], "abcdef");
- assertEquals(cs6.getComponents()[1], "");
- // internal ConsString should have been flattened after second traversal
- assertEquals(cs4.getComponents()[0], "bcdef");
- assertEquals(cs4.getComponents()[1], "");
- }
-}
--- a/nashorn/test/src/jdk/nashorn/internal/runtime/ContextTest.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,138 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.runtime;
-
-import static jdk.nashorn.internal.runtime.Source.sourceFor;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
-import java.util.Map;
-import jdk.nashorn.internal.objects.Global;
-import jdk.nashorn.internal.runtime.options.Options;
-import org.testng.annotations.Test;
-
-/**
- * Basic Context API tests.
- *
- * @test
- * @run testng jdk.nashorn.internal.runtime.ContextTest
- */
-@SuppressWarnings("javadoc")
-public class ContextTest {
- // basic context eval test
- @Test
- public void evalTest() {
- final Options options = new Options("");
- final ErrorManager errors = new ErrorManager();
- final Context cx = new Context(options, errors, Thread.currentThread().getContextClassLoader());
- final Global oldGlobal = Context.getGlobal();
- Context.setGlobal(cx.createGlobal());
- try {
- String code = "22 + 10";
- assertTrue(32.0 == ((Number)(eval(cx, "<evalTest>", code))).doubleValue());
-
- code = "obj = { js: 'nashorn' }; obj.js";
- assertEquals(eval(cx, "<evalTest2>", code), "nashorn");
- } finally {
- Context.setGlobal(oldGlobal);
- }
- }
-
- // Make sure trying to compile an invalid script returns null - see JDK-8046215.
- @Test
- public void compileErrorTest() {
- final Options options = new Options("");
- final ErrorManager errors = new ErrorManager();
- final Context cx = new Context(options, errors, Thread.currentThread().getContextClassLoader());
- final Global oldGlobal = Context.getGlobal();
- Context.setGlobal(cx.createGlobal());
- try {
- final ScriptFunction script = cx.compileScript(sourceFor("<evalCompileErrorTest>", "*/"), Context.getGlobal());
- if (script != null) {
- fail("Invalid script compiled without errors");
- }
- if (errors.getNumberOfErrors() != 1) {
- fail("Wrong number of errors: " + errors.getNumberOfErrors());
- }
- } finally {
- Context.setGlobal(oldGlobal);
- }
- }
-
- // basic check for JS reflection access - java.util.Map-like access on ScriptObject
- @Test
- public void reflectionTest() {
- final Options options = new Options("");
- final ErrorManager errors = new ErrorManager();
- final Context cx = new Context(options, errors, Thread.currentThread().getContextClassLoader());
- final boolean strict = cx.getEnv()._strict;
- final Global oldGlobal = Context.getGlobal();
- Context.setGlobal(cx.createGlobal());
-
- try {
- final String code = "var obj = { x: 344, y: 42 }";
- eval(cx, "<reflectionTest>", code);
-
- final Object obj = Context.getGlobal().get("obj");
-
- assertTrue(obj instanceof ScriptObject);
-
- final ScriptObject sobj = (ScriptObject)obj;
- int count = 0;
- for (final Map.Entry<?, ?> ex : sobj.entrySet()) {
- final Object key = ex.getKey();
- if (key.equals("x")) {
- assertTrue(ex.getValue() instanceof Number);
- assertTrue(344.0 == ((Number)ex.getValue()).doubleValue());
-
- count++;
- } else if (key.equals("y")) {
- assertTrue(ex.getValue() instanceof Number);
- assertTrue(42.0 == ((Number)ex.getValue()).doubleValue());
-
- count++;
- }
- }
- assertEquals(count, 2);
- assertEquals(sobj.size(), 2);
-
- // add property
- sobj.put("zee", "hello", strict);
- assertEquals(sobj.get("zee"), "hello");
- assertEquals(sobj.size(), 3);
-
- } finally {
- Context.setGlobal(oldGlobal);
- }
- }
-
- private static Object eval(final Context cx, final String name, final String code) {
- final Source source = sourceFor(name, code);
- final ScriptObject global = Context.getGlobal();
- final ScriptFunction func = cx.compileScript(source, global);
- return func != null ? ScriptRuntime.apply(func, global) : null;
- }
-}
--- a/nashorn/test/src/jdk/nashorn/internal/runtime/ExceptionsNotSerializable.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.runtime;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.fail;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.NotSerializableException;
-import java.io.ObjectOutputStream;
-import javax.script.ScriptEngine;
-import javax.script.ScriptException;
-import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
-import org.testng.annotations.Test;
-
-/**
- * JDK-8044518: Ensure exceptions related to optimistic recompilation are not serializable
- *
- * @test
- * @run testng jdk.nashorn.internal.runtime.ExceptionsNotSerializable
- */
-@SuppressWarnings("javadoc")
-public class ExceptionsNotSerializable {
- @Test
- public void rewriteExceptionNotSerializable() throws ScriptException {
- // NOTE: we must create a RewriteException in a context of a Nashorn engine, as it uses Global.newIntance()
- // internally.
- final ScriptEngine e = new NashornScriptEngineFactory().getScriptEngine();
- e.put("f", new Runnable() {
- @Override
- public void run() {
- tryToSerialize(RewriteException.create(null, new Object[0], new String[0]));
- }
- });
- e.eval("f()");
- }
-
- @Test
- public void unwarrantedOptimismExceptionNotSerializable() {
- tryToSerialize(new UnwarrantedOptimismException(new Double(1.0), 128));
- }
-
- private static void tryToSerialize(final Object obj) {
- try {
- new ObjectOutputStream(new ByteArrayOutputStream()).writeObject(obj);
- fail();
- } catch (final NotSerializableException e) {
- assertEquals(e.getMessage(), obj.getClass().getName());
- } catch (final IOException e) {
- fail("", e);
- }
-
- }
-}
--- a/nashorn/test/src/jdk/nashorn/internal/runtime/JSTypeTest.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,193 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.runtime;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-
-import org.testng.annotations.Test;
-
-/**
- * Tests for JSType methods.
- *
- * @test
- * @run testng jdk.nashorn.internal.runtime.JSTypeTest
- */
-public class JSTypeTest {
- /**
- * Test of isPrimitive method, of class Runtime.
- */
- @Test
- public void testIsPrimitive() {
- assertTrue(JSType.isPrimitive(null));
- assertTrue(JSType.isPrimitive(ScriptRuntime.UNDEFINED));
- assertTrue(JSType.isPrimitive(Double.NaN));
- assertTrue(JSType.isPrimitive(Double.NEGATIVE_INFINITY));
- assertTrue(JSType.isPrimitive(Double.POSITIVE_INFINITY));
- assertTrue(JSType.isPrimitive(0.0));
- assertTrue(JSType.isPrimitive(3.14));
- assertTrue(JSType.isPrimitive("hello"));
- assertTrue(JSType.isPrimitive(""));
- assertFalse(JSType.isPrimitive(new Object()));
- }
-
- /**
- * Test of toBoolean method, of class Runtime.
- */
- @Test
- public void testToBoolean() {
- assertFalse(JSType.toBoolean(ScriptRuntime.UNDEFINED));
- assertFalse(JSType.toBoolean(null));
- assertFalse(JSType.toBoolean(Boolean.FALSE));
- assertTrue(JSType.toBoolean(Boolean.TRUE));
- assertFalse(JSType.toBoolean(-0.0));
- assertFalse(JSType.toBoolean(0.0));
- assertFalse(JSType.toBoolean(Double.NaN));
- assertTrue(JSType.toBoolean(3.14));
- assertFalse(JSType.toBoolean(""));
- assertTrue(JSType.toBoolean("javascript"));
- assertTrue(JSType.toBoolean(new Object()));
- }
-
- /**
- * Test of toNumber method, of class Runtime.
- */
- @Test
- public void testToNumber_Object() {
- assertTrue(Double.isNaN(JSType.toNumber(ScriptRuntime.UNDEFINED)));
- assertEquals(JSType.toNumber((Object)null), 0.0, 0.0);
- assertEquals(JSType.toNumber(Boolean.TRUE), 1.0, 0.0);
- assertEquals(JSType.toNumber(Boolean.FALSE), 0.0, 0.0);
- assertEquals(JSType.toNumber(3.14), 3.14, 0.0);
- // FIXME: add more assertions for specific String to number cases
- // FIXME: add case for Object type (JSObject with getDefaultValue)
- }
-
- /**
- * Test of toString method, of class Runtime.
- */
- @Test
- public void testToString_Object() {
- assertEquals(JSType.toString(ScriptRuntime.UNDEFINED), "undefined");
- assertEquals(JSType.toString(null), "null");
- assertEquals(JSType.toString(Boolean.TRUE), "true");
- assertEquals(JSType.toString(Boolean.FALSE), "false");
- assertEquals(JSType.toString(""), "");
- assertEquals(JSType.toString("nashorn"), "nashorn");
- assertEquals(JSType.toString(Double.NaN), "NaN");
- assertEquals(JSType.toString(Double.POSITIVE_INFINITY), "Infinity");
- assertEquals(JSType.toString(Double.NEGATIVE_INFINITY), "-Infinity");
- assertEquals(JSType.toString(0.0), "0");
- // FIXME: add more number-to-string test cases
- // FIXME: add case for Object type (JSObject with getDefaultValue)
- }
-
- /**
- * Test of JSType.toUint32(double)
- */
- @Test
- public void testToUint32() {
- assertEquals(JSType.toUint32(+0.0), 0);
- assertEquals(JSType.toUint32(-0.0), 0);
- assertEquals(JSType.toUint32(Double.NaN), 0);
- assertEquals(JSType.toUint32(Double.POSITIVE_INFINITY), 0);
- assertEquals(JSType.toUint32(Double.NEGATIVE_INFINITY), 0);
- assertEquals(JSType.toUint32(9223372036854775807.0d), 0);
- assertEquals(JSType.toUint32(-9223372036854775807.0d), 0);
- assertEquals(JSType.toUint32(1099511627776.0d), 0);
- assertEquals(JSType.toUint32(-1099511627776.0d), 0);
- assertEquals(JSType.toUint32(4294967295.0d), 4294967295l);
- assertEquals(JSType.toUint32(4294967296.0d), 0);
- assertEquals(JSType.toUint32(4294967297.0d), 1);
- assertEquals(JSType.toUint32(-4294967295.0d), 1);
- assertEquals(JSType.toUint32(-4294967296.0d), 0);
- assertEquals(JSType.toUint32(-4294967297.0d), 4294967295l);
- assertEquals(JSType.toUint32(4294967295.6d), 4294967295l);
- assertEquals(JSType.toUint32(4294967296.6d), 0);
- assertEquals(JSType.toUint32(4294967297.6d), 1);
- assertEquals(JSType.toUint32(-4294967295.6d), 1);
- assertEquals(JSType.toUint32(-4294967296.6d), 0);
- assertEquals(JSType.toUint32(-4294967297.6d), 4294967295l);
- }
-
- /**
- * Test of JSType.toInt32(double)
- */
- @Test
- public void testToInt32() {
- assertEquals(JSType.toInt32(+0.0), 0);
- assertEquals(JSType.toInt32(-0.0), 0);
- assertEquals(JSType.toInt32(Double.NaN), 0);
- assertEquals(JSType.toInt32(Double.POSITIVE_INFINITY), 0);
- assertEquals(JSType.toInt32(Double.NEGATIVE_INFINITY), 0);
- assertEquals(JSType.toInt32(9223372036854775807.0d), 0);
- assertEquals(JSType.toInt32(-9223372036854775807.0d), 0);
- assertEquals(JSType.toInt32(1099511627776.0d), 0);
- assertEquals(JSType.toInt32(-1099511627776.0d), 0);
- assertEquals(JSType.toInt32(4294967295.0d), -1);
- assertEquals(JSType.toInt32(4294967296.0d), 0);
- assertEquals(JSType.toInt32(4294967297.0d), 1);
- assertEquals(JSType.toInt32(-4294967295.0d), 1);
- assertEquals(JSType.toInt32(-4294967296.0d), 0);
- assertEquals(JSType.toInt32(-4294967297.d), -1);
- assertEquals(JSType.toInt32(4294967295.6d), -1);
- assertEquals(JSType.toInt32(4294967296.6d), 0);
- assertEquals(JSType.toInt32(4294967297.6d), 1);
- assertEquals(JSType.toInt32(-4294967295.6d), 1);
- assertEquals(JSType.toInt32(-4294967296.6d), 0);
- assertEquals(JSType.toInt32(-4294967297.6d), -1);
- }
-
- /**
- * Test of JSType.toUint16(double)
- */
- @Test
- public void testToUint16() {
- assertEquals(JSType.toUint16(+0.0), 0);
- assertEquals(JSType.toUint16(-0.0), 0);
- assertEquals(JSType.toUint16(Double.NaN), 0);
- assertEquals(JSType.toUint16(Double.POSITIVE_INFINITY), 0);
- assertEquals(JSType.toUint16(Double.NEGATIVE_INFINITY), 0);
- assertEquals(JSType.toUint16(9223372036854775807.0d), 0);
- assertEquals(JSType.toUint16(-9223372036854775807.0d), 0);
- assertEquals(JSType.toUint16(1099511627776.0d), 0);
- assertEquals(JSType.toUint16(-1099511627776.0d), 0);
- assertEquals(JSType.toUint16(4294967295.0d), 65535);
- assertEquals(JSType.toUint16(4294967296.0d), 0);
- assertEquals(JSType.toUint16(4294967297.0d), 1);
- assertEquals(JSType.toUint16(-4294967295.0d), 1);
- assertEquals(JSType.toUint16(-4294967296.0d), 0);
- assertEquals(JSType.toUint16(-4294967297.0d), 65535);
- assertEquals(JSType.toUint16(4294967295.6d), 65535);
- assertEquals(JSType.toUint16(4294967296.6d), 0);
- assertEquals(JSType.toUint16(4294967297.6d), 1);
- assertEquals(JSType.toUint16(-4294967295.6d), 1);
- assertEquals(JSType.toUint16(-4294967296.6d), 0);
- assertEquals(JSType.toUint16(-4294967297.6d), 65535);
- }
-
-}
--- a/nashorn/test/src/jdk/nashorn/internal/runtime/LexicalBindingTest.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,212 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.runtime;
-
-import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
-import org.testng.annotations.Test;
-
-import javax.script.Bindings;
-import javax.script.ScriptContext;
-import javax.script.ScriptEngine;
-import javax.script.ScriptException;
-import javax.script.SimpleScriptContext;
-
-import static org.testng.Assert.assertEquals;
-
-/**
- * Top-level lexical binding tests.
- *
- * @test
- * @run testng jdk.nashorn.internal.runtime.LexicalBindingTest
- */
-@SuppressWarnings("javadoc")
-public class LexicalBindingTest {
-
- final static String LANGUAGE_ES6 = "--language=es6";
- final static int NUMBER_OF_CONTEXTS = 20;
- final static int MEGAMORPHIC_LOOP_COUNT = 20;
-
- /**
- * Test access to global var-declared variables for shared script classes with multiple globals.
- */
- @Test
- public static void megamorphicVarTest() throws ScriptException, InterruptedException {
- final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
- final ScriptEngine e = factory.getScriptEngine();
- final ScriptContext[] contexts = new ScriptContext[NUMBER_OF_CONTEXTS];
- final String sharedScript = "foo";
-
-
- for (int i = 0; i < NUMBER_OF_CONTEXTS; i++) {
- final ScriptContext context = contexts[i] = new SimpleScriptContext();
- final Bindings b = e.createBindings();
- context.setBindings(b, ScriptContext.ENGINE_SCOPE);
- assertEquals(e.eval("var foo = '" + i + "';", context), null);
- }
-
- for (int i = 0; i < NUMBER_OF_CONTEXTS; i++) {
- final ScriptContext context = contexts[i];
- assertEquals(e.eval(sharedScript, context), String.valueOf(i));
- }
- }
-
- /**
- * Test access to global lexically declared variables for shared script classes with multiple globals.
- */
- @Test
- public static void megamorphicMultiGlobalLetTest() throws ScriptException, InterruptedException {
- final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
- final ScriptEngine e = factory.getScriptEngine(LANGUAGE_ES6);
- final ScriptContext[] contexts = new ScriptContext[NUMBER_OF_CONTEXTS];
- final String sharedScript = "foo";
-
-
- for (int i = 0; i < NUMBER_OF_CONTEXTS; i++) {
- final ScriptContext context = contexts[i] = new SimpleScriptContext();
- final Bindings b = e.createBindings();
- context.setBindings(b, ScriptContext.ENGINE_SCOPE);
- assertEquals(e.eval("let foo = '" + i + "';", context), null);
- }
-
- for (int i = 0; i < NUMBER_OF_CONTEXTS; i++) {
- final ScriptContext context = contexts[i];
- assertEquals(e.eval(sharedScript, context), String.valueOf(i));
- }
- }
-
-
- /**
- * Test access to global lexically declared variables for shared script classes with single global.
- */
- @Test
- public static void megamorphicSingleGlobalLetTest() throws ScriptException, InterruptedException {
- final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
- final ScriptEngine e = factory.getScriptEngine(LANGUAGE_ES6);
- final String sharedGetterScript = "foo";
- final String sharedSetterScript = "foo = 1";
-
- for (int i = 0; i < MEGAMORPHIC_LOOP_COUNT; i++) {
- assertEquals(e.eval(sharedSetterScript), 1);
- assertEquals(e.eval(sharedGetterScript), 1);
- assertEquals(e.eval("delete foo; a" + i + " = 1; foo = " + i + ";"), i);
- assertEquals(e.eval(sharedGetterScript), i);
- }
-
- assertEquals(e.eval("let foo = 'foo';"), null);
- assertEquals(e.eval(sharedGetterScript), "foo");
- assertEquals(e.eval(sharedSetterScript), 1);
- assertEquals(e.eval(sharedGetterScript), 1);
- assertEquals(e.eval("this.foo"), MEGAMORPHIC_LOOP_COUNT - 1);
- }
-
- /**
- * Test access to global lexically declared variables for shared script classes with single global.
- */
- @Test
- public static void megamorphicInheritedGlobalLetTest() throws ScriptException, InterruptedException {
- final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
- final ScriptEngine e = factory.getScriptEngine(LANGUAGE_ES6);
- final String sharedGetterScript = "foo";
- final String sharedSetterScript = "foo = 1";
-
- for (int i = 0; i < MEGAMORPHIC_LOOP_COUNT; i++) {
- assertEquals(e.eval(sharedSetterScript), 1);
- assertEquals(e.eval(sharedGetterScript), 1);
- assertEquals(e.eval("delete foo; a" + i + " = 1; Object.prototype.foo = " + i + ";"), i);
- assertEquals(e.eval(sharedGetterScript), i);
- }
-
- assertEquals(e.eval("let foo = 'foo';"), null);
- assertEquals(e.eval(sharedGetterScript), "foo");
- assertEquals(e.eval(sharedSetterScript), 1);
- assertEquals(e.eval(sharedGetterScript), 1);
- assertEquals(e.eval("this.foo"), MEGAMORPHIC_LOOP_COUNT - 1);
- }
-
- /**
- * Test multi-threaded access to global lexically declared variables for shared script classes with multiple globals.
- */
- @Test
- public static void multiThreadedLetTest() throws ScriptException, InterruptedException {
- final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
- final ScriptEngine e = factory.getScriptEngine(LANGUAGE_ES6);
- final Bindings b = e.createBindings();
- final ScriptContext origContext = e.getContext();
- final ScriptContext newCtxt = new SimpleScriptContext();
- newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
- final String sharedScript = "foo";
-
- assertEquals(e.eval("let foo = 'original context';", origContext), null);
- assertEquals(e.eval("let foo = 'new context';", newCtxt), null);
-
- final Thread t1 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
- final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "new context", 1000));
- t1.start();
- t2.start();
- t1.join();
- t2.join();
-
- assertEquals(e.eval("foo = 'newer context';", newCtxt), "newer context");
- final Thread t3 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
- final Thread t4 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "newer context", 1000));
-
- t3.start();
- t4.start();
- t3.join();
- t4.join();
-
- assertEquals(e.eval(sharedScript), "original context");
- assertEquals(e.eval(sharedScript, newCtxt), "newer context");
- }
-
- private static class ScriptRunner implements Runnable {
-
- final ScriptEngine engine;
- final ScriptContext context;
- final String source;
- final Object expected;
- final int iterations;
-
- ScriptRunner(final ScriptEngine engine, final ScriptContext context, final String source, final Object expected, final int iterations) {
- this.engine = engine;
- this.context = context;
- this.source = source;
- this.expected = expected;
- this.iterations = iterations;
- }
-
- @Override
- public void run() {
- try {
- for (int i = 0; i < iterations; i++) {
- assertEquals(engine.eval(source, context), expected);
- }
- } catch (final ScriptException se) {
- throw new RuntimeException(se);
- }
- }
- }
-}
--- a/nashorn/test/src/jdk/nashorn/internal/runtime/NoPersistenceCachingTest.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,140 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package jdk.nashorn.internal.runtime;
-
-import static org.testng.Assert.fail;
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import javax.script.ScriptContext;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineFactory;
-import javax.script.ScriptEngineManager;
-import javax.script.SimpleScriptContext;
-import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
-import org.testng.annotations.AfterTest;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Test;
-
-/**
- * @test
- * @bug 8037378
- * @summary Sanity tests for no persistence caching
- * @run testng/othervm jdk.nashorn.internal.runtime.NoPersistenceCachingTest
- */
-@SuppressWarnings("javadoc")
-public class NoPersistenceCachingTest {
-
- private ScriptEngine engine;
- private ScriptContext context1, context2, context3;
- private ByteArrayOutputStream stderr;
- private PrintStream prevStderr;
-
- @BeforeTest
- public void setupTest() {
- stderr = new ByteArrayOutputStream();
- prevStderr = System.err;
- System.setErr(new PrintStream(stderr));
- NashornScriptEngineFactory nashornFactory = null;
- final ScriptEngineManager sm = new ScriptEngineManager();
- for (final ScriptEngineFactory fac : sm.getEngineFactories()) {
- if (fac instanceof NashornScriptEngineFactory) {
- nashornFactory = (NashornScriptEngineFactory) fac;
- break;
- }
- }
- if (nashornFactory == null) {
- fail("Cannot find nashorn factory!");
- }
- // fine is enough for cache hits, finest produces way too much information
- // TODO this should be ported to use the RuntimeEvents instead of screen scraping
- // logs, as obviously this is very brittle
- final String[] options = new String[]{"--log=compiler:fine"};
- engine = nashornFactory.getScriptEngine(options);
- context1 = engine.getContext();
- context2 = new SimpleScriptContext();
- context2.setBindings(engine.createBindings(), ScriptContext.ENGINE_SCOPE);
- context3 = new SimpleScriptContext();
- context3.setBindings(engine.createBindings(), ScriptContext.ENGINE_SCOPE);
- }
-
- @AfterTest
- public void setErrTest() {
- System.setErr(prevStderr);
- }
-
- public void runTest(final int numberOfContext, final String expectedOutputPattern,
- final int expectedPatternOccurrence) {
-
- try {
- switch (numberOfContext) {
- case 2:
- final String scriptTwoContexts = "print('HelloTwoContexts')";
- engine.eval(scriptTwoContexts, context1);
- engine.eval(scriptTwoContexts, context2);
- break;
- case 3:
- final String scriptThreeContexts = "print('HelloThreeContexts')";
- engine.eval(scriptThreeContexts, context1);
- engine.eval(scriptThreeContexts, context2);
- engine.eval(scriptThreeContexts, context3);
- break;
- default:
- break;
- }
- } catch (final Exception se) {
- se.printStackTrace();
- fail(se.getMessage());
- }
- final Pattern deoptimizing = Pattern.compile(expectedOutputPattern);
- final Matcher matcher = deoptimizing.matcher(stderr.toString());
- int matches = 0;
- while (matcher.find()) {
- matches++;
- }
- if (matches != expectedPatternOccurrence) {
- fail("Number of cache hit is not correct, expected: "
- + expectedPatternOccurrence + " and found: " + matches + "\n"
- + stderr);
- }
- stderr.reset();
- }
-
- private static String getCodeCachePattern() {
- return ("\\[compiler\\]\\sCode\\scache\\shit\\sfor\\s<eval>\\savoiding\\srecompile.");
- }
-
- @Test
- public void twoContextTest() {
- runTest(2, getCodeCachePattern(), 1);
-
- }
-
- @Test
- public void threeContextTest() {
- runTest(3, getCodeCachePattern(), 2);
- }
-}
--- a/nashorn/test/src/jdk/nashorn/internal/runtime/SourceTest.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,124 +0,0 @@
-/*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.runtime;
-
-import static jdk.nashorn.internal.runtime.Source.sourceFor;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.URL;
-import java.util.Arrays;
-import jdk.nashorn.api.scripting.URLReader;
-import org.testng.annotations.Test;
-
-/**
- * Tests different Source representations.
- */
-@SuppressWarnings("javadoc")
-public class SourceTest {
-
- final private static String SOURCE_NAME = "source.js";
- final private static String SOURCE_STRING = "var x = 1;";
- final private static char[] SOURCE_CHARS = SOURCE_STRING.toCharArray();
- final private static String RESOURCE_PATH = "resources/load_test.js";
- final private static File SOURCE_FILE = new File("build/test/classes/jdk/nashorn/internal/runtime/" + RESOURCE_PATH);
- final private static URL SOURCE_URL = SourceTest.class.getResource(RESOURCE_PATH);
-
-
- @Test
- public void testStringSource() {
- testSources(sourceFor(SOURCE_NAME, SOURCE_STRING), sourceFor(SOURCE_NAME, SOURCE_STRING));
- testSources(sourceFor(SOURCE_NAME, SOURCE_STRING), sourceFor(SOURCE_NAME, SOURCE_CHARS));
- }
-
- @Test
- public void testCharArraySource() {
- testSources(sourceFor(SOURCE_NAME, SOURCE_CHARS), sourceFor(SOURCE_NAME, SOURCE_CHARS));
- testSources(sourceFor(SOURCE_NAME, SOURCE_CHARS), sourceFor(SOURCE_NAME, SOURCE_STRING));
- }
-
- @Test
- public void testURLSource() {
- try {
- testSources(sourceFor(SOURCE_NAME, SOURCE_URL), sourceFor(SOURCE_NAME, SOURCE_URL));
- testSources(sourceFor(SOURCE_NAME, SOURCE_URL), sourceFor(SOURCE_NAME, new URLReader(SOURCE_URL)));
-
- } catch (final IOException e) {
- fail(e.toString());
- }
- }
-
- @Test
- public void testURLReaderSource() {
- try {
- System.err.println(SourceTest.class.getResource(""));
- testSources(sourceFor(SOURCE_NAME, new URLReader(SOURCE_URL)), sourceFor(SOURCE_NAME, new URLReader(SOURCE_URL)));
- testSources(sourceFor(SOURCE_NAME, new URLReader(SOURCE_URL)), sourceFor(SOURCE_NAME, SOURCE_URL));
- } catch (final IOException e) {
- fail(e.toString());
- }
- }
-
- @Test
- public void testReaderSource() {
- try {
- testSources(sourceFor(SOURCE_NAME, getReader(RESOURCE_PATH)), sourceFor(SOURCE_NAME, getReader(RESOURCE_PATH)));
- } catch (final IOException e) {
- fail(e.toString());
- }
- }
-
- @Test
- public void testFileSource() {
- try {
- testSources(sourceFor(SOURCE_NAME, SOURCE_FILE), sourceFor(SOURCE_NAME, SOURCE_FILE));
- } catch (final IOException e) {
- fail(e.toString());
- }
- }
-
- private static Reader getReader(final String path) {
- return new InputStreamReader(SourceTest.class.getResourceAsStream(path));
- }
-
- private static void testSources(final Source source1, final Source source2) {
- final char[] chars1 = source1.getContent();
- final char[] chars2 = source2.getContent();
- final String str1 = source1.getString();
- final String str2 = source2.getString();
- assertTrue(Arrays.equals(chars1, chars2));
- assertEquals(str1, str2);
- assertEquals(source1.hashCode(), source2.hashCode());
- assertTrue(source1.equals(source2));
- assertTrue(Arrays.equals(source1.getContent(), str1.toCharArray()));
- assertTrue(Arrays.equals(source1.getContent(), chars1));
- assertTrue(Arrays.equals(source1.getContent(), source2.getContent()));
- }
-}
--- a/nashorn/test/src/jdk/nashorn/internal/runtime/TrustedScriptEngineTest.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,362 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.runtime;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
-import javax.script.ScriptContext;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineFactory;
-import javax.script.ScriptEngineManager;
-import javax.script.ScriptException;
-import javax.script.SimpleScriptContext;
-import jdk.nashorn.api.scripting.ClassFilter;
-import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
-import org.testng.annotations.Test;
-
-/**
- * Tests for trusted client usage of nashorn script engine factory extension API
- */
-@SuppressWarnings("javadoc")
-public class TrustedScriptEngineTest {
- @Test
- public void versionTest() {
- final ScriptEngineManager m = new ScriptEngineManager();
- final ScriptEngine e = m.getEngineByName("nashorn");
- assertEquals(e.getFactory().getEngineVersion(), Version.version());
- }
-
- private static class MyClassLoader extends ClassLoader {
- // to check if script engine uses the specified class loader
- private final boolean[] reached = new boolean[1];
-
- @Override
- protected Class<?> findClass(final String name) throws ClassNotFoundException {
- // flag that it reached here
- reached[0] = true;
- return super.findClass(name);
- }
-
- public boolean reached() {
- return reached[0];
- }
- }
-
- // These are for "private" extension API of NashornScriptEngineFactory that
- // accepts a ClassLoader and/or command line options.
-
- @Test
- public void factoryClassLoaderTest() {
- final ScriptEngineManager sm = new ScriptEngineManager();
- for (final ScriptEngineFactory fac : sm.getEngineFactories()) {
- if (fac instanceof NashornScriptEngineFactory) {
- final NashornScriptEngineFactory nfac = (NashornScriptEngineFactory)fac;
- final MyClassLoader loader = new MyClassLoader();
- // set the classloader as app class loader
- final ScriptEngine e = nfac.getScriptEngine(loader);
- try {
- e.eval("Packages.foo");
- // check that the class loader was attempted
- assertTrue(loader.reached(), "did not reach class loader!");
- } catch (final ScriptException se) {
- se.printStackTrace();
- fail(se.getMessage());
- }
- return;
- }
- }
-
- fail("Cannot find nashorn factory!");
- }
-
- @Test
- public void factoryClassLoaderAndOptionsTest() {
- final ScriptEngineManager sm = new ScriptEngineManager();
- for (final ScriptEngineFactory fac : sm.getEngineFactories()) {
- if (fac instanceof NashornScriptEngineFactory) {
- final NashornScriptEngineFactory nfac = (NashornScriptEngineFactory)fac;
- final String[] options = new String[] { "-strict" };
- final MyClassLoader loader = new MyClassLoader();
- // set the classloader as app class loader
- final ScriptEngine e = nfac.getScriptEngine(options, loader);
- try {
- e.eval("Packages.foo");
- // check that the class loader was attempted
- assertTrue(loader.reached(), "did not reach class loader!");
- } catch (final ScriptException se) {
- se.printStackTrace();
- fail(se.getMessage());
- }
-
- try {
- // strict mode - delete of a var should throw SyntaxError
- e.eval("var d = 2; delete d;");
- } catch (final ScriptException se) {
- // check that the error message contains "SyntaxError"
- assertTrue(se.getMessage().contains("SyntaxError"));
- }
-
- return;
- }
- }
-
- fail("Cannot find nashorn factory!");
- }
-
- @Test
- public void factoryOptionsTest() {
- final ScriptEngineManager sm = new ScriptEngineManager();
- for (final ScriptEngineFactory fac : sm.getEngineFactories()) {
- if (fac instanceof NashornScriptEngineFactory) {
- final NashornScriptEngineFactory nfac = (NashornScriptEngineFactory)fac;
- // specify --no-syntax-extensions flag
- final String[] options = new String[] { "--no-syntax-extensions" };
- final ScriptEngine e = nfac.getScriptEngine(options);
- try {
- // try nashorn specific extension
- e.eval("var f = funtion(x) 2*x;");
- fail("should have thrown exception!");
- } catch (final Exception ex) {
- //empty
- }
- return;
- }
- }
-
- fail("Cannot find nashorn factory!");
- }
-
- @Test
- /**
- * Test repeated evals with --loader-per-compile=false
- * We used to get "class redefinition error".
- */
- public void noLoaderPerCompilerTest() {
- final ScriptEngineManager sm = new ScriptEngineManager();
- for (final ScriptEngineFactory fac : sm.getEngineFactories()) {
- if (fac instanceof NashornScriptEngineFactory) {
- final NashornScriptEngineFactory nfac = (NashornScriptEngineFactory)fac;
- final String[] options = new String[] { "--loader-per-compile=false" };
- final ScriptEngine e = nfac.getScriptEngine(options);
- try {
- e.eval("2 + 3");
- e.eval("4 + 4");
- } catch (final ScriptException se) {
- se.printStackTrace();
- fail(se.getMessage());
- }
- return;
- }
- }
- fail("Cannot find nashorn factory!");
- }
-
- @Test
- /**
- * Test that we can use same script name in repeated evals with --loader-per-compile=false
- * We used to get "class redefinition error" as name was derived from script name.
- */
- public void noLoaderPerCompilerWithSameNameTest() {
- final ScriptEngineManager sm = new ScriptEngineManager();
- for (final ScriptEngineFactory fac : sm.getEngineFactories()) {
- if (fac instanceof NashornScriptEngineFactory) {
- final NashornScriptEngineFactory nfac = (NashornScriptEngineFactory)fac;
- final String[] options = new String[] { "--loader-per-compile=false" };
- final ScriptEngine e = nfac.getScriptEngine(options);
- e.put(ScriptEngine.FILENAME, "test.js");
- try {
- e.eval("2 + 3");
- e.eval("4 + 4");
- } catch (final ScriptException se) {
- se.printStackTrace();
- fail(se.getMessage());
- }
- return;
- }
- }
- fail("Cannot find nashorn factory!");
- }
-
- @Test
- public void globalPerEngineTest() throws ScriptException {
- final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
- final String[] options = new String[] { "--global-per-engine" };
- final ScriptEngine e = fac.getScriptEngine(options);
-
- e.eval("function foo() {}");
-
- final ScriptContext newCtx = new SimpleScriptContext();
- newCtx.setBindings(e.createBindings(), ScriptContext.ENGINE_SCOPE);
-
- // all global definitions shared and so 'foo' should be
- // visible in new Bindings as well.
- assertTrue(e.eval("typeof foo", newCtx).equals("function"));
-
- e.eval("function bar() {}", newCtx);
-
- // bar should be visible in default context
- assertTrue(e.eval("typeof bar").equals("function"));
- }
-
- @Test
- public void classFilterTest() throws ScriptException {
- final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
- final ScriptEngine e = fac.getScriptEngine(new ClassFilter() {
- @Override
- public boolean exposeToScripts(final String fullName) {
- // don't allow anything that is not "java."
- return fullName.startsWith("java.");
- }
- });
-
- assertEquals(e.eval("typeof javax.script.ScriptEngine"), "object");
- assertEquals(e.eval("typeof java.util.Vector"), "function");
-
- try {
- e.eval("Java.type('javax.script.ScriptContext')");
- fail("should not reach here");
- } catch (final ScriptException | RuntimeException se) {
- if (! (se.getCause() instanceof ClassNotFoundException)) {
- fail("ClassNotFoundException expected");
- }
- }
- }
-
- @Test
- public void classFilterTest2() throws ScriptException {
- final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
- final ScriptEngine e = fac.getScriptEngine(new String[0], Thread.currentThread().getContextClassLoader(),
- new ClassFilter() {
- @Override
- public boolean exposeToScripts(final String fullName) {
- // don't allow anything that is not "java."
- return fullName.startsWith("java.");
- }
- });
-
- assertEquals(e.eval("typeof javax.script.ScriptEngine"), "object");
- assertEquals(e.eval("typeof java.util.Vector"), "function");
-
- try {
- e.eval("Java.type('javax.script.ScriptContext')");
- fail("should not reach here");
- } catch (final ScriptException | RuntimeException se) {
- if (! (se.getCause() instanceof ClassNotFoundException)) {
- fail("ClassNotFoundException expected");
- }
- }
- }
-
- @Test
- public void nullClassFilterTest() {
- final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
- try {
- fac.getScriptEngine((ClassFilter)null);
- fail("should have thrown NPE");
- } catch (final NullPointerException e) {
- //empty
- }
- }
-
- @Test
- public void nullClassFilterTest2() {
- final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
- try {
- fac.getScriptEngine(new String[0], null, null);
- fail("should have thrown NPE");
- } catch (final NullPointerException e) {
- //empty
- }
- }
-
- @Test
- public void nullArgsTest() {
- final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
- try {
- fac.getScriptEngine((String[])null);
- fail("should have thrown NPE");
- } catch (final NullPointerException e) {
- //empty
- }
- }
-
- @Test
- public void nullArgsTest2() {
- final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
- try {
- fac.getScriptEngine(null, null, new ClassFilter() {
- @Override
- public boolean exposeToScripts(final String name) {
- return true;
- }
- });
- fail("should have thrown NPE");
- } catch (final NullPointerException e) {
- //empty
- }
- }
-
- @Test
- public void nashornSwallowsConstKeyword() throws Exception {
- final NashornScriptEngineFactory f = new NashornScriptEngineFactory();
- final String[] args = new String[] { "--const-as-var" };
- final ScriptEngine engine = f.getScriptEngine(args);
-
- final Object ret = engine.eval(""
- + "(function() {\n"
- + " const x = 10;\n"
- + " return x;\n"
- + "})();"
- );
- assertEquals(ret, 10, "Parsed and executed OK");
- }
-
- @Test
- public void evalDefaultFileNameTest() throws ScriptException {
- final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
- final ScriptEngine engine = fac.getScriptEngine(new String[] { "--verify-code=true" });
- // default FILENAME being "<eval>" make sure generated code bytecode verifies.
- engine.eval("var a = 3;");
- }
-
- @Test
- public void evalFileNameWithSpecialCharsTest() throws ScriptException {
- final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
- final ScriptEngine engine = fac.getScriptEngine(new String[] { "--verify-code=true" });
- final ScriptContext ctxt = new SimpleScriptContext();
- // use file name with "dangerous" chars.
- ctxt.setAttribute(ScriptEngine.FILENAME, "<myscript>", ScriptContext.ENGINE_SCOPE);
- engine.eval("var a = 3;");
- ctxt.setAttribute(ScriptEngine.FILENAME, "[myscript]", ScriptContext.ENGINE_SCOPE);
- engine.eval("var h = 'hello';");
- ctxt.setAttribute(ScriptEngine.FILENAME, ";/\\$.", ScriptContext.ENGINE_SCOPE);
- engine.eval("var foo = 'world';");
- // name used by jjs shell tool for the interactive mode
- ctxt.setAttribute(ScriptEngine.FILENAME, "<shell>", ScriptContext.ENGINE_SCOPE);
- engine.eval("var foo = 'world';");
- }
-}
--- a/nashorn/test/src/jdk/nashorn/internal/runtime/regexp/JdkRegExpTest.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.runtime.regexp;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
-import org.testng.annotations.Test;
-
-/**
- * Basic tests for the JDK based RegExp implementation.
- *
- * @test
- * @run testng jdk.nashorn.internal.runtime.regexp.JdkRegExpTest
- */
-public class JdkRegExpTest {
-
- /**
- * Compile a regular expression using the JDK implementation
- */
- @Test
- public void testMatcher() {
- final RegExp regexp = new RegExpFactory().compile("f(o)o", "");
- final RegExpMatcher matcher = regexp.match("foo");
- assertNotNull(matcher);
- assertTrue(matcher.search(0));
- assertEquals(matcher.getInput(), "foo");
- assertEquals(matcher.groupCount(), 1);
- assertEquals(matcher.group(), "foo");
- assertEquals(matcher.start(), 0);
- assertEquals(matcher.end(), 3);
- assertEquals(matcher.group(1), "o");
- assertEquals(matcher.start(1), 1);
- assertEquals(matcher.end(1), 2);
- }
-}
--- a/nashorn/test/src/jdk/nashorn/internal/runtime/regexp/joni/JoniTest.java Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.runtime.regexp.joni;
-
-import org.testng.annotations.Test;
-
-/**
- * Joni coverage tests
- *
- * @test
- * @run testng jdk.nashorn.internal.runtime.regexp.joni.JoniTest
- */
-@SuppressWarnings("javadoc")
-public class JoniTest {
-
- @Test
- public void testDump() {
- new Regex("^a{3,}(.*)[z]++\\s\\1x$").dumpTree();
- new Regex("^a{3,}(.*)[z]++\\s\\1x$").dumpByteCode();
- new Regex("(abc){4,}{2,5}").dumpTree();
- new Regex("(abc){4,}{2,5}").dumpByteCode();
- new Regex("aaa|aa|bbbb|ccc").dumpTree();
- new Regex("aaa|aa|bbbb|ccc").dumpByteCode();
- new Regex("(?:ZFVR.(\\d+\\.\\d+))|(?:(?:Sversbk|TenaCnenqvfb|Vprjrnfry).(\\d+\\.\\d+))|(?:Bcren.(\\d+\\.\\d+))|(?:NccyrJroXvg.(\\d+(?:\\.\\d+)?))").dumpTree();
- new Regex("(?:ZFVR.(\\d+\\.\\d+))|(?:(?:Sversbk|TenaCnenqvfb|Vprjrnfry).(\\d+\\.\\d+))|(?:Bcren.(\\d+\\.\\d+))|(?:NccyrJroXvg.(\\d+(?:\\.\\d+)?))").dumpByteCode();
- }
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/internal/runtime/regexp/joni/test/JoniTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.runtime.regexp.joni.test;
+
+import jdk.nashorn.internal.runtime.regexp.joni.Regex;
+import org.testng.annotations.Test;
+
+/**
+ * Joni coverage tests
+ *
+ * @test
+ * @run testng jdk.nashorn.internal.runtime.regexp.joni.test.JoniTest
+ */
+@SuppressWarnings("javadoc")
+public class JoniTest {
+
+ @Test
+ public void testDump() {
+ new Regex("^a{3,}(.*)[z]++\\s\\1x$").dumpTree();
+ new Regex("^a{3,}(.*)[z]++\\s\\1x$").dumpByteCode();
+ new Regex("(abc){4,}{2,5}").dumpTree();
+ new Regex("(abc){4,}{2,5}").dumpByteCode();
+ new Regex("aaa|aa|bbbb|ccc").dumpTree();
+ new Regex("aaa|aa|bbbb|ccc").dumpByteCode();
+ new Regex("(?:ZFVR.(\\d+\\.\\d+))|(?:(?:Sversbk|TenaCnenqvfb|Vprjrnfry).(\\d+\\.\\d+))|(?:Bcren.(\\d+\\.\\d+))|(?:NccyrJroXvg.(\\d+(?:\\.\\d+)?))").dumpTree();
+ new Regex("(?:ZFVR.(\\d+\\.\\d+))|(?:(?:Sversbk|TenaCnenqvfb|Vprjrnfry).(\\d+\\.\\d+))|(?:Bcren.(\\d+\\.\\d+))|(?:NccyrJroXvg.(\\d+(?:\\.\\d+)?))").dumpByteCode();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/internal/runtime/regexp/test/JdkRegExpTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.runtime.regexp.test;
+
+import jdk.nashorn.internal.runtime.regexp.RegExp;
+import jdk.nashorn.internal.runtime.regexp.RegExpFactory;
+import jdk.nashorn.internal.runtime.regexp.RegExpMatcher;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import org.testng.annotations.Test;
+
+/**
+ * Basic tests for the JDK based RegExp implementation.
+ *
+ * @test
+ * @run testng jdk.nashorn.internal.runtime.regexp.test.JdkRegExpTest
+ */
+public class JdkRegExpTest {
+
+ /**
+ * Compile a regular expression using the JDK implementation
+ */
+ @Test
+ public void testMatcher() {
+ final RegExp regexp = new RegExpFactory().compile("f(o)o", "");
+ final RegExpMatcher matcher = regexp.match("foo");
+ assertNotNull(matcher);
+ assertTrue(matcher.search(0));
+ assertEquals(matcher.getInput(), "foo");
+ assertEquals(matcher.groupCount(), 1);
+ assertEquals(matcher.group(), "foo");
+ assertEquals(matcher.start(), 0);
+ assertEquals(matcher.end(), 3);
+ assertEquals(matcher.group(1), "o");
+ assertEquals(matcher.start(1), 1);
+ assertEquals(matcher.end(1), 2);
+ }
+}
--- a/nashorn/test/src/jdk/nashorn/internal/runtime/resources/load_test.js Mon Apr 13 17:03:11 2015 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-function loadedFunc(arg) {
- return arg.toUpperCase();
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/internal/runtime/test/ClassFilterTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,185 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.runtime.test;
+
+import static org.testng.Assert.fail;
+import java.io.File;
+import javax.script.ScriptEngine;
+import javax.script.ScriptException;
+import jdk.nashorn.api.scripting.ClassFilter;
+import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
+import jdk.nashorn.api.scripting.URLReader;
+import jdk.nashorn.internal.test.framework.TestFinder;
+import org.testng.annotations.Test;
+
+@SuppressWarnings("javadoc")
+public class ClassFilterTest {
+ private static final String NASHORN_CODE_CACHE = "nashorn.persistent.code.cache";
+ private static final String CLASSFILTER_CODE_CACHE = "build/classfilter_nashorn_code_cache";
+
+ // @Test
+ // This test takes too much time for basic "ant clean test" run.
+ // Given that "allow-all-java-classes" is equivalent to no java class
+ // filter and external tests don't access any java, not sure if this
+ // test contributes much. We need faster "ant clean test" cycle for
+ // developers.
+ public void runExternalJsTest() {
+ final String[] paths = new String[]{
+ "test/script/basic/compile-octane.js",
+ "test/script/basic/jquery.js",
+ "test/script/basic/prototype.js",
+ "test/script/basic/runsunspider.js",
+ "test/script/basic/underscore.js",
+ "test/script/basic/yui.js",
+ "test/script/basic/run-octane.js"
+ };
+ final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
+ for (final String path : paths) {
+ final ScriptEngine engine = factory.getScriptEngine(new String[]{"-scripting"}, getClass().getClassLoader(), getClassFilter());
+ try {
+ engine.eval(new URLReader(new File(path).toURI().toURL()));
+ } catch (final Exception e) {
+ fail("Script " + path + " fails with exception :" + e.getMessage());
+ }
+ }
+ }
+
+ @Test
+ public void noJavaOptionTest() {
+ final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
+ final ScriptEngine engine = factory.getScriptEngine(new String[]{"--no-java"}, getClass().getClassLoader(), getClassFilter());
+ try {
+ engine.eval("var str = Java.type('java.lang.String');");
+ fail("TypeError should have been thrown");
+ } catch (final ScriptException e) {
+ //emtpy
+ }
+ }
+
+ @Test
+ public void securityTest() {
+ if (System.getSecurityManager() == null) {
+ return;
+ }
+
+ final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
+ final ScriptEngine engine = factory.getScriptEngine(getClassFilter());
+ try {
+ engine.eval("var thread = Java.type('sun.misc.Unsafe')");
+ fail("SecurityException should have been thrown");
+ } catch (final Exception e) {
+ //empty
+ }
+ try {
+ engine.eval("var thread = new sun.misc.Unsafe()");
+ fail("SecurityException should have been thrown");
+ } catch (final Exception e) {
+ //empty
+ }
+ try {
+ engine.eval("var thread = Java.extend(sun.misc.Unsafe, {})");
+ fail("TypeError should have been thrown");
+ } catch (final Exception e) {
+ //empty
+ }
+ try {
+ engine.eval("java.lang.System.exit(0)");
+ fail("SecurityException should have been thrown");
+ } catch (final Exception e) {
+ //empty
+ }
+
+ }
+
+ @Test
+ public void persistentCacheTest() {
+ final String oldCodeCache = System.getProperty(NASHORN_CODE_CACHE);
+ System.setProperty(NASHORN_CODE_CACHE, CLASSFILTER_CODE_CACHE);
+ try {
+ persistentCacheTestImpl();
+ } finally {
+ if (oldCodeCache != null) {
+ System.setProperty(NASHORN_CODE_CACHE, oldCodeCache);
+ }
+ }
+ }
+
+ private void persistentCacheTestImpl() {
+ final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
+ final ScriptEngine engine = factory.getScriptEngine(
+ TestFinder.addExplicitOptimisticTypes(new String[]{"--persistent-code-cache", "--optimistic-types=true"}),
+ getClass().getClassLoader(),
+ getClassFilter()
+ );
+ final String testScript = "var a = Java.type('java.lang.String');" + generateCodeForPersistentStore();
+ try {
+ engine.eval(testScript);
+ } catch (final ScriptException exc) {
+ fail(exc.getMessage());
+ }
+ final ScriptEngine engineSafe = factory.getScriptEngine(
+ TestFinder.addExplicitOptimisticTypes(new String[]{"--persistent-code-cache", "--optimistic-types=true"}),
+ getClass().getClassLoader(),
+ new ClassFilter() {
+ @Override
+ public boolean exposeToScripts(final String s) {
+ return false;
+ }
+ }
+ );
+ try {
+ engineSafe.eval(testScript);
+ fail("ClassNotFoundException should have been thrown");
+ } catch (final Exception exc) {
+ if (!(exc.getCause() instanceof ClassNotFoundException)) {
+ fail("ClassNotFoundException expected, got " + exc.getClass());
+ }
+ }
+ }
+
+ private static String generateCodeForPersistentStore() {
+ final StringBuilder stringBuilder = new StringBuilder();
+ for (int i=0; i < 100; i++) {
+ stringBuilder.append("function i")
+ .append(i)
+ .append("(y, z) { var x")
+ .append(i)
+ .append(" = ")
+ .append(i)
+ .append(";}");
+ }
+ return stringBuilder.toString();
+ }
+
+ private static ClassFilter getClassFilter() {
+ return new ClassFilter() {
+ @Override
+ public boolean exposeToScripts(final String s) {
+ return true;
+ }
+ };
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/internal/runtime/test/CodeStoreAndPathTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,189 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.nashorn.internal.runtime.test;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.DirectoryStream;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import javax.script.ScriptEngine;
+import javax.script.ScriptException;
+import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
+import org.testng.annotations.Test;
+
+/**
+ * @ignore Fails with jtreg, but passes with ant test run. Ignore for now.
+ * @test
+ * @bug 8039185 8039403
+ * @summary Test for persistent code cache and path handling
+ * @run testng jdk.nashorn.internal.runtime.test.CodeStoreAndPathTest
+ */
+@SuppressWarnings("javadoc")
+public class CodeStoreAndPathTest {
+
+ final String code1 = "var code1; var x = 'Hello Script'; var x1 = 'Hello Script'; "
+ + "var x2 = 'Hello Script'; var x3 = 'Hello Script'; "
+ + "var x4 = 'Hello Script'; var x5 = 'Hello Script';"
+ + "var x6 = 'Hello Script'; var x7 = 'Hello Script'; "
+ + "var x8 = 'Hello Script'; var x9 = 'Hello Script'; "
+ + "var x10 = 'Hello Script';"
+ + "function f() {x ='Bye Script'; x1 ='Bye Script'; x2='Bye Script';"
+ + "x3='Bye Script'; x4='Bye Script'; x5='Bye Script'; x6='Bye Script';"
+ + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; "
+ + "var x10 = 'Hello Script';}"
+ + "function g() {x ='Bye Script'; x1 ='Bye Script'; x2='Bye Script';"
+ + "x3='Bye Script'; x4='Bye Script'; x5='Bye Script'; x6='Bye Script';"
+ + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; "
+ + "var x10 = 'Hello Script';}"
+ + "function h() {x ='Bye Script'; x1 ='Bye Script'; x2='Bye Script';"
+ + "x3='Bye Script'; x4='Bye Script'; x5='Bye Script'; x6='Bye Script';"
+ + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; "
+ + "var x10 = 'Hello Script';}"
+ + "function i() {x ='Bye Script'; x1 ='Bye Script'; x2='Bye Script';"
+ + "x3='Bye Script'; x4='Bye Script'; x5='Bye Script'; x6='Bye Script';"
+ + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; "
+ + "var x10 = 'Hello Script';}";
+ final String code2 = "var code2; var x = 'Hello Script'; var x1 = 'Hello Script'; "
+ + "var x2 = 'Hello Script'; var x3 = 'Hello Script'; "
+ + "var x4 = 'Hello Script'; var x5 = 'Hello Script';"
+ + "var x6 = 'Hello Script'; var x7 = 'Hello Script'; "
+ + "var x8 = 'Hello Script'; var x9 = 'Hello Script'; "
+ + "var x10 = 'Hello Script';"
+ + "function f() {x ='Bye Script'; x1 ='Bye Script'; x2='Bye Script';"
+ + "x3='Bye Script'; x4='Bye Script'; x5='Bye Script'; x6='Bye Script';"
+ + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; "
+ + "var x10 = 'Hello Script';}"
+ + "function g() {x ='Bye Script'; x1 ='Bye Script'; x2='Bye Script';"
+ + "x3='Bye Script'; x4='Bye Script'; x5='Bye Script'; x6='Bye Script';"
+ + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; "
+ + "var x10 = 'Hello Script';}"
+ + "function h() {x ='Bye Script'; x1 ='Bye Script'; x2='Bye Script';"
+ + "x3='Bye Script'; x4='Bye Script'; x5='Bye Script'; x6='Bye Script';"
+ + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; "
+ + "var x10 = 'Hello Script';}"
+ + "function i() {x ='Bye Script'; x1 ='Bye Script'; x2='Bye Script';"
+ + "x3='Bye Script'; x4='Bye Script'; x5='Bye Script'; x6='Bye Script';"
+ + "x7='Bye Script'; x8='Bye Script'; var x9 = 'Hello Script'; "
+ + "var x10 = 'Hello Script';}";
+ // Script size < Default minimum size for storing a compiled script class
+ final String code3 = "var code3; var x = 'Hello Script'; var x1 = 'Hello Script'; ";
+ final String codeCache = "build/nashorn_code_cache";
+ final String oldUserDir = System.getProperty("user.dir");
+
+ private static final String[] ENGINE_OPTIONS_OPT = new String[]{"--persistent-code-cache", "--optimistic-types=true"};
+ private static final String[] ENGINE_OPTIONS_NOOPT = new String[]{"--persistent-code-cache", "--optimistic-types=false"};
+
+ @Test
+ public void pathHandlingTest() {
+ System.setProperty("nashorn.persistent.code.cache", codeCache);
+ final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
+
+ fac.getScriptEngine(ENGINE_OPTIONS_NOOPT);
+
+ final Path expectedCodeCachePath = FileSystems.getDefault().getPath(oldUserDir + File.separator + codeCache);
+ final Path actualCodeCachePath = FileSystems.getDefault().getPath(System.getProperty(
+ "nashorn.persistent.code.cache")).toAbsolutePath();
+ // Check that nashorn code cache is created in current working directory
+ assertEquals(actualCodeCachePath, expectedCodeCachePath);
+ // Check that code cache dir exists and it's not empty
+ final File file = new File(actualCodeCachePath.toUri());
+ assertFalse(!file.isDirectory(), "No code cache directory was created!");
+ assertFalse(file.list().length == 0, "Code cache directory is empty!");
+ }
+
+ @Test
+ public void changeUserDirTest() throws ScriptException, IOException {
+ System.setProperty("nashorn.persistent.code.cache", codeCache);
+ final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
+ final ScriptEngine e = fac.getScriptEngine(ENGINE_OPTIONS_NOOPT);
+ final Path codeCachePath = getCodeCachePath(false);
+ final String newUserDir = "build/newUserDir";
+ // Now changing current working directory
+ System.setProperty("user.dir", System.getProperty("user.dir") + File.separator + newUserDir);
+ try {
+ // Check that a new compiled script is stored in existing code cache
+ e.eval(code1);
+ final DirectoryStream<Path> stream = Files.newDirectoryStream(codeCachePath);
+ checkCompiledScripts(stream, 1);
+ // Setting to default current working dir
+ } finally {
+ System.setProperty("user.dir", oldUserDir);
+ }
+ }
+
+ @Test
+ public void codeCacheTest() throws ScriptException, IOException {
+ System.setProperty("nashorn.persistent.code.cache", codeCache);
+ final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
+ final ScriptEngine e = fac.getScriptEngine(ENGINE_OPTIONS_NOOPT);
+ final Path codeCachePath = getCodeCachePath(false);
+ e.eval(code1);
+ e.eval(code2);
+ e.eval(code3);// less than minimum size for storing
+ // adding code1 and code2.
+ final DirectoryStream<Path> stream = Files.newDirectoryStream(codeCachePath);
+ checkCompiledScripts(stream, 2);
+ }
+
+ @Test
+ public void codeCacheTestOpt() throws ScriptException, IOException {
+ System.setProperty("nashorn.persistent.code.cache", codeCache);
+ final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
+ final ScriptEngine e = fac.getScriptEngine(ENGINE_OPTIONS_OPT);
+ final Path codeCachePath = getCodeCachePath(true);
+ e.eval(code1);
+ e.eval(code2);
+ e.eval(code3);// less than minimum size for storing
+ // adding code1 and code2.
+ final DirectoryStream<Path> stream = Files.newDirectoryStream(codeCachePath);
+ checkCompiledScripts(stream, 2);
+ }
+
+ private static Path getCodeCachePath(final boolean optimistic) {
+ final String codeCache = System.getProperty("nashorn.persistent.code.cache");
+ final Path codeCachePath = FileSystems.getDefault().getPath(codeCache).toAbsolutePath();
+ final String[] files = codeCachePath.toFile().list();
+ for (final String file : files) {
+ if (file.endsWith("_opt") == optimistic) {
+ return codeCachePath.resolve(file);
+ }
+ }
+ throw new AssertionError("Code cache path not found");
+ }
+
+ private static void checkCompiledScripts(final DirectoryStream<Path> stream, final int numberOfScripts) throws IOException {
+ int n = numberOfScripts;
+ for (@SuppressWarnings("unused") final Path file : stream) {
+ n--;
+ }
+ stream.close();
+ assertEquals(n, 0);
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/internal/runtime/test/ConsStringTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.runtime.test;
+
+import jdk.nashorn.internal.runtime.ConsString;
+import static org.testng.Assert.assertEquals;
+
+import org.testng.annotations.Test;
+
+/**
+ * Tests for JSType methods.
+ *
+ * @test
+ * @run testng jdk.nashorn.internal.runtime.test.ConsStringTest
+ */
+public class ConsStringTest {
+
+ /**
+ * Test toString conversion
+ */
+ @Test
+ public void testConsStringToString() {
+ final ConsString cs1 = new ConsString("b", "c");
+ final ConsString cs2 = new ConsString("d", "e");
+ final ConsString cs3 = new ConsString(cs1, cs2);
+ final ConsString cs4 = new ConsString(cs3, "f");
+ final ConsString cs5 = new ConsString("a", cs4);
+ assertEquals(cs5.toString(), "abcdef");
+ assertEquals(cs4.toString(), "bcdef");
+ assertEquals(cs3.toString(), "bcde");
+ assertEquals(cs2.toString(), "de");
+ assertEquals(cs1.toString(), "bc");
+ // ConsStrings should be flattened now
+ assertEquals(cs1.getComponents()[0], "bc");
+ assertEquals(cs1.getComponents()[1], "");
+ assertEquals(cs2.getComponents()[0], "de");
+ assertEquals(cs2.getComponents()[1], "");
+ assertEquals(cs3.getComponents()[0], "bcde");
+ assertEquals(cs3.getComponents()[1], "");
+ assertEquals(cs4.getComponents()[0], "bcdef");
+ assertEquals(cs4.getComponents()[1], "");
+ assertEquals(cs5.getComponents()[0], "abcdef");
+ assertEquals(cs5.getComponents()[1], "");
+ }
+
+ /**
+ * Test charAt
+ */
+ @Test
+ public void testConsStringCharAt() {
+ final ConsString cs1 = new ConsString("b", "c");
+ final ConsString cs2 = new ConsString("d", "e");
+ final ConsString cs3 = new ConsString(cs1, cs2);
+ final ConsString cs4 = new ConsString(cs3, "f");
+ final ConsString cs5 = new ConsString("a", cs4);
+ assertEquals(cs1.charAt(1), 'c');
+ assertEquals(cs2.charAt(0), 'd');
+ assertEquals(cs3.charAt(3), 'e');
+ assertEquals(cs4.charAt(1), 'c');
+ assertEquals(cs5.charAt(2), 'c');
+ // ConsStrings should be flattened now
+ assertEquals(cs1.getComponents()[0], "bc");
+ assertEquals(cs1.getComponents()[1], "");
+ assertEquals(cs2.getComponents()[0], "de");
+ assertEquals(cs2.getComponents()[1], "");
+ assertEquals(cs3.getComponents()[0], "bcde");
+ assertEquals(cs3.getComponents()[1], "");
+ assertEquals(cs4.getComponents()[0], "bcdef");
+ assertEquals(cs4.getComponents()[1], "");
+ assertEquals(cs5.getComponents()[0], "abcdef");
+ assertEquals(cs5.getComponents()[1], "");
+ }
+
+
+ /**
+ * Test flattening of top-level and internal ConsStrings
+ */
+ @Test
+ public void testConsStringFlattening() {
+ final ConsString cs1 = new ConsString("b", "c");
+ final ConsString cs2 = new ConsString("d", "e");
+ final ConsString cs3 = new ConsString(cs1, cs2);
+ final ConsString cs4 = new ConsString(cs3, "f");
+
+ final ConsString cs5 = new ConsString("a", cs4);
+ // top-level ConsString should not yet be flattened
+ assert(cs5.getComponents()[0] == "a");
+ assert(cs5.getComponents()[1] == cs4);
+ assertEquals(cs5.toString(), "abcdef");
+ // top-level ConsString should be flattened
+ assertEquals(cs5.getComponents()[0], "abcdef");
+ assertEquals(cs5.getComponents()[1], "");
+ // internal ConsString should not yet be flattened after first traversal
+ assertEquals(cs4.getComponents()[0], cs3);
+ assertEquals(cs4.getComponents()[1], "f");
+
+ final ConsString cs6 = new ConsString("a", cs4);
+ // top-level ConsString should not yet be flattened
+ assertEquals(cs6.getComponents()[0], "a");
+ assertEquals(cs6.getComponents()[1], cs4);
+ assertEquals(cs6.toString(), "abcdef");
+ // top-level ConsString should be flattened
+ assertEquals(cs6.getComponents()[0], "abcdef");
+ assertEquals(cs6.getComponents()[1], "");
+ // internal ConsString should have been flattened after second traversal
+ assertEquals(cs4.getComponents()[0], "bcdef");
+ assertEquals(cs4.getComponents()[1], "");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/internal/runtime/test/ContextTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.runtime.test;
+
+import static jdk.nashorn.internal.runtime.Source.sourceFor;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+import java.util.Map;
+import jdk.nashorn.internal.objects.Global;
+import jdk.nashorn.internal.runtime.Context;
+import jdk.nashorn.internal.runtime.ErrorManager;
+import jdk.nashorn.internal.runtime.ScriptFunction;
+import jdk.nashorn.internal.runtime.ScriptObject;
+import jdk.nashorn.internal.runtime.ScriptRuntime;
+import jdk.nashorn.internal.runtime.Source;
+import jdk.nashorn.internal.runtime.options.Options;
+import org.testng.annotations.Test;
+
+/**
+ * Basic Context API tests.
+ *
+ * @test
+ * @run testng jdk.nashorn.internal.runtime.test.ContextTest
+ */
+@SuppressWarnings("javadoc")
+public class ContextTest {
+ // basic context eval test
+ @Test
+ public void evalTest() {
+ final Options options = new Options("");
+ final ErrorManager errors = new ErrorManager();
+ final Context cx = new Context(options, errors, Thread.currentThread().getContextClassLoader());
+ final Global oldGlobal = Context.getGlobal();
+ Context.setGlobal(cx.createGlobal());
+ try {
+ String code = "22 + 10";
+ assertTrue(32.0 == ((Number)(eval(cx, "<evalTest>", code))).doubleValue());
+
+ code = "obj = { js: 'nashorn' }; obj.js";
+ assertEquals(eval(cx, "<evalTest2>", code), "nashorn");
+ } finally {
+ Context.setGlobal(oldGlobal);
+ }
+ }
+
+ // Make sure trying to compile an invalid script returns null - see JDK-8046215.
+ @Test
+ public void compileErrorTest() {
+ final Options options = new Options("");
+ final ErrorManager errors = new ErrorManager();
+ final Context cx = new Context(options, errors, Thread.currentThread().getContextClassLoader());
+ final Global oldGlobal = Context.getGlobal();
+ Context.setGlobal(cx.createGlobal());
+ try {
+ final ScriptFunction script = cx.compileScript(sourceFor("<evalCompileErrorTest>", "*/"), Context.getGlobal());
+ if (script != null) {
+ fail("Invalid script compiled without errors");
+ }
+ if (errors.getNumberOfErrors() != 1) {
+ fail("Wrong number of errors: " + errors.getNumberOfErrors());
+ }
+ } finally {
+ Context.setGlobal(oldGlobal);
+ }
+ }
+
+ // basic check for JS reflection access - java.util.Map-like access on ScriptObject
+ @Test
+ public void reflectionTest() {
+ final Options options = new Options("");
+ final ErrorManager errors = new ErrorManager();
+ final Context cx = new Context(options, errors, Thread.currentThread().getContextClassLoader());
+ final boolean strict = cx.getEnv()._strict;
+ final Global oldGlobal = Context.getGlobal();
+ Context.setGlobal(cx.createGlobal());
+
+ try {
+ final String code = "var obj = { x: 344, y: 42 }";
+ eval(cx, "<reflectionTest>", code);
+
+ final Object obj = Context.getGlobal().get("obj");
+
+ assertTrue(obj instanceof ScriptObject);
+
+ final ScriptObject sobj = (ScriptObject)obj;
+ int count = 0;
+ for (final Map.Entry<?, ?> ex : sobj.entrySet()) {
+ final Object key = ex.getKey();
+ if (key.equals("x")) {
+ assertTrue(ex.getValue() instanceof Number);
+ assertTrue(344.0 == ((Number)ex.getValue()).doubleValue());
+
+ count++;
+ } else if (key.equals("y")) {
+ assertTrue(ex.getValue() instanceof Number);
+ assertTrue(42.0 == ((Number)ex.getValue()).doubleValue());
+
+ count++;
+ }
+ }
+ assertEquals(count, 2);
+ assertEquals(sobj.size(), 2);
+
+ // add property
+ sobj.put("zee", "hello", strict);
+ assertEquals(sobj.get("zee"), "hello");
+ assertEquals(sobj.size(), 3);
+
+ } finally {
+ Context.setGlobal(oldGlobal);
+ }
+ }
+
+ private static Object eval(final Context cx, final String name, final String code) {
+ final Source source = sourceFor(name, code);
+ final ScriptObject global = Context.getGlobal();
+ final ScriptFunction func = cx.compileScript(source, global);
+ return func != null ? ScriptRuntime.apply(func, global) : null;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/internal/runtime/test/ExceptionsNotSerializable.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.runtime.test;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.fail;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.NotSerializableException;
+import java.io.ObjectOutputStream;
+import javax.script.ScriptEngine;
+import javax.script.ScriptException;
+import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
+import jdk.nashorn.internal.runtime.RewriteException;
+import jdk.nashorn.internal.runtime.UnwarrantedOptimismException;
+import org.testng.annotations.Test;
+
+/**
+ * JDK-8044518: Ensure exceptions related to optimistic recompilation are not serializable
+ *
+ * @test
+ * @run testng jdk.nashorn.internal.runtime.test.ExceptionsNotSerializable
+ */
+@SuppressWarnings("javadoc")
+public class ExceptionsNotSerializable {
+ @Test
+ public void rewriteExceptionNotSerializable() throws ScriptException {
+ // NOTE: we must create a RewriteException in a context of a Nashorn engine, as it uses Global.newIntance()
+ // internally.
+ final ScriptEngine e = new NashornScriptEngineFactory().getScriptEngine();
+ e.put("f", new Runnable() {
+ @Override
+ public void run() {
+ tryToSerialize(RewriteException.create(null, new Object[0], new String[0]));
+ }
+ });
+ e.eval("f()");
+ }
+
+ @Test
+ public void unwarrantedOptimismExceptionNotSerializable() {
+ tryToSerialize(new UnwarrantedOptimismException(new Double(1.0), 128));
+ }
+
+ private static void tryToSerialize(final Object obj) {
+ try {
+ new ObjectOutputStream(new ByteArrayOutputStream()).writeObject(obj);
+ fail();
+ } catch (final NotSerializableException e) {
+ assertEquals(e.getMessage(), obj.getClass().getName());
+ } catch (final IOException e) {
+ fail("", e);
+ }
+
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/internal/runtime/test/JSTypeTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,195 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.runtime.test;
+
+import jdk.nashorn.internal.runtime.JSType;
+import jdk.nashorn.internal.runtime.ScriptRuntime;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import org.testng.annotations.Test;
+
+/**
+ * Tests for JSType methods.
+ *
+ * @test
+ * @run testng jdk.nashorn.internal.runtime.test.JSTypeTest
+ */
+public class JSTypeTest {
+ /**
+ * Test of isPrimitive method, of class Runtime.
+ */
+ @Test
+ public void testIsPrimitive() {
+ assertTrue(JSType.isPrimitive(null));
+ assertTrue(JSType.isPrimitive(ScriptRuntime.UNDEFINED));
+ assertTrue(JSType.isPrimitive(Double.NaN));
+ assertTrue(JSType.isPrimitive(Double.NEGATIVE_INFINITY));
+ assertTrue(JSType.isPrimitive(Double.POSITIVE_INFINITY));
+ assertTrue(JSType.isPrimitive(0.0));
+ assertTrue(JSType.isPrimitive(3.14));
+ assertTrue(JSType.isPrimitive("hello"));
+ assertTrue(JSType.isPrimitive(""));
+ assertFalse(JSType.isPrimitive(new Object()));
+ }
+
+ /**
+ * Test of toBoolean method, of class Runtime.
+ */
+ @Test
+ public void testToBoolean() {
+ assertFalse(JSType.toBoolean(ScriptRuntime.UNDEFINED));
+ assertFalse(JSType.toBoolean(null));
+ assertFalse(JSType.toBoolean(Boolean.FALSE));
+ assertTrue(JSType.toBoolean(Boolean.TRUE));
+ assertFalse(JSType.toBoolean(-0.0));
+ assertFalse(JSType.toBoolean(0.0));
+ assertFalse(JSType.toBoolean(Double.NaN));
+ assertTrue(JSType.toBoolean(3.14));
+ assertFalse(JSType.toBoolean(""));
+ assertTrue(JSType.toBoolean("javascript"));
+ assertTrue(JSType.toBoolean(new Object()));
+ }
+
+ /**
+ * Test of toNumber method, of class Runtime.
+ */
+ @Test
+ public void testToNumber_Object() {
+ assertTrue(Double.isNaN(JSType.toNumber(ScriptRuntime.UNDEFINED)));
+ assertEquals(JSType.toNumber((Object)null), 0.0, 0.0);
+ assertEquals(JSType.toNumber(Boolean.TRUE), 1.0, 0.0);
+ assertEquals(JSType.toNumber(Boolean.FALSE), 0.0, 0.0);
+ assertEquals(JSType.toNumber(3.14), 3.14, 0.0);
+ // FIXME: add more assertions for specific String to number cases
+ // FIXME: add case for Object type (JSObject with getDefaultValue)
+ }
+
+ /**
+ * Test of toString method, of class Runtime.
+ */
+ @Test
+ public void testToString_Object() {
+ assertEquals(JSType.toString(ScriptRuntime.UNDEFINED), "undefined");
+ assertEquals(JSType.toString(null), "null");
+ assertEquals(JSType.toString(Boolean.TRUE), "true");
+ assertEquals(JSType.toString(Boolean.FALSE), "false");
+ assertEquals(JSType.toString(""), "");
+ assertEquals(JSType.toString("nashorn"), "nashorn");
+ assertEquals(JSType.toString(Double.NaN), "NaN");
+ assertEquals(JSType.toString(Double.POSITIVE_INFINITY), "Infinity");
+ assertEquals(JSType.toString(Double.NEGATIVE_INFINITY), "-Infinity");
+ assertEquals(JSType.toString(0.0), "0");
+ // FIXME: add more number-to-string test cases
+ // FIXME: add case for Object type (JSObject with getDefaultValue)
+ }
+
+ /**
+ * Test of JSType.toUint32(double)
+ */
+ @Test
+ public void testToUint32() {
+ assertEquals(JSType.toUint32(+0.0), 0);
+ assertEquals(JSType.toUint32(-0.0), 0);
+ assertEquals(JSType.toUint32(Double.NaN), 0);
+ assertEquals(JSType.toUint32(Double.POSITIVE_INFINITY), 0);
+ assertEquals(JSType.toUint32(Double.NEGATIVE_INFINITY), 0);
+ assertEquals(JSType.toUint32(9223372036854775807.0d), 0);
+ assertEquals(JSType.toUint32(-9223372036854775807.0d), 0);
+ assertEquals(JSType.toUint32(1099511627776.0d), 0);
+ assertEquals(JSType.toUint32(-1099511627776.0d), 0);
+ assertEquals(JSType.toUint32(4294967295.0d), 4294967295l);
+ assertEquals(JSType.toUint32(4294967296.0d), 0);
+ assertEquals(JSType.toUint32(4294967297.0d), 1);
+ assertEquals(JSType.toUint32(-4294967295.0d), 1);
+ assertEquals(JSType.toUint32(-4294967296.0d), 0);
+ assertEquals(JSType.toUint32(-4294967297.0d), 4294967295l);
+ assertEquals(JSType.toUint32(4294967295.6d), 4294967295l);
+ assertEquals(JSType.toUint32(4294967296.6d), 0);
+ assertEquals(JSType.toUint32(4294967297.6d), 1);
+ assertEquals(JSType.toUint32(-4294967295.6d), 1);
+ assertEquals(JSType.toUint32(-4294967296.6d), 0);
+ assertEquals(JSType.toUint32(-4294967297.6d), 4294967295l);
+ }
+
+ /**
+ * Test of JSType.toInt32(double)
+ */
+ @Test
+ public void testToInt32() {
+ assertEquals(JSType.toInt32(+0.0), 0);
+ assertEquals(JSType.toInt32(-0.0), 0);
+ assertEquals(JSType.toInt32(Double.NaN), 0);
+ assertEquals(JSType.toInt32(Double.POSITIVE_INFINITY), 0);
+ assertEquals(JSType.toInt32(Double.NEGATIVE_INFINITY), 0);
+ assertEquals(JSType.toInt32(9223372036854775807.0d), 0);
+ assertEquals(JSType.toInt32(-9223372036854775807.0d), 0);
+ assertEquals(JSType.toInt32(1099511627776.0d), 0);
+ assertEquals(JSType.toInt32(-1099511627776.0d), 0);
+ assertEquals(JSType.toInt32(4294967295.0d), -1);
+ assertEquals(JSType.toInt32(4294967296.0d), 0);
+ assertEquals(JSType.toInt32(4294967297.0d), 1);
+ assertEquals(JSType.toInt32(-4294967295.0d), 1);
+ assertEquals(JSType.toInt32(-4294967296.0d), 0);
+ assertEquals(JSType.toInt32(-4294967297.d), -1);
+ assertEquals(JSType.toInt32(4294967295.6d), -1);
+ assertEquals(JSType.toInt32(4294967296.6d), 0);
+ assertEquals(JSType.toInt32(4294967297.6d), 1);
+ assertEquals(JSType.toInt32(-4294967295.6d), 1);
+ assertEquals(JSType.toInt32(-4294967296.6d), 0);
+ assertEquals(JSType.toInt32(-4294967297.6d), -1);
+ }
+
+ /**
+ * Test of JSType.toUint16(double)
+ */
+ @Test
+ public void testToUint16() {
+ assertEquals(JSType.toUint16(+0.0), 0);
+ assertEquals(JSType.toUint16(-0.0), 0);
+ assertEquals(JSType.toUint16(Double.NaN), 0);
+ assertEquals(JSType.toUint16(Double.POSITIVE_INFINITY), 0);
+ assertEquals(JSType.toUint16(Double.NEGATIVE_INFINITY), 0);
+ assertEquals(JSType.toUint16(9223372036854775807.0d), 0);
+ assertEquals(JSType.toUint16(-9223372036854775807.0d), 0);
+ assertEquals(JSType.toUint16(1099511627776.0d), 0);
+ assertEquals(JSType.toUint16(-1099511627776.0d), 0);
+ assertEquals(JSType.toUint16(4294967295.0d), 65535);
+ assertEquals(JSType.toUint16(4294967296.0d), 0);
+ assertEquals(JSType.toUint16(4294967297.0d), 1);
+ assertEquals(JSType.toUint16(-4294967295.0d), 1);
+ assertEquals(JSType.toUint16(-4294967296.0d), 0);
+ assertEquals(JSType.toUint16(-4294967297.0d), 65535);
+ assertEquals(JSType.toUint16(4294967295.6d), 65535);
+ assertEquals(JSType.toUint16(4294967296.6d), 0);
+ assertEquals(JSType.toUint16(4294967297.6d), 1);
+ assertEquals(JSType.toUint16(-4294967295.6d), 1);
+ assertEquals(JSType.toUint16(-4294967296.6d), 0);
+ assertEquals(JSType.toUint16(-4294967297.6d), 65535);
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/internal/runtime/test/LexicalBindingTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,212 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.runtime.test;
+
+import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
+import org.testng.annotations.Test;
+
+import javax.script.Bindings;
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptException;
+import javax.script.SimpleScriptContext;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * Top-level lexical binding tests.
+ *
+ * @test
+ * @run testng jdk.nashorn.internal.runtime.test.LexicalBindingTest
+ */
+@SuppressWarnings("javadoc")
+public class LexicalBindingTest {
+
+ final static String LANGUAGE_ES6 = "--language=es6";
+ final static int NUMBER_OF_CONTEXTS = 20;
+ final static int MEGAMORPHIC_LOOP_COUNT = 20;
+
+ /**
+ * Test access to global var-declared variables for shared script classes with multiple globals.
+ */
+ @Test
+ public static void megamorphicVarTest() throws ScriptException, InterruptedException {
+ final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
+ final ScriptEngine e = factory.getScriptEngine();
+ final ScriptContext[] contexts = new ScriptContext[NUMBER_OF_CONTEXTS];
+ final String sharedScript = "foo";
+
+
+ for (int i = 0; i < NUMBER_OF_CONTEXTS; i++) {
+ final ScriptContext context = contexts[i] = new SimpleScriptContext();
+ final Bindings b = e.createBindings();
+ context.setBindings(b, ScriptContext.ENGINE_SCOPE);
+ assertEquals(e.eval("var foo = '" + i + "';", context), null);
+ }
+
+ for (int i = 0; i < NUMBER_OF_CONTEXTS; i++) {
+ final ScriptContext context = contexts[i];
+ assertEquals(e.eval(sharedScript, context), String.valueOf(i));
+ }
+ }
+
+ /**
+ * Test access to global lexically declared variables for shared script classes with multiple globals.
+ */
+ @Test
+ public static void megamorphicMultiGlobalLetTest() throws ScriptException, InterruptedException {
+ final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
+ final ScriptEngine e = factory.getScriptEngine(LANGUAGE_ES6);
+ final ScriptContext[] contexts = new ScriptContext[NUMBER_OF_CONTEXTS];
+ final String sharedScript = "foo";
+
+
+ for (int i = 0; i < NUMBER_OF_CONTEXTS; i++) {
+ final ScriptContext context = contexts[i] = new SimpleScriptContext();
+ final Bindings b = e.createBindings();
+ context.setBindings(b, ScriptContext.ENGINE_SCOPE);
+ assertEquals(e.eval("let foo = '" + i + "';", context), null);
+ }
+
+ for (int i = 0; i < NUMBER_OF_CONTEXTS; i++) {
+ final ScriptContext context = contexts[i];
+ assertEquals(e.eval(sharedScript, context), String.valueOf(i));
+ }
+ }
+
+
+ /**
+ * Test access to global lexically declared variables for shared script classes with single global.
+ */
+ @Test
+ public static void megamorphicSingleGlobalLetTest() throws ScriptException, InterruptedException {
+ final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
+ final ScriptEngine e = factory.getScriptEngine(LANGUAGE_ES6);
+ final String sharedGetterScript = "foo";
+ final String sharedSetterScript = "foo = 1";
+
+ for (int i = 0; i < MEGAMORPHIC_LOOP_COUNT; i++) {
+ assertEquals(e.eval(sharedSetterScript), 1);
+ assertEquals(e.eval(sharedGetterScript), 1);
+ assertEquals(e.eval("delete foo; a" + i + " = 1; foo = " + i + ";"), i);
+ assertEquals(e.eval(sharedGetterScript), i);
+ }
+
+ assertEquals(e.eval("let foo = 'foo';"), null);
+ assertEquals(e.eval(sharedGetterScript), "foo");
+ assertEquals(e.eval(sharedSetterScript), 1);
+ assertEquals(e.eval(sharedGetterScript), 1);
+ assertEquals(e.eval("this.foo"), MEGAMORPHIC_LOOP_COUNT - 1);
+ }
+
+ /**
+ * Test access to global lexically declared variables for shared script classes with single global.
+ */
+ @Test
+ public static void megamorphicInheritedGlobalLetTest() throws ScriptException, InterruptedException {
+ final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
+ final ScriptEngine e = factory.getScriptEngine(LANGUAGE_ES6);
+ final String sharedGetterScript = "foo";
+ final String sharedSetterScript = "foo = 1";
+
+ for (int i = 0; i < MEGAMORPHIC_LOOP_COUNT; i++) {
+ assertEquals(e.eval(sharedSetterScript), 1);
+ assertEquals(e.eval(sharedGetterScript), 1);
+ assertEquals(e.eval("delete foo; a" + i + " = 1; Object.prototype.foo = " + i + ";"), i);
+ assertEquals(e.eval(sharedGetterScript), i);
+ }
+
+ assertEquals(e.eval("let foo = 'foo';"), null);
+ assertEquals(e.eval(sharedGetterScript), "foo");
+ assertEquals(e.eval(sharedSetterScript), 1);
+ assertEquals(e.eval(sharedGetterScript), 1);
+ assertEquals(e.eval("this.foo"), MEGAMORPHIC_LOOP_COUNT - 1);
+ }
+
+ /**
+ * Test multi-threaded access to global lexically declared variables for shared script classes with multiple globals.
+ */
+ @Test
+ public static void multiThreadedLetTest() throws ScriptException, InterruptedException {
+ final NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
+ final ScriptEngine e = factory.getScriptEngine(LANGUAGE_ES6);
+ final Bindings b = e.createBindings();
+ final ScriptContext origContext = e.getContext();
+ final ScriptContext newCtxt = new SimpleScriptContext();
+ newCtxt.setBindings(b, ScriptContext.ENGINE_SCOPE);
+ final String sharedScript = "foo";
+
+ assertEquals(e.eval("let foo = 'original context';", origContext), null);
+ assertEquals(e.eval("let foo = 'new context';", newCtxt), null);
+
+ final Thread t1 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
+ final Thread t2 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "new context", 1000));
+ t1.start();
+ t2.start();
+ t1.join();
+ t2.join();
+
+ assertEquals(e.eval("foo = 'newer context';", newCtxt), "newer context");
+ final Thread t3 = new Thread(new ScriptRunner(e, origContext, sharedScript, "original context", 1000));
+ final Thread t4 = new Thread(new ScriptRunner(e, newCtxt, sharedScript, "newer context", 1000));
+
+ t3.start();
+ t4.start();
+ t3.join();
+ t4.join();
+
+ assertEquals(e.eval(sharedScript), "original context");
+ assertEquals(e.eval(sharedScript, newCtxt), "newer context");
+ }
+
+ private static class ScriptRunner implements Runnable {
+
+ final ScriptEngine engine;
+ final ScriptContext context;
+ final String source;
+ final Object expected;
+ final int iterations;
+
+ ScriptRunner(final ScriptEngine engine, final ScriptContext context, final String source, final Object expected, final int iterations) {
+ this.engine = engine;
+ this.context = context;
+ this.source = source;
+ this.expected = expected;
+ this.iterations = iterations;
+ }
+
+ @Override
+ public void run() {
+ try {
+ for (int i = 0; i < iterations; i++) {
+ assertEquals(engine.eval(source, context), expected);
+ }
+ } catch (final ScriptException se) {
+ throw new RuntimeException(se);
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/internal/runtime/test/NoPersistenceCachingTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.nashorn.internal.runtime.test;
+
+import static org.testng.Assert.fail;
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineFactory;
+import javax.script.ScriptEngineManager;
+import javax.script.SimpleScriptContext;
+import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+/**
+ * @test
+ * @bug 8037378
+ * @summary Sanity tests for no persistence caching
+ * @run testng/othervm jdk.nashorn.internal.runtime.test.NoPersistenceCachingTest
+ */
+@SuppressWarnings("javadoc")
+public class NoPersistenceCachingTest {
+
+ private ScriptEngine engine;
+ private ScriptContext context1, context2, context3;
+ private ByteArrayOutputStream stderr;
+ private PrintStream prevStderr;
+
+ @BeforeTest
+ public void setupTest() {
+ stderr = new ByteArrayOutputStream();
+ prevStderr = System.err;
+ System.setErr(new PrintStream(stderr));
+ NashornScriptEngineFactory nashornFactory = null;
+ final ScriptEngineManager sm = new ScriptEngineManager();
+ for (final ScriptEngineFactory fac : sm.getEngineFactories()) {
+ if (fac instanceof NashornScriptEngineFactory) {
+ nashornFactory = (NashornScriptEngineFactory) fac;
+ break;
+ }
+ }
+ if (nashornFactory == null) {
+ fail("Cannot find nashorn factory!");
+ }
+ // fine is enough for cache hits, finest produces way too much information
+ // TODO this should be ported to use the RuntimeEvents instead of screen scraping
+ // logs, as obviously this is very brittle
+ final String[] options = new String[]{"--log=compiler:fine"};
+ engine = nashornFactory.getScriptEngine(options);
+ context1 = engine.getContext();
+ context2 = new SimpleScriptContext();
+ context2.setBindings(engine.createBindings(), ScriptContext.ENGINE_SCOPE);
+ context3 = new SimpleScriptContext();
+ context3.setBindings(engine.createBindings(), ScriptContext.ENGINE_SCOPE);
+ }
+
+ @AfterTest
+ public void setErrTest() {
+ System.setErr(prevStderr);
+ }
+
+ public void runTest(final int numberOfContext, final String expectedOutputPattern,
+ final int expectedPatternOccurrence) {
+
+ try {
+ switch (numberOfContext) {
+ case 2:
+ final String scriptTwoContexts = "print('HelloTwoContexts')";
+ engine.eval(scriptTwoContexts, context1);
+ engine.eval(scriptTwoContexts, context2);
+ break;
+ case 3:
+ final String scriptThreeContexts = "print('HelloThreeContexts')";
+ engine.eval(scriptThreeContexts, context1);
+ engine.eval(scriptThreeContexts, context2);
+ engine.eval(scriptThreeContexts, context3);
+ break;
+ default:
+ break;
+ }
+ } catch (final Exception se) {
+ se.printStackTrace();
+ fail(se.getMessage());
+ }
+ final Pattern deoptimizing = Pattern.compile(expectedOutputPattern);
+ final Matcher matcher = deoptimizing.matcher(stderr.toString());
+ int matches = 0;
+ while (matcher.find()) {
+ matches++;
+ }
+ if (matches != expectedPatternOccurrence) {
+ fail("Number of cache hit is not correct, expected: "
+ + expectedPatternOccurrence + " and found: " + matches + "\n"
+ + stderr);
+ }
+ stderr.reset();
+ }
+
+ private static String getCodeCachePattern() {
+ return ("\\[compiler\\]\\sCode\\scache\\shit\\sfor\\s<eval>\\savoiding\\srecompile.");
+ }
+
+ @Test
+ public void twoContextTest() {
+ runTest(2, getCodeCachePattern(), 1);
+
+ }
+
+ @Test
+ public void threeContextTest() {
+ runTest(3, getCodeCachePattern(), 2);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/internal/runtime/test/SourceTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.runtime.test;
+
+import static jdk.nashorn.internal.runtime.Source.sourceFor;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.URL;
+import java.util.Arrays;
+import jdk.nashorn.api.scripting.URLReader;
+import jdk.nashorn.internal.runtime.Source;
+import org.testng.annotations.Test;
+
+/**
+ * Tests different Source representations.
+ */
+@SuppressWarnings("javadoc")
+public class SourceTest {
+
+ final private static String SOURCE_NAME = "source.js";
+ final private static String SOURCE_STRING = "var x = 1;";
+ final private static char[] SOURCE_CHARS = SOURCE_STRING.toCharArray();
+ final private static String RESOURCE_PATH = "resources/load_test.js";
+ final private static File SOURCE_FILE = new File("build/test/classes/jdk/nashorn/internal/runtime/test/" + RESOURCE_PATH);
+ final private static URL SOURCE_URL = SourceTest.class.getResource(RESOURCE_PATH);
+
+
+ @Test
+ public void testStringSource() {
+ testSources(sourceFor(SOURCE_NAME, SOURCE_STRING), sourceFor(SOURCE_NAME, SOURCE_STRING));
+ testSources(sourceFor(SOURCE_NAME, SOURCE_STRING), sourceFor(SOURCE_NAME, SOURCE_CHARS));
+ }
+
+ @Test
+ public void testCharArraySource() {
+ testSources(sourceFor(SOURCE_NAME, SOURCE_CHARS), sourceFor(SOURCE_NAME, SOURCE_CHARS));
+ testSources(sourceFor(SOURCE_NAME, SOURCE_CHARS), sourceFor(SOURCE_NAME, SOURCE_STRING));
+ }
+
+ @Test
+ public void testURLSource() {
+ try {
+ testSources(sourceFor(SOURCE_NAME, SOURCE_URL), sourceFor(SOURCE_NAME, SOURCE_URL));
+ testSources(sourceFor(SOURCE_NAME, SOURCE_URL), sourceFor(SOURCE_NAME, new URLReader(SOURCE_URL)));
+
+ } catch (final IOException e) {
+ fail(e.toString());
+ }
+ }
+
+ @Test
+ public void testURLReaderSource() {
+ try {
+ System.err.println(SourceTest.class.getResource(""));
+ testSources(sourceFor(SOURCE_NAME, new URLReader(SOURCE_URL)), sourceFor(SOURCE_NAME, new URLReader(SOURCE_URL)));
+ testSources(sourceFor(SOURCE_NAME, new URLReader(SOURCE_URL)), sourceFor(SOURCE_NAME, SOURCE_URL));
+ } catch (final IOException e) {
+ fail(e.toString());
+ }
+ }
+
+ @Test
+ public void testReaderSource() {
+ try {
+ testSources(sourceFor(SOURCE_NAME, getReader(RESOURCE_PATH)), sourceFor(SOURCE_NAME, getReader(RESOURCE_PATH)));
+ } catch (final IOException e) {
+ fail(e.toString());
+ }
+ }
+
+ @Test
+ public void testFileSource() {
+ try {
+ testSources(sourceFor(SOURCE_NAME, SOURCE_FILE), sourceFor(SOURCE_NAME, SOURCE_FILE));
+ } catch (final IOException e) {
+ fail(e.toString());
+ }
+ }
+
+ private static Reader getReader(final String path) {
+ return new InputStreamReader(SourceTest.class.getResourceAsStream(path));
+ }
+
+ private static void testSources(final Source source1, final Source source2) {
+ final char[] chars1 = source1.getContent();
+ final char[] chars2 = source2.getContent();
+ final String str1 = source1.getString();
+ final String str2 = source2.getString();
+ assertTrue(Arrays.equals(chars1, chars2));
+ assertEquals(str1, str2);
+ assertEquals(source1.hashCode(), source2.hashCode());
+ assertTrue(source1.equals(source2));
+ assertTrue(Arrays.equals(source1.getContent(), str1.toCharArray()));
+ assertTrue(Arrays.equals(source1.getContent(), chars1));
+ assertTrue(Arrays.equals(source1.getContent(), source2.getContent()));
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/internal/runtime/test/TrustedScriptEngineTest.java Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,363 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.runtime.test;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineFactory;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import javax.script.SimpleScriptContext;
+import jdk.nashorn.api.scripting.ClassFilter;
+import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
+import jdk.nashorn.internal.runtime.Version;
+import org.testng.annotations.Test;
+
+/**
+ * Tests for trusted client usage of nashorn script engine factory extension API
+ */
+@SuppressWarnings("javadoc")
+public class TrustedScriptEngineTest {
+ @Test
+ public void versionTest() {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ assertEquals(e.getFactory().getEngineVersion(), Version.version());
+ }
+
+ private static class MyClassLoader extends ClassLoader {
+ // to check if script engine uses the specified class loader
+ private final boolean[] reached = new boolean[1];
+
+ @Override
+ protected Class<?> findClass(final String name) throws ClassNotFoundException {
+ // flag that it reached here
+ reached[0] = true;
+ return super.findClass(name);
+ }
+
+ public boolean reached() {
+ return reached[0];
+ }
+ }
+
+ // These are for "private" extension API of NashornScriptEngineFactory that
+ // accepts a ClassLoader and/or command line options.
+
+ @Test
+ public void factoryClassLoaderTest() {
+ final ScriptEngineManager sm = new ScriptEngineManager();
+ for (final ScriptEngineFactory fac : sm.getEngineFactories()) {
+ if (fac instanceof NashornScriptEngineFactory) {
+ final NashornScriptEngineFactory nfac = (NashornScriptEngineFactory)fac;
+ final MyClassLoader loader = new MyClassLoader();
+ // set the classloader as app class loader
+ final ScriptEngine e = nfac.getScriptEngine(loader);
+ try {
+ e.eval("Packages.foo");
+ // check that the class loader was attempted
+ assertTrue(loader.reached(), "did not reach class loader!");
+ } catch (final ScriptException se) {
+ se.printStackTrace();
+ fail(se.getMessage());
+ }
+ return;
+ }
+ }
+
+ fail("Cannot find nashorn factory!");
+ }
+
+ @Test
+ public void factoryClassLoaderAndOptionsTest() {
+ final ScriptEngineManager sm = new ScriptEngineManager();
+ for (final ScriptEngineFactory fac : sm.getEngineFactories()) {
+ if (fac instanceof NashornScriptEngineFactory) {
+ final NashornScriptEngineFactory nfac = (NashornScriptEngineFactory)fac;
+ final String[] options = new String[] { "-strict" };
+ final MyClassLoader loader = new MyClassLoader();
+ // set the classloader as app class loader
+ final ScriptEngine e = nfac.getScriptEngine(options, loader);
+ try {
+ e.eval("Packages.foo");
+ // check that the class loader was attempted
+ assertTrue(loader.reached(), "did not reach class loader!");
+ } catch (final ScriptException se) {
+ se.printStackTrace();
+ fail(se.getMessage());
+ }
+
+ try {
+ // strict mode - delete of a var should throw SyntaxError
+ e.eval("var d = 2; delete d;");
+ } catch (final ScriptException se) {
+ // check that the error message contains "SyntaxError"
+ assertTrue(se.getMessage().contains("SyntaxError"));
+ }
+
+ return;
+ }
+ }
+
+ fail("Cannot find nashorn factory!");
+ }
+
+ @Test
+ public void factoryOptionsTest() {
+ final ScriptEngineManager sm = new ScriptEngineManager();
+ for (final ScriptEngineFactory fac : sm.getEngineFactories()) {
+ if (fac instanceof NashornScriptEngineFactory) {
+ final NashornScriptEngineFactory nfac = (NashornScriptEngineFactory)fac;
+ // specify --no-syntax-extensions flag
+ final String[] options = new String[] { "--no-syntax-extensions" };
+ final ScriptEngine e = nfac.getScriptEngine(options);
+ try {
+ // try nashorn specific extension
+ e.eval("var f = funtion(x) 2*x;");
+ fail("should have thrown exception!");
+ } catch (final Exception ex) {
+ //empty
+ }
+ return;
+ }
+ }
+
+ fail("Cannot find nashorn factory!");
+ }
+
+ @Test
+ /**
+ * Test repeated evals with --loader-per-compile=false
+ * We used to get "class redefinition error".
+ */
+ public void noLoaderPerCompilerTest() {
+ final ScriptEngineManager sm = new ScriptEngineManager();
+ for (final ScriptEngineFactory fac : sm.getEngineFactories()) {
+ if (fac instanceof NashornScriptEngineFactory) {
+ final NashornScriptEngineFactory nfac = (NashornScriptEngineFactory)fac;
+ final String[] options = new String[] { "--loader-per-compile=false" };
+ final ScriptEngine e = nfac.getScriptEngine(options);
+ try {
+ e.eval("2 + 3");
+ e.eval("4 + 4");
+ } catch (final ScriptException se) {
+ se.printStackTrace();
+ fail(se.getMessage());
+ }
+ return;
+ }
+ }
+ fail("Cannot find nashorn factory!");
+ }
+
+ @Test
+ /**
+ * Test that we can use same script name in repeated evals with --loader-per-compile=false
+ * We used to get "class redefinition error" as name was derived from script name.
+ */
+ public void noLoaderPerCompilerWithSameNameTest() {
+ final ScriptEngineManager sm = new ScriptEngineManager();
+ for (final ScriptEngineFactory fac : sm.getEngineFactories()) {
+ if (fac instanceof NashornScriptEngineFactory) {
+ final NashornScriptEngineFactory nfac = (NashornScriptEngineFactory)fac;
+ final String[] options = new String[] { "--loader-per-compile=false" };
+ final ScriptEngine e = nfac.getScriptEngine(options);
+ e.put(ScriptEngine.FILENAME, "test.js");
+ try {
+ e.eval("2 + 3");
+ e.eval("4 + 4");
+ } catch (final ScriptException se) {
+ se.printStackTrace();
+ fail(se.getMessage());
+ }
+ return;
+ }
+ }
+ fail("Cannot find nashorn factory!");
+ }
+
+ @Test
+ public void globalPerEngineTest() throws ScriptException {
+ final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
+ final String[] options = new String[] { "--global-per-engine" };
+ final ScriptEngine e = fac.getScriptEngine(options);
+
+ e.eval("function foo() {}");
+
+ final ScriptContext newCtx = new SimpleScriptContext();
+ newCtx.setBindings(e.createBindings(), ScriptContext.ENGINE_SCOPE);
+
+ // all global definitions shared and so 'foo' should be
+ // visible in new Bindings as well.
+ assertTrue(e.eval("typeof foo", newCtx).equals("function"));
+
+ e.eval("function bar() {}", newCtx);
+
+ // bar should be visible in default context
+ assertTrue(e.eval("typeof bar").equals("function"));
+ }
+
+ @Test
+ public void classFilterTest() throws ScriptException {
+ final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
+ final ScriptEngine e = fac.getScriptEngine(new ClassFilter() {
+ @Override
+ public boolean exposeToScripts(final String fullName) {
+ // don't allow anything that is not "java."
+ return fullName.startsWith("java.");
+ }
+ });
+
+ assertEquals(e.eval("typeof javax.script.ScriptEngine"), "object");
+ assertEquals(e.eval("typeof java.util.Vector"), "function");
+
+ try {
+ e.eval("Java.type('javax.script.ScriptContext')");
+ fail("should not reach here");
+ } catch (final ScriptException | RuntimeException se) {
+ if (! (se.getCause() instanceof ClassNotFoundException)) {
+ fail("ClassNotFoundException expected");
+ }
+ }
+ }
+
+ @Test
+ public void classFilterTest2() throws ScriptException {
+ final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
+ final ScriptEngine e = fac.getScriptEngine(new String[0], Thread.currentThread().getContextClassLoader(),
+ new ClassFilter() {
+ @Override
+ public boolean exposeToScripts(final String fullName) {
+ // don't allow anything that is not "java."
+ return fullName.startsWith("java.");
+ }
+ });
+
+ assertEquals(e.eval("typeof javax.script.ScriptEngine"), "object");
+ assertEquals(e.eval("typeof java.util.Vector"), "function");
+
+ try {
+ e.eval("Java.type('javax.script.ScriptContext')");
+ fail("should not reach here");
+ } catch (final ScriptException | RuntimeException se) {
+ if (! (se.getCause() instanceof ClassNotFoundException)) {
+ fail("ClassNotFoundException expected");
+ }
+ }
+ }
+
+ @Test
+ public void nullClassFilterTest() {
+ final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
+ try {
+ fac.getScriptEngine((ClassFilter)null);
+ fail("should have thrown NPE");
+ } catch (final NullPointerException e) {
+ //empty
+ }
+ }
+
+ @Test
+ public void nullClassFilterTest2() {
+ final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
+ try {
+ fac.getScriptEngine(new String[0], null, null);
+ fail("should have thrown NPE");
+ } catch (final NullPointerException e) {
+ //empty
+ }
+ }
+
+ @Test
+ public void nullArgsTest() {
+ final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
+ try {
+ fac.getScriptEngine((String[])null);
+ fail("should have thrown NPE");
+ } catch (final NullPointerException e) {
+ //empty
+ }
+ }
+
+ @Test
+ public void nullArgsTest2() {
+ final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
+ try {
+ fac.getScriptEngine(null, null, new ClassFilter() {
+ @Override
+ public boolean exposeToScripts(final String name) {
+ return true;
+ }
+ });
+ fail("should have thrown NPE");
+ } catch (final NullPointerException e) {
+ //empty
+ }
+ }
+
+ @Test
+ public void nashornSwallowsConstKeyword() throws Exception {
+ final NashornScriptEngineFactory f = new NashornScriptEngineFactory();
+ final String[] args = new String[] { "--const-as-var" };
+ final ScriptEngine engine = f.getScriptEngine(args);
+
+ final Object ret = engine.eval(""
+ + "(function() {\n"
+ + " const x = 10;\n"
+ + " return x;\n"
+ + "})();"
+ );
+ assertEquals(ret, 10, "Parsed and executed OK");
+ }
+
+ @Test
+ public void evalDefaultFileNameTest() throws ScriptException {
+ final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
+ final ScriptEngine engine = fac.getScriptEngine(new String[] { "--verify-code=true" });
+ // default FILENAME being "<eval>" make sure generated code bytecode verifies.
+ engine.eval("var a = 3;");
+ }
+
+ @Test
+ public void evalFileNameWithSpecialCharsTest() throws ScriptException {
+ final NashornScriptEngineFactory fac = new NashornScriptEngineFactory();
+ final ScriptEngine engine = fac.getScriptEngine(new String[] { "--verify-code=true" });
+ final ScriptContext ctxt = new SimpleScriptContext();
+ // use file name with "dangerous" chars.
+ ctxt.setAttribute(ScriptEngine.FILENAME, "<myscript>", ScriptContext.ENGINE_SCOPE);
+ engine.eval("var a = 3;");
+ ctxt.setAttribute(ScriptEngine.FILENAME, "[myscript]", ScriptContext.ENGINE_SCOPE);
+ engine.eval("var h = 'hello';");
+ ctxt.setAttribute(ScriptEngine.FILENAME, ";/\\$.", ScriptContext.ENGINE_SCOPE);
+ engine.eval("var foo = 'world';");
+ // name used by jjs shell tool for the interactive mode
+ ctxt.setAttribute(ScriptEngine.FILENAME, "<shell>", ScriptContext.ENGINE_SCOPE);
+ engine.eval("var foo = 'world';");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/internal/runtime/test/resources/load_test.js Tue Apr 14 12:10:00 2015 -0700
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+function loadedFunc(arg) {
+ return arg.toUpperCase();
+}