diff --git a/.hgtags b/.hgtags index cb3ba5ed43e..db502a72772 100644 --- a/.hgtags +++ b/.hgtags @@ -269,3 +269,5 @@ c5495e25c7258ab5f96a1ae14610887d76d2be63 jdk9-b18 d9ce05f36ffec3e5e8af62a92455c1c66a63c320 jdk9-b24 13a5c76976fe48e55c9727c25fae2d2ce7c05da0 jdk9-b25 cd6f4557e7fea5799ff3762ed7a80a743e75d5fd jdk9-b26 +d06a6d3c66c08293b2a9650f3cc01fd55c620e65 jdk9-b27 +f4269e8f454eb77763ecee228a88ae102a9aef6e jdk9-b28 diff --git a/.hgtags-top-repo b/.hgtags-top-repo index d0fc930890e..b1a11dc3634 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -269,3 +269,5 @@ ee4fd72b2ec3d92497f37163352f294aa695c6fb jdk9-b20 1d4a293fbec19dc2d5790bbb2c7dd0ed8f265484 jdk9-b24 aefd8899a8d6615fb34ba99b2e38996a7145baa8 jdk9-b25 d3ec8d048e6c3c46b6e0ee011cc551ad386dfba5 jdk9-b26 +ba5645f2735b41ed085d07ba20fa7b322afff318 jdk9-b27 +ea2f7981236f3812436958748ab3d26e80a35130 jdk9-b28 diff --git a/Makefile b/Makefile index 1e574940964..6827fd615f3 100644 --- a/Makefile +++ b/Makefile @@ -136,10 +136,12 @@ help: $(info . make docs # Create all docs) $(info . make docs-javadoc # Create just javadocs, depends on less than full docs) $(info . make profiles # Create complete j2re compact profile images) - $(info . make bootcycle-images # Build images twice, second time with newly build JDK) + $(info . make bootcycle-images # Build images twice, second time with newly built JDK) $(info . make install # Install the generated images locally) $(info . make clean # Remove all files generated by make, but not those) - $(info . # generated by configure) + $(info . # generated by configure. Do not run clean and other) + $(info . # targets together as that might behave in an) + $(info . # unexpected way.) $(info . make dist-clean # Remove all files, including configuration) $(info . make help # Give some help on using make) $(info . make test # Run tests, default is all tests (see TEST below)) diff --git a/common/autoconf/basics.m4 b/common/autoconf/basics.m4 index 79d54a231ee..1a8cb100d94 100644 --- a/common/autoconf/basics.m4 +++ b/common/autoconf/basics.m4 @@ -377,7 +377,6 @@ AC_DEFUN_ONCE([BASIC_SETUP_FUNDAMENTAL_TOOLS], BASIC_REQUIRE_PROGS(CMP, cmp) BASIC_REQUIRE_PROGS(COMM, comm) BASIC_REQUIRE_PROGS(CP, cp) - BASIC_REQUIRE_PROGS(CPIO, cpio) BASIC_REQUIRE_PROGS(CUT, cut) BASIC_REQUIRE_PROGS(DATE, date) BASIC_REQUIRE_PROGS(DIFF, [gdiff diff]) @@ -427,6 +426,7 @@ AC_DEFUN_ONCE([BASIC_SETUP_FUNDAMENTAL_TOOLS], BASIC_PATH_PROGS(READLINK, [greadlink readlink]) BASIC_PATH_PROGS(DF, df) BASIC_PATH_PROGS(SETFILE, SetFile) + BASIC_PATH_PROGS(CPIO, [cpio bsdcpio]) ]) # Setup basic configuration paths, and platform-specific stuff related to PATHs. @@ -849,7 +849,12 @@ AC_DEFUN([BASIC_CHECK_FIND_DELETE], if test -f $DELETEDIR/TestIfFindSupportsDelete; then # No, it does not. rm $DELETEDIR/TestIfFindSupportsDelete - FIND_DELETE="-exec rm \{\} \+" + if test "x$OPENJDK_TARGET_OS" = "xaix"; then + # AIX 'find' is buggy if called with '-exec {} \+' and an empty file list + FIND_DELETE="-print | xargs rm" + else + FIND_DELETE="-exec rm \{\} \+" + fi AC_MSG_RESULT([no]) else AC_MSG_RESULT([yes]) @@ -954,7 +959,7 @@ AC_DEFUN([BASIC_CHECK_DIR_ON_LOCAL_DISK], # not be the case in cygwin in certain conditions. AC_DEFUN_ONCE([BASIC_CHECK_SRC_PERMS], [ - if test x"$OPENJDK_BUILD_OS" = xwindows; then + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then file_to_test="$SRC_ROOT/LICENSE" if test `$STAT -c '%a' "$file_to_test"` -lt 400; then AC_MSG_ERROR([Bad file permissions on src files. This is usually caused by cloning the repositories with a non cygwin hg in a directory not created in cygwin.]) diff --git a/common/autoconf/basics_windows.m4 b/common/autoconf/basics_windows.m4 index 0d43553fd95..1bcb6151486 100644 --- a/common/autoconf/basics_windows.m4 +++ b/common/autoconf/basics_windows.m4 @@ -266,6 +266,14 @@ AC_DEFUN([BASIC_FIXUP_EXECUTABLE_MSYS], BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(new_path) new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in MSYS causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path="$path" + BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(new_path) + fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. diff --git a/common/autoconf/boot-jdk.m4 b/common/autoconf/boot-jdk.m4 index 872e33fb609..fbfa15c7b06 100644 --- a/common/autoconf/boot-jdk.m4 +++ b/common/autoconf/boot-jdk.m4 @@ -370,18 +370,27 @@ AC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK_ARGUMENTS], # Maximum amount of heap memory. # Maximum stack size. + JVM_MAX_HEAP=`expr $MEMORY_SIZE / 2` if test "x$BUILD_NUM_BITS" = x32; then - JVM_MAX_HEAP=1100M + if test "$JVM_MAX_HEAP" -gt "1100"; then + JVM_MAX_HEAP=1100 + elif test "$JVM_MAX_HEAP" -lt "512"; then + JVM_MAX_HEAP=512 + fi STACK_SIZE=768 else # Running Javac on a JVM on a 64-bit machine, takes more space since 64-bit # pointers are used. Apparently, we need to increase the heap and stack # space for the jvm. More specifically, when running javac to build huge # jdk batch - JVM_MAX_HEAP=1600M + if test "$JVM_MAX_HEAP" -gt "1600"; then + JVM_MAX_HEAP=1600 + elif test "$JVM_MAX_HEAP" -lt "512"; then + JVM_MAX_HEAP=512 + fi STACK_SIZE=1536 fi - ADD_JVM_ARG_IF_OK([-Xmx$JVM_MAX_HEAP],boot_jdk_jvmargs_big,[$JAVA]) + ADD_JVM_ARG_IF_OK([-Xmx${JVM_MAX_HEAP}M],boot_jdk_jvmargs_big,[$JAVA]) ADD_JVM_ARG_IF_OK([-XX:ThreadStackSize=$STACK_SIZE],boot_jdk_jvmargs_big,[$JAVA]) AC_MSG_RESULT([$boot_jdk_jvmargs_big]) diff --git a/common/autoconf/build-performance.m4 b/common/autoconf/build-performance.m4 index 7d4b8abb8da..8425d744990 100644 --- a/common/autoconf/build-performance.m4 +++ b/common/autoconf/build-performance.m4 @@ -131,8 +131,8 @@ AC_DEFUN_ONCE([BPERF_SETUP_BUILD_JOBS], if test "x$with_jobs" = x; then # Number of jobs was not specified, calculate. AC_MSG_CHECKING([for appropriate number of jobs to run in parallel]) - # Approximate memory in GB, rounding up a bit. - memory_gb=`expr $MEMORY_SIZE / 1100` + # Approximate memory in GB. + memory_gb=`expr $MEMORY_SIZE / 1024` # Pick the lowest of memory in gb and number of cores. if test "$memory_gb" -lt "$NUM_CORES"; then JOBS="$memory_gb" @@ -291,16 +291,11 @@ AC_DEFUN_ONCE([BPERF_SETUP_SMART_JAVAC], AC_MSG_ERROR([Could not execute server java: $SJAVAC_SERVER_JAVA]) fi else - SJAVAC_SERVER_JAVA="" - # Hotspot specific options. - ADD_JVM_ARG_IF_OK([-verbosegc],SJAVAC_SERVER_JAVA,[$JAVA]) - # JRockit specific options. - ADD_JVM_ARG_IF_OK([-Xverbose:gc],SJAVAC_SERVER_JAVA,[$JAVA]) - SJAVAC_SERVER_JAVA="$JAVA $SJAVAC_SERVER_JAVA" + SJAVAC_SERVER_JAVA="$JAVA" fi AC_SUBST(SJAVAC_SERVER_JAVA) - if test "$MEMORY_SIZE" -gt "2500"; then + if test "$MEMORY_SIZE" -gt "3000"; then ADD_JVM_ARG_IF_OK([-d64],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) if test "$JVM_ARG_OK" = true; then JVM_64BIT=true @@ -308,34 +303,33 @@ AC_DEFUN_ONCE([BPERF_SETUP_SMART_JAVAC], fi fi + MX_VALUE=`expr $MEMORY_SIZE / 2` if test "$JVM_64BIT" = true; then - if test "$MEMORY_SIZE" -gt "17000"; then - ADD_JVM_ARG_IF_OK([-Xms10G -Xmx10G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) + # Set ms lower than mx since more than one instance of the server might + # get launched at the same time before they figure out which instance won. + MS_VALUE=512 + if test "$MX_VALUE" -gt "2048"; then + MX_VALUE=2048 fi - if test "$MEMORY_SIZE" -gt "10000" && test "$JVM_ARG_OK" = false; then - ADD_JVM_ARG_IF_OK([-Xms6G -Xmx6G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) - fi - if test "$MEMORY_SIZE" -gt "5000" && test "$JVM_ARG_OK" = false; then - ADD_JVM_ARG_IF_OK([-Xms1G -Xmx3G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) - fi - if test "$MEMORY_SIZE" -gt "3800" && test "$JVM_ARG_OK" = false; then - ADD_JVM_ARG_IF_OK([-Xms1G -Xmx2500M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) + else + MS_VALUE=256 + if test "$MX_VALUE" -gt "1500"; then + MX_VALUE=1500 fi fi - if test "$MEMORY_SIZE" -gt "2500" && test "$JVM_ARG_OK" = false; then - ADD_JVM_ARG_IF_OK([-Xms1000M -Xmx1500M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) - fi - if test "$MEMORY_SIZE" -gt "1000" && test "$JVM_ARG_OK" = false; then - ADD_JVM_ARG_IF_OK([-Xms400M -Xmx1100M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) - fi - if test "$JVM_ARG_OK" = false; then - ADD_JVM_ARG_IF_OK([-Xms256M -Xmx512M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) + if test "$MX_VALUE" -lt "512"; then + MX_VALUE=512 fi + ADD_JVM_ARG_IF_OK([-Xms${MS_VALUE}M -Xmx${MX_VALUE}M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) - AC_MSG_CHECKING([whether to use sjavac]) AC_ARG_ENABLE([sjavac], [AS_HELP_STRING([--enable-sjavac], [use sjavac to do fast incremental compiles @<:@disabled@:>@])], [ENABLE_SJAVAC="${enableval}"], [ENABLE_SJAVAC='no']) + if test "x$JVM_ARG_OK" = "xfalse"; then + AC_MSG_WARN([Could not set -Xms${MS_VALUE}M -Xmx${MX_VALUE}M, disabling sjavac]) + ENABLE_SJAVAC=no; + fi + AC_MSG_CHECKING([whether to use sjavac]) AC_MSG_RESULT([$ENABLE_SJAVAC]) AC_SUBST(ENABLE_SJAVAC) diff --git a/common/autoconf/configure.ac b/common/autoconf/configure.ac index ec0d7490d59..ca373c859f1 100644 --- a/common/autoconf/configure.ac +++ b/common/autoconf/configure.ac @@ -142,7 +142,6 @@ JDKOPT_SETUP_JDK_VERSION_NUMBERS ############################################################################### BOOTJDK_SETUP_BOOT_JDK -BOOTJDK_SETUP_BOOT_JDK_ARGUMENTS ############################################################################### # @@ -233,6 +232,9 @@ BPERF_SETUP_BUILD_CORES BPERF_SETUP_BUILD_MEMORY BPERF_SETUP_BUILD_JOBS +# Setup arguments for the boot jdk (after cores and memory have been setup) +BOOTJDK_SETUP_BOOT_JDK_ARGUMENTS + # Setup smart javac (after cores and memory have been setup) BPERF_SETUP_SMART_JAVAC diff --git a/common/autoconf/flags.m4 b/common/autoconf/flags.m4 index 6f69f0c53a2..7a62d93ea7f 100644 --- a/common/autoconf/flags.m4 +++ b/common/autoconf/flags.m4 @@ -342,17 +342,15 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION], # no adjustment ;; fastdebug ) - # Add compile time bounds checks. - CFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1" - CXXFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1" + # no adjustment ;; slowdebug ) - # Add runtime bounds checks and symbol info. - CFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-all --param ssp-buffer-size=1" - CXXFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-all --param ssp-buffer-size=1" + # Add runtime stack smashing and undefined behavior checks + CFLAGS_DEBUG_OPTIONS="-fstack-protector-all --param ssp-buffer-size=1" + CXXFLAGS_DEBUG_OPTIONS="-fstack-protector-all --param ssp-buffer-size=1" if test "x$HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR" = "xtrue"; then CFLAGS_DEBUG_OPTIONS="$CFLAGS_DEBUG_OPTIONS $CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG" - CXXFLAGS_DEBUG_OPTIONS="$CXXFLAGS_DEBUG_OPTIONS $CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG" + CXXFLAGS_DEBUG_OPTIONS="$CXXFLAGS_DEBUG_OPTIONS $CFLAG_DETECT_UNDEFINED_BEHAVIsOR_FLAG" fi ;; esac @@ -900,7 +898,7 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_MISC], case "${TOOLCHAIN_TYPE}" in microsoft) - CFLAGS_WARNINGS_ARE_ERRORS="/WX" + CFLAGS_WARNINGS_ARE_ERRORS="-WX" ;; solstudio) CFLAGS_WARNINGS_ARE_ERRORS="-errtags -errwarn=%all" diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 5b044dc241d..d24edd39c20 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -634,6 +634,10 @@ USE_PRECOMPILED_HEADER SJAVAC_SERVER_DIR ENABLE_SJAVAC SJAVAC_SERVER_JAVA +JAVA_TOOL_FLAGS_SMALL +JAVA_FLAGS_SMALL +JAVA_FLAGS_BIG +JAVA_FLAGS JOBS MEMORY_SIZE NUM_CORES @@ -805,10 +809,6 @@ JAXWS_TOPDIR JAXP_TOPDIR CORBA_TOPDIR LANGTOOLS_TOPDIR -JAVA_TOOL_FLAGS_SMALL -JAVA_FLAGS_SMALL -JAVA_FLAGS_BIG -JAVA_FLAGS JAVAC_FLAGS BOOT_JDK_SOURCETARGET JARSIGNER @@ -920,12 +920,14 @@ OPENJDK_TARGET_CPU_ENDIAN OPENJDK_TARGET_CPU_BITS OPENJDK_TARGET_CPU_ARCH OPENJDK_TARGET_CPU +OPENJDK_TARGET_OS_ENV OPENJDK_TARGET_OS_API OPENJDK_TARGET_OS OPENJDK_BUILD_CPU_ENDIAN OPENJDK_BUILD_CPU_BITS OPENJDK_BUILD_CPU_ARCH OPENJDK_BUILD_CPU +OPENJDK_BUILD_OS_ENV OPENJDK_BUILD_OS_API OPENJDK_BUILD_OS OPENJDK_BUILD_AUTOCONF_NAME @@ -942,6 +944,7 @@ build_os build_vendor build_cpu build +CPIO SETFILE DF READLINK @@ -980,7 +983,6 @@ DIRNAME DIFF DATE CUT -CPIO CP COMM CMP @@ -1062,7 +1064,6 @@ with_update_version with_user_release_suffix with_build_number with_boot_jdk -with_boot_jdk_jvmargs with_add_source_root with_override_source_root with_adds_and_overrides @@ -1104,6 +1105,7 @@ with_dxsdk_include with_num_cores with_memory_size with_jobs +with_boot_jdk_jvmargs with_sjavac_server_java enable_sjavac enable_precompiled_headers @@ -1120,7 +1122,6 @@ CHMOD CMP COMM CP -CPIO CUT DATE DIFF @@ -1159,6 +1160,7 @@ CYGPATH READLINK DF SETFILE +CPIO UNZIP ZIP LDD @@ -1902,10 +1904,6 @@ Optional Packages: number is not set.[username_builddateb00] --with-build-number Set build number value for build [b00] --with-boot-jdk path to Boot JDK (used to bootstrap build) [probed] - --with-boot-jdk-jvmargs specify JVM arguments to be passed to all java - invocations of boot JDK, overriding the default - values, e.g --with-boot-jdk-jvmargs="-Xmx8G - -enableassertions" --with-add-source-root for each and every source directory, look in this additional source root for the same directory; if it exists and have files in it, include it in the build @@ -1977,6 +1975,10 @@ Optional Packages: --with-memory-size=1024 [probed] --with-jobs number of parallel jobs to let make run [calculated based on cores and memory] + --with-boot-jdk-jvmargs specify JVM arguments to be passed to all java + invocations of boot JDK, overriding the default + values, e.g --with-boot-jdk-jvmargs="-Xmx8G + -enableassertions" --with-sjavac-server-java use this java binary for running the sjavac background server [Boot JDK java] @@ -1990,7 +1992,6 @@ Some influential environment variables: CMP Override default value for CMP COMM Override default value for COMM CP Override default value for CP - CPIO Override default value for CPIO CUT Override default value for CUT DATE Override default value for DATE DIFF Override default value for DIFF @@ -2029,6 +2030,7 @@ Some influential environment variables: READLINK Override default value for READLINK DF Override default value for DF SETFILE Override default value for SETFILE + CPIO Override default value for CPIO UNZIP Override default value for UNZIP ZIP Override default value for ZIP LDD Override default value for LDD @@ -4319,7 +4321,7 @@ TOOLCHAIN_DESCRIPTION_xlc="IBM XL C/C++" #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1407143049 +DATE_WHEN_GENERATED=1409311712 ############################################################################### # @@ -5721,199 +5723,6 @@ $as_echo "$tool_specified" >&6; } - # Publish this variable in the help. - - - if test "x$CPIO" = x; then - # The variable is not set by user, try to locate tool using the code snippet - for ac_prog in cpio -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CPIO+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $CPIO in - [\\/]* | ?:[\\/]*) - ac_cv_path_CPIO="$CPIO" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_CPIO="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - ;; -esac -fi -CPIO=$ac_cv_path_CPIO -if test -n "$CPIO"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPIO" >&5 -$as_echo "$CPIO" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$CPIO" && break -done - - else - # The variable is set, but is it from the command line or the environment? - - # Try to remove the string !CPIO! from our list. - try_remove_var=${CONFIGURE_OVERRIDDEN_VARIABLES//!CPIO!/} - if test "x$try_remove_var" = "x$CONFIGURE_OVERRIDDEN_VARIABLES"; then - # If it failed, the variable was not from the command line. Ignore it, - # but warn the user (except for BASH, which is always set by the calling BASH). - if test "xCPIO" != xBASH; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring value of CPIO from the environment. Use command line variables instead." >&5 -$as_echo "$as_me: WARNING: Ignoring value of CPIO from the environment. Use command line variables instead." >&2;} - fi - # Try to locate tool using the code snippet - for ac_prog in cpio -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CPIO+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $CPIO in - [\\/]* | ?:[\\/]*) - ac_cv_path_CPIO="$CPIO" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_CPIO="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - ;; -esac -fi -CPIO=$ac_cv_path_CPIO -if test -n "$CPIO"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPIO" >&5 -$as_echo "$CPIO" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$CPIO" && break -done - - else - # If it succeeded, then it was overridden by the user. We will use it - # for the tool. - - # First remove it from the list of overridden variables, so we can test - # for unknown variables in the end. - CONFIGURE_OVERRIDDEN_VARIABLES="$try_remove_var" - - # Check if the provided tool contains a complete path. - tool_specified="$CPIO" - tool_basename="${tool_specified##*/}" - if test "x$tool_basename" = "x$tool_specified"; then - # A command without a complete path is provided, search $PATH. - { $as_echo "$as_me:${as_lineno-$LINENO}: Will search for user supplied tool CPIO=$tool_basename" >&5 -$as_echo "$as_me: Will search for user supplied tool CPIO=$tool_basename" >&6;} - # Extract the first word of "$tool_basename", so it can be a program name with args. -set dummy $tool_basename; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path_CPIO+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $CPIO in - [\\/]* | ?:[\\/]*) - ac_cv_path_CPIO="$CPIO" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path_CPIO="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - ;; -esac -fi -CPIO=$ac_cv_path_CPIO -if test -n "$CPIO"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPIO" >&5 -$as_echo "$CPIO" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - if test "x$CPIO" = x; then - as_fn_error $? "User supplied tool $tool_basename could not be found" "$LINENO" 5 - fi - else - # Otherwise we believe it is a complete path. Use it as it is. - { $as_echo "$as_me:${as_lineno-$LINENO}: Will use user supplied tool CPIO=$tool_specified" >&5 -$as_echo "$as_me: Will use user supplied tool CPIO=$tool_specified" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for CPIO" >&5 -$as_echo_n "checking for CPIO... " >&6; } - if test ! -x "$tool_specified"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 -$as_echo "not found" >&6; } - as_fn_error $? "User supplied tool CPIO=$tool_specified does not exist or is not executable" "$LINENO" 5 - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tool_specified" >&5 -$as_echo "$tool_specified" >&6; } - fi - fi - fi - - - - if test "x$CPIO" = x; then - as_fn_error $? "Could not find required tool for CPIO" "$LINENO" 5 - fi - - - - - # Publish this variable in the help. @@ -13386,6 +13195,192 @@ $as_echo "$tool_specified" >&6; } + # Publish this variable in the help. + + + if test "x$CPIO" = x; then + # The variable is not set by user, try to locate tool using the code snippet + for ac_prog in cpio bsdcpio +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_CPIO+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $CPIO in + [\\/]* | ?:[\\/]*) + ac_cv_path_CPIO="$CPIO" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_CPIO="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +CPIO=$ac_cv_path_CPIO +if test -n "$CPIO"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPIO" >&5 +$as_echo "$CPIO" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CPIO" && break +done + + else + # The variable is set, but is it from the command line or the environment? + + # Try to remove the string !CPIO! from our list. + try_remove_var=${CONFIGURE_OVERRIDDEN_VARIABLES//!CPIO!/} + if test "x$try_remove_var" = "x$CONFIGURE_OVERRIDDEN_VARIABLES"; then + # If it failed, the variable was not from the command line. Ignore it, + # but warn the user (except for BASH, which is always set by the calling BASH). + if test "xCPIO" != xBASH; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring value of CPIO from the environment. Use command line variables instead." >&5 +$as_echo "$as_me: WARNING: Ignoring value of CPIO from the environment. Use command line variables instead." >&2;} + fi + # Try to locate tool using the code snippet + for ac_prog in cpio bsdcpio +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_CPIO+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $CPIO in + [\\/]* | ?:[\\/]*) + ac_cv_path_CPIO="$CPIO" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_CPIO="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +CPIO=$ac_cv_path_CPIO +if test -n "$CPIO"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPIO" >&5 +$as_echo "$CPIO" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CPIO" && break +done + + else + # If it succeeded, then it was overridden by the user. We will use it + # for the tool. + + # First remove it from the list of overridden variables, so we can test + # for unknown variables in the end. + CONFIGURE_OVERRIDDEN_VARIABLES="$try_remove_var" + + # Check if the provided tool contains a complete path. + tool_specified="$CPIO" + tool_basename="${tool_specified##*/}" + if test "x$tool_basename" = "x$tool_specified"; then + # A command without a complete path is provided, search $PATH. + { $as_echo "$as_me:${as_lineno-$LINENO}: Will search for user supplied tool CPIO=$tool_basename" >&5 +$as_echo "$as_me: Will search for user supplied tool CPIO=$tool_basename" >&6;} + # Extract the first word of "$tool_basename", so it can be a program name with args. +set dummy $tool_basename; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_CPIO+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $CPIO in + [\\/]* | ?:[\\/]*) + ac_cv_path_CPIO="$CPIO" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_CPIO="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +CPIO=$ac_cv_path_CPIO +if test -n "$CPIO"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPIO" >&5 +$as_echo "$CPIO" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + if test "x$CPIO" = x; then + as_fn_error $? "User supplied tool $tool_basename could not be found" "$LINENO" 5 + fi + else + # Otherwise we believe it is a complete path. Use it as it is. + { $as_echo "$as_me:${as_lineno-$LINENO}: Will use user supplied tool CPIO=$tool_specified" >&5 +$as_echo "$as_me: Will use user supplied tool CPIO=$tool_specified" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for CPIO" >&5 +$as_echo_n "checking for CPIO... " >&6; } + if test ! -x "$tool_specified"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + as_fn_error $? "User supplied tool CPIO=$tool_specified does not exist or is not executable" "$LINENO" 5 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tool_specified" >&5 +$as_echo "$tool_specified" >&6; } + fi + fi + fi + + + + # Now we can determine OpenJDK build and target platforms. This is required to # have early on. # Make sure we can run config.sub. @@ -13644,6 +13639,7 @@ test -n "$target_alias" && + { $as_echo "$as_me:${as_lineno-$LINENO}: checking openjdk-build os-cpu" >&5 $as_echo_n "checking openjdk-build os-cpu... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OPENJDK_BUILD_OS-$OPENJDK_BUILD_CPU" >&5 @@ -13775,6 +13771,7 @@ $as_echo "$OPENJDK_BUILD_OS-$OPENJDK_BUILD_CPU" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking openjdk-target os-cpu" >&5 $as_echo_n "checking openjdk-target os-cpu... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU" >&5 @@ -15611,6 +15608,23 @@ $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in MSYS causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. @@ -15967,6 +15981,23 @@ $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in MSYS causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. @@ -16320,6 +16351,23 @@ $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in MSYS causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. @@ -16678,6 +16726,23 @@ $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in MSYS causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. @@ -17030,6 +17095,23 @@ $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in MSYS causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. @@ -17202,7 +17284,12 @@ $as_echo_n "checking if find supports -delete... " >&6; } if test -f $DELETEDIR/TestIfFindSupportsDelete; then # No, it does not. rm $DELETEDIR/TestIfFindSupportsDelete - FIND_DELETE="-exec rm \{\} \+" + if test "x$OPENJDK_TARGET_OS" = "xaix"; then + # AIX 'find' is buggy if called with '-exec {} \+' and an empty file list + FIND_DELETE="-print | xargs rm" + else + FIND_DELETE="-exec rm \{\} \+" + fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } else @@ -26233,197 +26320,6 @@ $as_echo "$tool_specified" >&6; } - ############################################################################## - # - # Specify jvm options for anything that is run with the Boot JDK. - # Not all JVM:s accept the same arguments on the command line. - # - -# Check whether --with-boot-jdk-jvmargs was given. -if test "${with_boot_jdk_jvmargs+set}" = set; then : - withval=$with_boot_jdk_jvmargs; -fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking flags for boot jdk java command " >&5 -$as_echo_n "checking flags for boot jdk java command ... " >&6; } - - # Disable special log output when a debug build is used as Boot JDK... - - $ECHO "Check if jvm arg is ok: -XX:-PrintVMOptions -XX:-UnlockDiagnosticVMOptions -XX:-LogVMOutput" >&5 - $ECHO "Command: $JAVA -XX:-PrintVMOptions -XX:-UnlockDiagnosticVMOptions -XX:-LogVMOutput -version" >&5 - OUTPUT=`$JAVA -XX:-PrintVMOptions -XX:-UnlockDiagnosticVMOptions -XX:-LogVMOutput -version 2>&1` - FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn` - FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""` - if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then - boot_jdk_jvmargs="$boot_jdk_jvmargs -XX:-PrintVMOptions -XX:-UnlockDiagnosticVMOptions -XX:-LogVMOutput" - JVM_ARG_OK=true - else - $ECHO "Arg failed:" >&5 - $ECHO "$OUTPUT" >&5 - JVM_ARG_OK=false - fi - - - # Apply user provided options. - - $ECHO "Check if jvm arg is ok: $with_boot_jdk_jvmargs" >&5 - $ECHO "Command: $JAVA $with_boot_jdk_jvmargs -version" >&5 - OUTPUT=`$JAVA $with_boot_jdk_jvmargs -version 2>&1` - FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn` - FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""` - if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then - boot_jdk_jvmargs="$boot_jdk_jvmargs $with_boot_jdk_jvmargs" - JVM_ARG_OK=true - else - $ECHO "Arg failed:" >&5 - $ECHO "$OUTPUT" >&5 - JVM_ARG_OK=false - fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $boot_jdk_jvmargs" >&5 -$as_echo "$boot_jdk_jvmargs" >&6; } - - # For now, general JAVA_FLAGS are the same as the boot jdk jvmargs - JAVA_FLAGS=$boot_jdk_jvmargs - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking flags for boot jdk java command for big workloads" >&5 -$as_echo_n "checking flags for boot jdk java command for big workloads... " >&6; } - - # Starting amount of heap memory. - - $ECHO "Check if jvm arg is ok: -Xms64M" >&5 - $ECHO "Command: $JAVA -Xms64M -version" >&5 - OUTPUT=`$JAVA -Xms64M -version 2>&1` - FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn` - FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""` - if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then - boot_jdk_jvmargs_big="$boot_jdk_jvmargs_big -Xms64M" - JVM_ARG_OK=true - else - $ECHO "Arg failed:" >&5 - $ECHO "$OUTPUT" >&5 - JVM_ARG_OK=false - fi - - - # Maximum amount of heap memory. - # Maximum stack size. - if test "x$BUILD_NUM_BITS" = x32; then - JVM_MAX_HEAP=1100M - STACK_SIZE=768 - else - # Running Javac on a JVM on a 64-bit machine, takes more space since 64-bit - # pointers are used. Apparently, we need to increase the heap and stack - # space for the jvm. More specifically, when running javac to build huge - # jdk batch - JVM_MAX_HEAP=1600M - STACK_SIZE=1536 - fi - - $ECHO "Check if jvm arg is ok: -Xmx$JVM_MAX_HEAP" >&5 - $ECHO "Command: $JAVA -Xmx$JVM_MAX_HEAP -version" >&5 - OUTPUT=`$JAVA -Xmx$JVM_MAX_HEAP -version 2>&1` - FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn` - FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""` - if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then - boot_jdk_jvmargs_big="$boot_jdk_jvmargs_big -Xmx$JVM_MAX_HEAP" - JVM_ARG_OK=true - else - $ECHO "Arg failed:" >&5 - $ECHO "$OUTPUT" >&5 - JVM_ARG_OK=false - fi - - - $ECHO "Check if jvm arg is ok: -XX:ThreadStackSize=$STACK_SIZE" >&5 - $ECHO "Command: $JAVA -XX:ThreadStackSize=$STACK_SIZE -version" >&5 - OUTPUT=`$JAVA -XX:ThreadStackSize=$STACK_SIZE -version 2>&1` - FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn` - FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""` - if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then - boot_jdk_jvmargs_big="$boot_jdk_jvmargs_big -XX:ThreadStackSize=$STACK_SIZE" - JVM_ARG_OK=true - else - $ECHO "Arg failed:" >&5 - $ECHO "$OUTPUT" >&5 - JVM_ARG_OK=false - fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $boot_jdk_jvmargs_big" >&5 -$as_echo "$boot_jdk_jvmargs_big" >&6; } - - JAVA_FLAGS_BIG=$boot_jdk_jvmargs_big - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking flags for boot jdk java command for small workloads" >&5 -$as_echo_n "checking flags for boot jdk java command for small workloads... " >&6; } - - # Use serial gc for small short lived tools if possible - - $ECHO "Check if jvm arg is ok: -XX:+UseSerialGC" >&5 - $ECHO "Command: $JAVA -XX:+UseSerialGC -version" >&5 - OUTPUT=`$JAVA -XX:+UseSerialGC -version 2>&1` - FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn` - FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""` - if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then - boot_jdk_jvmargs_small="$boot_jdk_jvmargs_small -XX:+UseSerialGC" - JVM_ARG_OK=true - else - $ECHO "Arg failed:" >&5 - $ECHO "$OUTPUT" >&5 - JVM_ARG_OK=false - fi - - - $ECHO "Check if jvm arg is ok: -Xms32M" >&5 - $ECHO "Command: $JAVA -Xms32M -version" >&5 - OUTPUT=`$JAVA -Xms32M -version 2>&1` - FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn` - FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""` - if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then - boot_jdk_jvmargs_small="$boot_jdk_jvmargs_small -Xms32M" - JVM_ARG_OK=true - else - $ECHO "Arg failed:" >&5 - $ECHO "$OUTPUT" >&5 - JVM_ARG_OK=false - fi - - - $ECHO "Check if jvm arg is ok: -Xmx512M" >&5 - $ECHO "Command: $JAVA -Xmx512M -version" >&5 - OUTPUT=`$JAVA -Xmx512M -version 2>&1` - FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn` - FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""` - if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then - boot_jdk_jvmargs_small="$boot_jdk_jvmargs_small -Xmx512M" - JVM_ARG_OK=true - else - $ECHO "Arg failed:" >&5 - $ECHO "$OUTPUT" >&5 - JVM_ARG_OK=false - fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $boot_jdk_jvmargs_small" >&5 -$as_echo "$boot_jdk_jvmargs_small" >&6; } - - JAVA_FLAGS_SMALL=$boot_jdk_jvmargs_small - - - JAVA_TOOL_FLAGS_SMALL="" - for f in $JAVA_FLAGS_SMALL; do - JAVA_TOOL_FLAGS_SMALL="$JAVA_TOOL_FLAGS_SMALL -J$f" - done - - - ############################################################################### # # Configure the sources to use. We can add or override individual directories. @@ -27493,6 +27389,23 @@ $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in MSYS causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. @@ -28136,6 +28049,23 @@ $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in MSYS causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. @@ -28576,6 +28506,23 @@ $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in MSYS causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. @@ -29842,6 +29789,23 @@ $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in MSYS causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. @@ -30282,6 +30246,23 @@ $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in MSYS causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. @@ -31127,6 +31108,23 @@ $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in MSYS causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. @@ -31525,6 +31523,23 @@ $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in MSYS causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. @@ -31852,6 +31867,23 @@ $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in MSYS causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. @@ -32330,6 +32362,23 @@ $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in MSYS causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. @@ -32941,6 +32990,23 @@ $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in MSYS causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. @@ -33460,6 +33526,23 @@ $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in MSYS causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. @@ -33911,6 +33994,23 @@ $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in MSYS causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. @@ -34235,6 +34335,23 @@ $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in MSYS causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. @@ -34555,6 +34672,23 @@ $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in MSYS causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. @@ -34857,6 +34991,23 @@ $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in MSYS causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. @@ -35311,6 +35462,23 @@ $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in MSYS causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. @@ -35762,6 +35930,23 @@ $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in MSYS causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. @@ -36213,6 +36398,23 @@ $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in MSYS causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. @@ -36665,6 +36867,23 @@ $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in MSYS causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. @@ -37228,6 +37447,23 @@ $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in MSYS causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. @@ -37789,6 +38025,23 @@ $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in MSYS causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. @@ -38359,6 +38612,23 @@ $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in MSYS causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. @@ -38926,6 +39196,23 @@ $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in MSYS causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. @@ -39402,6 +39689,23 @@ $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in MSYS causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. @@ -39853,6 +40157,23 @@ $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in MSYS causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. @@ -40304,6 +40625,23 @@ $as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" new_path=`$WHICH "$new_path" 2> /dev/null` + # bat and cmd files are not always considered executable in MSYS causing which + # to not find them + if test "x$new_path" = x \ + && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \ + && test "x`$LS \"$path\" 2>/dev/null`" != x; then + new_path="$path" + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + fi if test "x$new_path" = x; then # It's still not found. Now this is an unrecoverable error. @@ -41991,17 +42329,15 @@ $as_echo "$ac_cv_c_bigendian" >&6; } # no adjustment ;; fastdebug ) - # Add compile time bounds checks. - CFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1" - CXXFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1" + # no adjustment ;; slowdebug ) - # Add runtime bounds checks and symbol info. - CFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-all --param ssp-buffer-size=1" - CXXFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-all --param ssp-buffer-size=1" + # Add runtime stack smashing and undefined behavior checks + CFLAGS_DEBUG_OPTIONS="-fstack-protector-all --param ssp-buffer-size=1" + CXXFLAGS_DEBUG_OPTIONS="-fstack-protector-all --param ssp-buffer-size=1" if test "x$HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR" = "xtrue"; then CFLAGS_DEBUG_OPTIONS="$CFLAGS_DEBUG_OPTIONS $CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG" - CXXFLAGS_DEBUG_OPTIONS="$CXXFLAGS_DEBUG_OPTIONS $CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG" + CXXFLAGS_DEBUG_OPTIONS="$CXXFLAGS_DEBUG_OPTIONS $CFLAG_DETECT_UNDEFINED_BEHAVIsOR_FLAG" fi ;; esac @@ -42629,7 +42965,7 @@ $as_echo "$supports" >&6; } case "${TOOLCHAIN_TYPE}" in microsoft) - CFLAGS_WARNINGS_ARE_ERRORS="/WX" + CFLAGS_WARNINGS_ARE_ERRORS="-WX" ;; solstudio) CFLAGS_WARNINGS_ARE_ERRORS="-errtags -errwarn=%all" @@ -48711,12 +49047,22 @@ $as_echo "$as_me: Found msvcr100.dll at $POSSIBLE_MSVCR_DLL using $METHOD" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: checking found msvcr100.dll architecture" >&5 $as_echo_n "checking found msvcr100.dll architecture... " >&6; } MSVCR_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVCR_DLL"` - if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then - CORRECT_MSVCR_ARCH=386 + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + # The MSYS 'file' command returns "PE32 executable for MS Windows (DLL) (GUI) Intel 80386 32-bit" + # on x32 and "PE32+ executable for MS Windows (DLL) (GUI) Mono/.Net assembly" on x64 systems. + if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then + CORRECT_MSVCR_ARCH="PE32 executable" + else + CORRECT_MSVCR_ARCH="PE32+ executable" + fi else - CORRECT_MSVCR_ARCH=x86-64 + if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then + CORRECT_MSVCR_ARCH=386 + else + CORRECT_MSVCR_ARCH=x86-64 + fi fi - if $ECHO "$MSVCR_DLL_FILETYPE" | $GREP $CORRECT_MSVCR_ARCH 2>&1 > /dev/null; then + if $ECHO "$MSVCR_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } MSVCR_DLL="$POSSIBLE_MSVCR_DLL" @@ -48767,12 +49113,22 @@ $as_echo "$as_me: Found msvcr100.dll at $POSSIBLE_MSVCR_DLL using $METHOD" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: checking found msvcr100.dll architecture" >&5 $as_echo_n "checking found msvcr100.dll architecture... " >&6; } MSVCR_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVCR_DLL"` - if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then - CORRECT_MSVCR_ARCH=386 + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + # The MSYS 'file' command returns "PE32 executable for MS Windows (DLL) (GUI) Intel 80386 32-bit" + # on x32 and "PE32+ executable for MS Windows (DLL) (GUI) Mono/.Net assembly" on x64 systems. + if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then + CORRECT_MSVCR_ARCH="PE32 executable" + else + CORRECT_MSVCR_ARCH="PE32+ executable" + fi else - CORRECT_MSVCR_ARCH=x86-64 + if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then + CORRECT_MSVCR_ARCH=386 + else + CORRECT_MSVCR_ARCH=x86-64 + fi fi - if $ECHO "$MSVCR_DLL_FILETYPE" | $GREP $CORRECT_MSVCR_ARCH 2>&1 > /dev/null; then + if $ECHO "$MSVCR_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } MSVCR_DLL="$POSSIBLE_MSVCR_DLL" @@ -48805,12 +49161,22 @@ $as_echo "$as_me: Found msvcr100.dll at $POSSIBLE_MSVCR_DLL using $METHOD" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: checking found msvcr100.dll architecture" >&5 $as_echo_n "checking found msvcr100.dll architecture... " >&6; } MSVCR_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVCR_DLL"` - if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then - CORRECT_MSVCR_ARCH=386 + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + # The MSYS 'file' command returns "PE32 executable for MS Windows (DLL) (GUI) Intel 80386 32-bit" + # on x32 and "PE32+ executable for MS Windows (DLL) (GUI) Mono/.Net assembly" on x64 systems. + if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then + CORRECT_MSVCR_ARCH="PE32 executable" + else + CORRECT_MSVCR_ARCH="PE32+ executable" + fi else - CORRECT_MSVCR_ARCH=x86-64 + if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then + CORRECT_MSVCR_ARCH=386 + else + CORRECT_MSVCR_ARCH=x86-64 + fi fi - if $ECHO "$MSVCR_DLL_FILETYPE" | $GREP $CORRECT_MSVCR_ARCH 2>&1 > /dev/null; then + if $ECHO "$MSVCR_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } MSVCR_DLL="$POSSIBLE_MSVCR_DLL" @@ -48853,12 +49219,22 @@ $as_echo "$as_me: Found msvcr100.dll at $POSSIBLE_MSVCR_DLL using $METHOD" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: checking found msvcr100.dll architecture" >&5 $as_echo_n "checking found msvcr100.dll architecture... " >&6; } MSVCR_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVCR_DLL"` - if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then - CORRECT_MSVCR_ARCH=386 + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + # The MSYS 'file' command returns "PE32 executable for MS Windows (DLL) (GUI) Intel 80386 32-bit" + # on x32 and "PE32+ executable for MS Windows (DLL) (GUI) Mono/.Net assembly" on x64 systems. + if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then + CORRECT_MSVCR_ARCH="PE32 executable" + else + CORRECT_MSVCR_ARCH="PE32+ executable" + fi else - CORRECT_MSVCR_ARCH=x86-64 + if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then + CORRECT_MSVCR_ARCH=386 + else + CORRECT_MSVCR_ARCH=x86-64 + fi fi - if $ECHO "$MSVCR_DLL_FILETYPE" | $GREP $CORRECT_MSVCR_ARCH 2>&1 > /dev/null; then + if $ECHO "$MSVCR_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } MSVCR_DLL="$POSSIBLE_MSVCR_DLL" @@ -48906,12 +49282,22 @@ $as_echo "$as_me: Found msvcr100.dll at $POSSIBLE_MSVCR_DLL using $METHOD" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: checking found msvcr100.dll architecture" >&5 $as_echo_n "checking found msvcr100.dll architecture... " >&6; } MSVCR_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVCR_DLL"` - if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then - CORRECT_MSVCR_ARCH=386 + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + # The MSYS 'file' command returns "PE32 executable for MS Windows (DLL) (GUI) Intel 80386 32-bit" + # on x32 and "PE32+ executable for MS Windows (DLL) (GUI) Mono/.Net assembly" on x64 systems. + if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then + CORRECT_MSVCR_ARCH="PE32 executable" + else + CORRECT_MSVCR_ARCH="PE32+ executable" + fi else - CORRECT_MSVCR_ARCH=x86-64 + if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then + CORRECT_MSVCR_ARCH=386 + else + CORRECT_MSVCR_ARCH=x86-64 + fi fi - if $ECHO "$MSVCR_DLL_FILETYPE" | $GREP $CORRECT_MSVCR_ARCH 2>&1 > /dev/null; then + if $ECHO "$MSVCR_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } MSVCR_DLL="$POSSIBLE_MSVCR_DLL" @@ -48955,12 +49341,22 @@ $as_echo "$as_me: Found msvcr100.dll at $POSSIBLE_MSVCR_DLL using $METHOD" >&6;} { $as_echo "$as_me:${as_lineno-$LINENO}: checking found msvcr100.dll architecture" >&5 $as_echo_n "checking found msvcr100.dll architecture... " >&6; } MSVCR_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVCR_DLL"` - if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then - CORRECT_MSVCR_ARCH=386 + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + # The MSYS 'file' command returns "PE32 executable for MS Windows (DLL) (GUI) Intel 80386 32-bit" + # on x32 and "PE32+ executable for MS Windows (DLL) (GUI) Mono/.Net assembly" on x64 systems. + if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then + CORRECT_MSVCR_ARCH="PE32 executable" + else + CORRECT_MSVCR_ARCH="PE32+ executable" + fi else - CORRECT_MSVCR_ARCH=x86-64 + if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then + CORRECT_MSVCR_ARCH=386 + else + CORRECT_MSVCR_ARCH=x86-64 + fi fi - if $ECHO "$MSVCR_DLL_FILETYPE" | $GREP $CORRECT_MSVCR_ARCH 2>&1 > /dev/null; then + if $ECHO "$MSVCR_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } MSVCR_DLL="$POSSIBLE_MSVCR_DLL" @@ -49300,8 +49696,8 @@ fi # Number of jobs was not specified, calculate. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for appropriate number of jobs to run in parallel" >&5 $as_echo_n "checking for appropriate number of jobs to run in parallel... " >&6; } - # Approximate memory in GB, rounding up a bit. - memory_gb=`expr $MEMORY_SIZE / 1100` + # Approximate memory in GB. + memory_gb=`expr $MEMORY_SIZE / 1024` # Pick the lowest of memory in gb and number of cores. if test "$memory_gb" -lt "$NUM_CORES"; then JOBS="$memory_gb" @@ -49327,6 +49723,208 @@ $as_echo "$JOBS" >&6; } +# Setup arguments for the boot jdk (after cores and memory have been setup) + + ############################################################################## + # + # Specify jvm options for anything that is run with the Boot JDK. + # Not all JVM:s accept the same arguments on the command line. + # + +# Check whether --with-boot-jdk-jvmargs was given. +if test "${with_boot_jdk_jvmargs+set}" = set; then : + withval=$with_boot_jdk_jvmargs; +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking flags for boot jdk java command " >&5 +$as_echo_n "checking flags for boot jdk java command ... " >&6; } + + # Disable special log output when a debug build is used as Boot JDK... + + $ECHO "Check if jvm arg is ok: -XX:-PrintVMOptions -XX:-UnlockDiagnosticVMOptions -XX:-LogVMOutput" >&5 + $ECHO "Command: $JAVA -XX:-PrintVMOptions -XX:-UnlockDiagnosticVMOptions -XX:-LogVMOutput -version" >&5 + OUTPUT=`$JAVA -XX:-PrintVMOptions -XX:-UnlockDiagnosticVMOptions -XX:-LogVMOutput -version 2>&1` + FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn` + FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""` + if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then + boot_jdk_jvmargs="$boot_jdk_jvmargs -XX:-PrintVMOptions -XX:-UnlockDiagnosticVMOptions -XX:-LogVMOutput" + JVM_ARG_OK=true + else + $ECHO "Arg failed:" >&5 + $ECHO "$OUTPUT" >&5 + JVM_ARG_OK=false + fi + + + # Apply user provided options. + + $ECHO "Check if jvm arg is ok: $with_boot_jdk_jvmargs" >&5 + $ECHO "Command: $JAVA $with_boot_jdk_jvmargs -version" >&5 + OUTPUT=`$JAVA $with_boot_jdk_jvmargs -version 2>&1` + FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn` + FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""` + if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then + boot_jdk_jvmargs="$boot_jdk_jvmargs $with_boot_jdk_jvmargs" + JVM_ARG_OK=true + else + $ECHO "Arg failed:" >&5 + $ECHO "$OUTPUT" >&5 + JVM_ARG_OK=false + fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $boot_jdk_jvmargs" >&5 +$as_echo "$boot_jdk_jvmargs" >&6; } + + # For now, general JAVA_FLAGS are the same as the boot jdk jvmargs + JAVA_FLAGS=$boot_jdk_jvmargs + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking flags for boot jdk java command for big workloads" >&5 +$as_echo_n "checking flags for boot jdk java command for big workloads... " >&6; } + + # Starting amount of heap memory. + + $ECHO "Check if jvm arg is ok: -Xms64M" >&5 + $ECHO "Command: $JAVA -Xms64M -version" >&5 + OUTPUT=`$JAVA -Xms64M -version 2>&1` + FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn` + FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""` + if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then + boot_jdk_jvmargs_big="$boot_jdk_jvmargs_big -Xms64M" + JVM_ARG_OK=true + else + $ECHO "Arg failed:" >&5 + $ECHO "$OUTPUT" >&5 + JVM_ARG_OK=false + fi + + + # Maximum amount of heap memory. + # Maximum stack size. + JVM_MAX_HEAP=`expr $MEMORY_SIZE / 2` + if test "x$BUILD_NUM_BITS" = x32; then + if test "$JVM_MAX_HEAP" -gt "1100"; then + JVM_MAX_HEAP=1100 + elif test "$JVM_MAX_HEAP" -lt "512"; then + JVM_MAX_HEAP=512 + fi + STACK_SIZE=768 + else + # Running Javac on a JVM on a 64-bit machine, takes more space since 64-bit + # pointers are used. Apparently, we need to increase the heap and stack + # space for the jvm. More specifically, when running javac to build huge + # jdk batch + if test "$JVM_MAX_HEAP" -gt "1600"; then + JVM_MAX_HEAP=1600 + elif test "$JVM_MAX_HEAP" -lt "512"; then + JVM_MAX_HEAP=512 + fi + STACK_SIZE=1536 + fi + + $ECHO "Check if jvm arg is ok: -Xmx${JVM_MAX_HEAP}M" >&5 + $ECHO "Command: $JAVA -Xmx${JVM_MAX_HEAP}M -version" >&5 + OUTPUT=`$JAVA -Xmx${JVM_MAX_HEAP}M -version 2>&1` + FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn` + FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""` + if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then + boot_jdk_jvmargs_big="$boot_jdk_jvmargs_big -Xmx${JVM_MAX_HEAP}M" + JVM_ARG_OK=true + else + $ECHO "Arg failed:" >&5 + $ECHO "$OUTPUT" >&5 + JVM_ARG_OK=false + fi + + + $ECHO "Check if jvm arg is ok: -XX:ThreadStackSize=$STACK_SIZE" >&5 + $ECHO "Command: $JAVA -XX:ThreadStackSize=$STACK_SIZE -version" >&5 + OUTPUT=`$JAVA -XX:ThreadStackSize=$STACK_SIZE -version 2>&1` + FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn` + FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""` + if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then + boot_jdk_jvmargs_big="$boot_jdk_jvmargs_big -XX:ThreadStackSize=$STACK_SIZE" + JVM_ARG_OK=true + else + $ECHO "Arg failed:" >&5 + $ECHO "$OUTPUT" >&5 + JVM_ARG_OK=false + fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $boot_jdk_jvmargs_big" >&5 +$as_echo "$boot_jdk_jvmargs_big" >&6; } + + JAVA_FLAGS_BIG=$boot_jdk_jvmargs_big + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking flags for boot jdk java command for small workloads" >&5 +$as_echo_n "checking flags for boot jdk java command for small workloads... " >&6; } + + # Use serial gc for small short lived tools if possible + + $ECHO "Check if jvm arg is ok: -XX:+UseSerialGC" >&5 + $ECHO "Command: $JAVA -XX:+UseSerialGC -version" >&5 + OUTPUT=`$JAVA -XX:+UseSerialGC -version 2>&1` + FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn` + FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""` + if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then + boot_jdk_jvmargs_small="$boot_jdk_jvmargs_small -XX:+UseSerialGC" + JVM_ARG_OK=true + else + $ECHO "Arg failed:" >&5 + $ECHO "$OUTPUT" >&5 + JVM_ARG_OK=false + fi + + + $ECHO "Check if jvm arg is ok: -Xms32M" >&5 + $ECHO "Command: $JAVA -Xms32M -version" >&5 + OUTPUT=`$JAVA -Xms32M -version 2>&1` + FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn` + FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""` + if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then + boot_jdk_jvmargs_small="$boot_jdk_jvmargs_small -Xms32M" + JVM_ARG_OK=true + else + $ECHO "Arg failed:" >&5 + $ECHO "$OUTPUT" >&5 + JVM_ARG_OK=false + fi + + + $ECHO "Check if jvm arg is ok: -Xmx512M" >&5 + $ECHO "Command: $JAVA -Xmx512M -version" >&5 + OUTPUT=`$JAVA -Xmx512M -version 2>&1` + FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn` + FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""` + if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then + boot_jdk_jvmargs_small="$boot_jdk_jvmargs_small -Xmx512M" + JVM_ARG_OK=true + else + $ECHO "Arg failed:" >&5 + $ECHO "$OUTPUT" >&5 + JVM_ARG_OK=false + fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $boot_jdk_jvmargs_small" >&5 +$as_echo "$boot_jdk_jvmargs_small" >&6; } + + JAVA_FLAGS_SMALL=$boot_jdk_jvmargs_small + + + JAVA_TOOL_FLAGS_SMALL="" + for f in $JAVA_FLAGS_SMALL; do + JAVA_TOOL_FLAGS_SMALL="$JAVA_TOOL_FLAGS_SMALL -J$f" + done + + + # Setup smart javac (after cores and memory have been setup) @@ -49343,44 +49941,11 @@ fi as_fn_error $? "Could not execute server java: $SJAVAC_SERVER_JAVA" "$LINENO" 5 fi else - SJAVAC_SERVER_JAVA="" - # Hotspot specific options. - - $ECHO "Check if jvm arg is ok: -verbosegc" >&5 - $ECHO "Command: $JAVA -verbosegc -version" >&5 - OUTPUT=`$JAVA -verbosegc -version 2>&1` - FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn` - FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""` - if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then - SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -verbosegc" - JVM_ARG_OK=true - else - $ECHO "Arg failed:" >&5 - $ECHO "$OUTPUT" >&5 - JVM_ARG_OK=false - fi - - # JRockit specific options. - - $ECHO "Check if jvm arg is ok: -Xverbose:gc" >&5 - $ECHO "Command: $JAVA -Xverbose:gc -version" >&5 - OUTPUT=`$JAVA -Xverbose:gc -version 2>&1` - FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn` - FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""` - if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then - SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -Xverbose:gc" - JVM_ARG_OK=true - else - $ECHO "Arg failed:" >&5 - $ECHO "$OUTPUT" >&5 - JVM_ARG_OK=false - fi - - SJAVAC_SERVER_JAVA="$JAVA $SJAVAC_SERVER_JAVA" + SJAVAC_SERVER_JAVA="$JAVA" fi - if test "$MEMORY_SIZE" -gt "2500"; then + if test "$MEMORY_SIZE" -gt "3000"; then $ECHO "Check if jvm arg is ok: -d64" >&5 $ECHO "Command: $SJAVAC_SERVER_JAVA -d64 -version" >&5 @@ -49402,85 +49967,31 @@ fi fi fi + MX_VALUE=`expr $MEMORY_SIZE / 2` if test "$JVM_64BIT" = true; then - if test "$MEMORY_SIZE" -gt "17000"; then - - $ECHO "Check if jvm arg is ok: -Xms10G -Xmx10G" >&5 - $ECHO "Command: $SJAVAC_SERVER_JAVA -Xms10G -Xmx10G -version" >&5 - OUTPUT=`$SJAVAC_SERVER_JAVA -Xms10G -Xmx10G -version 2>&1` - FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn` - FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""` - if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then - SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -Xms10G -Xmx10G" - JVM_ARG_OK=true - else - $ECHO "Arg failed:" >&5 - $ECHO "$OUTPUT" >&5 - JVM_ARG_OK=false - fi - + # Set ms lower than mx since more than one instance of the server might + # get launched at the same time before they figure out which instance won. + MS_VALUE=512 + if test "$MX_VALUE" -gt "2048"; then + MX_VALUE=2048 fi - if test "$MEMORY_SIZE" -gt "10000" && test "$JVM_ARG_OK" = false; then - - $ECHO "Check if jvm arg is ok: -Xms6G -Xmx6G" >&5 - $ECHO "Command: $SJAVAC_SERVER_JAVA -Xms6G -Xmx6G -version" >&5 - OUTPUT=`$SJAVAC_SERVER_JAVA -Xms6G -Xmx6G -version 2>&1` - FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn` - FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""` - if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then - SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -Xms6G -Xmx6G" - JVM_ARG_OK=true else - $ECHO "Arg failed:" >&5 - $ECHO "$OUTPUT" >&5 - JVM_ARG_OK=false - fi - - fi - if test "$MEMORY_SIZE" -gt "5000" && test "$JVM_ARG_OK" = false; then - - $ECHO "Check if jvm arg is ok: -Xms1G -Xmx3G" >&5 - $ECHO "Command: $SJAVAC_SERVER_JAVA -Xms1G -Xmx3G -version" >&5 - OUTPUT=`$SJAVAC_SERVER_JAVA -Xms1G -Xmx3G -version 2>&1` - FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn` - FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""` - if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then - SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -Xms1G -Xmx3G" - JVM_ARG_OK=true - else - $ECHO "Arg failed:" >&5 - $ECHO "$OUTPUT" >&5 - JVM_ARG_OK=false - fi - - fi - if test "$MEMORY_SIZE" -gt "3800" && test "$JVM_ARG_OK" = false; then - - $ECHO "Check if jvm arg is ok: -Xms1G -Xmx2500M" >&5 - $ECHO "Command: $SJAVAC_SERVER_JAVA -Xms1G -Xmx2500M -version" >&5 - OUTPUT=`$SJAVAC_SERVER_JAVA -Xms1G -Xmx2500M -version 2>&1` - FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn` - FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""` - if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then - SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -Xms1G -Xmx2500M" - JVM_ARG_OK=true - else - $ECHO "Arg failed:" >&5 - $ECHO "$OUTPUT" >&5 - JVM_ARG_OK=false - fi - + MS_VALUE=256 + if test "$MX_VALUE" -gt "1500"; then + MX_VALUE=1500 fi fi - if test "$MEMORY_SIZE" -gt "2500" && test "$JVM_ARG_OK" = false; then + if test "$MX_VALUE" -lt "512"; then + MX_VALUE=512 + fi - $ECHO "Check if jvm arg is ok: -Xms1000M -Xmx1500M" >&5 - $ECHO "Command: $SJAVAC_SERVER_JAVA -Xms1000M -Xmx1500M -version" >&5 - OUTPUT=`$SJAVAC_SERVER_JAVA -Xms1000M -Xmx1500M -version 2>&1` + $ECHO "Check if jvm arg is ok: -Xms${MS_VALUE}M -Xmx${MX_VALUE}M" >&5 + $ECHO "Command: $SJAVAC_SERVER_JAVA -Xms${MS_VALUE}M -Xmx${MX_VALUE}M -version" >&5 + OUTPUT=`$SJAVAC_SERVER_JAVA -Xms${MS_VALUE}M -Xmx${MX_VALUE}M -version 2>&1` FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn` FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""` if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then - SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -Xms1000M -Xmx1500M" + SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -Xms${MS_VALUE}M -Xmx${MX_VALUE}M" JVM_ARG_OK=true else $ECHO "Arg failed:" >&5 @@ -49488,44 +49999,7 @@ fi JVM_ARG_OK=false fi - fi - if test "$MEMORY_SIZE" -gt "1000" && test "$JVM_ARG_OK" = false; then - $ECHO "Check if jvm arg is ok: -Xms400M -Xmx1100M" >&5 - $ECHO "Command: $SJAVAC_SERVER_JAVA -Xms400M -Xmx1100M -version" >&5 - OUTPUT=`$SJAVAC_SERVER_JAVA -Xms400M -Xmx1100M -version 2>&1` - FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn` - FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""` - if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then - SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -Xms400M -Xmx1100M" - JVM_ARG_OK=true - else - $ECHO "Arg failed:" >&5 - $ECHO "$OUTPUT" >&5 - JVM_ARG_OK=false - fi - - fi - if test "$JVM_ARG_OK" = false; then - - $ECHO "Check if jvm arg is ok: -Xms256M -Xmx512M" >&5 - $ECHO "Command: $SJAVAC_SERVER_JAVA -Xms256M -Xmx512M -version" >&5 - OUTPUT=`$SJAVAC_SERVER_JAVA -Xms256M -Xmx512M -version 2>&1` - FOUND_WARN=`$ECHO "$OUTPUT" | grep -i warn` - FOUND_VERSION=`$ECHO $OUTPUT | grep " version \""` - if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then - SJAVAC_SERVER_JAVA="$SJAVAC_SERVER_JAVA -Xms256M -Xmx512M" - JVM_ARG_OK=true - else - $ECHO "Arg failed:" >&5 - $ECHO "$OUTPUT" >&5 - JVM_ARG_OK=false - fi - - fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use sjavac" >&5 -$as_echo_n "checking whether to use sjavac... " >&6; } # Check whether --enable-sjavac was given. if test "${enable_sjavac+set}" = set; then : enableval=$enable_sjavac; ENABLE_SJAVAC="${enableval}" @@ -49533,6 +50007,13 @@ else ENABLE_SJAVAC='no' fi + if test "x$JVM_ARG_OK" = "xfalse"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Could not set -Xms${MS_VALUE}M -Xmx${MX_VALUE}M, disabling sjavac" >&5 +$as_echo "$as_me: WARNING: Could not set -Xms${MS_VALUE}M -Xmx${MX_VALUE}M, disabling sjavac" >&2;} + ENABLE_SJAVAC=no; + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use sjavac" >&5 +$as_echo_n "checking whether to use sjavac... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ENABLE_SJAVAC" >&5 $as_echo "$ENABLE_SJAVAC" >&6; } @@ -49903,7 +50384,7 @@ $as_echo "no, disabling ccaching of precompiled headers" >&6; } # Check for some common pitfalls - if test x"$OPENJDK_BUILD_OS" = xwindows; then + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then file_to_test="$SRC_ROOT/LICENSE" if test `$STAT -c '%a' "$file_to_test"` -lt 400; then as_fn_error $? "Bad file permissions on src files. This is usually caused by cloning the repositories with a non cygwin hg in a directory not created in cygwin." "$LINENO" 5 diff --git a/common/autoconf/platform.m4 b/common/autoconf/platform.m4 index ead832d5050..4eacb397cbe 100644 --- a/common/autoconf/platform.m4 +++ b/common/autoconf/platform.m4 @@ -173,6 +173,7 @@ AC_DEFUN([PLATFORM_EXTRACT_TARGET_AND_BUILD], OPENJDK_BUILD_CPU_ENDIAN="$VAR_CPU_ENDIAN" AC_SUBST(OPENJDK_BUILD_OS) AC_SUBST(OPENJDK_BUILD_OS_API) + AC_SUBST(OPENJDK_BUILD_OS_ENV) AC_SUBST(OPENJDK_BUILD_CPU) AC_SUBST(OPENJDK_BUILD_CPU_ARCH) AC_SUBST(OPENJDK_BUILD_CPU_BITS) @@ -194,6 +195,7 @@ AC_DEFUN([PLATFORM_EXTRACT_TARGET_AND_BUILD], OPENJDK_TARGET_CPU_ENDIAN="$VAR_CPU_ENDIAN" AC_SUBST(OPENJDK_TARGET_OS) AC_SUBST(OPENJDK_TARGET_OS_API) + AC_SUBST(OPENJDK_TARGET_OS_ENV) AC_SUBST(OPENJDK_TARGET_CPU) AC_SUBST(OPENJDK_TARGET_CPU_ARCH) AC_SUBST(OPENJDK_TARGET_CPU_BITS) diff --git a/common/autoconf/spec.gmk.in b/common/autoconf/spec.gmk.in index 315c10615e4..e85c830783c 100644 --- a/common/autoconf/spec.gmk.in +++ b/common/autoconf/spec.gmk.in @@ -106,6 +106,7 @@ OPENJDK_TARGET_OS_EXPORT_DIR:=@OPENJDK_TARGET_OS_EXPORT_DIR@ # When not cross-compiling, it is the same as the target. OPENJDK_BUILD_OS:=@OPENJDK_BUILD_OS@ OPENJDK_BUILD_OS_API:=@OPENJDK_BUILD_OS_API@ +OPENJDK_BUILD_OS_ENV:=@OPENJDK_BUILD_OS_ENV@ OPENJDK_BUILD_CPU:=@OPENJDK_BUILD_CPU@ OPENJDK_BUILD_CPU_ARCH:=@OPENJDK_BUILD_CPU_ARCH@ diff --git a/common/autoconf/toolchain_windows.m4 b/common/autoconf/toolchain_windows.m4 index b4888a46ac5..bdd110582c9 100644 --- a/common/autoconf/toolchain_windows.m4 +++ b/common/autoconf/toolchain_windows.m4 @@ -244,12 +244,22 @@ AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_MSVCR_DLL], # Need to check if the found msvcr is correct architecture AC_MSG_CHECKING([found msvcr100.dll architecture]) MSVCR_DLL_FILETYPE=`$FILE -b "$POSSIBLE_MSVCR_DLL"` - if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then - CORRECT_MSVCR_ARCH=386 + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + # The MSYS 'file' command returns "PE32 executable for MS Windows (DLL) (GUI) Intel 80386 32-bit" + # on x32 and "PE32+ executable for MS Windows (DLL) (GUI) Mono/.Net assembly" on x64 systems. + if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then + CORRECT_MSVCR_ARCH="PE32 executable" + else + CORRECT_MSVCR_ARCH="PE32+ executable" + fi else - CORRECT_MSVCR_ARCH=x86-64 + if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then + CORRECT_MSVCR_ARCH=386 + else + CORRECT_MSVCR_ARCH=x86-64 + fi fi - if $ECHO "$MSVCR_DLL_FILETYPE" | $GREP $CORRECT_MSVCR_ARCH 2>&1 > /dev/null; then + if $ECHO "$MSVCR_DLL_FILETYPE" | $GREP "$CORRECT_MSVCR_ARCH" 2>&1 > /dev/null; then AC_MSG_RESULT([ok]) MSVCR_DLL="$POSSIBLE_MSVCR_DLL" AC_MSG_CHECKING([for msvcr100.dll]) diff --git a/common/bin/hgforest.sh b/common/bin/hgforest.sh index e7fbd1fe13f..5bf586bc13c 100644 --- a/common/bin/hgforest.sh +++ b/common/bin/hgforest.sh @@ -77,6 +77,11 @@ do shift done +# debug mode +if [ "${HGFOREST_DEBUG:-false}" = "true" ] ; then + global_opts="${global_opts} --debug" +fi + # silence standard output? if [ ${qflag} = "true" ] ; then global_opts="${global_opts} -q" @@ -89,14 +94,26 @@ if [ ${vflag} = "true" ] ; then fi # Make sure we have a command. -if [ $# -lt 1 -o -z "${1:-}" ] ; then - echo "ERROR: No command to hg supplied!" - usage +if [ ${#} -lt 1 -o -z "${1:-}" ] ; then + echo "ERROR: No command to hg supplied!" > ${status_output} + usage > ${status_output} fi -command="$1"; shift +# grab command +command="${1}"; shift + +if [ ${vflag} = "true" ] ; then + echo "# Mercurial command: ${command}" > ${status_output} +fi + + +# capture command options and arguments (if any) command_args="${@:-}" +if [ ${vflag} = "true" ] ; then + echo "# Mercurial command arguments: ${command_args}" > ${status_output} +fi + # Clean out the temporary directory that stores the pid files. tmp=/tmp/forest.$$ rm -f -r ${tmp} @@ -104,7 +121,8 @@ mkdir -p ${tmp} if [ "${HGFOREST_DEBUG:-false}" = "true" ] ; then - echo "DEBUG: temp files are in: ${tmp}" + # ignores redirection. + echo "DEBUG: temp files are in: ${tmp}" >&2 fi # Check if we can use fifos for monitoring sub-process completion. @@ -377,21 +395,33 @@ else fi fi done + + if [ ${have_fifos} = "true" ]; then + # done with the fifo + exec 3>&- + fi fi # Wait for all subprocesses to complete wait # Terminate with exit 0 only if all subprocesses were successful +# Terminate with highest exit code of subprocesses ec=0 if [ -d ${tmp} ]; then rcfiles="`(ls -a ${tmp}/*.pid.rc 2> /dev/null) || echo ''`" for rc in ${rcfiles} ; do exit_code=`cat ${rc} | tr -d ' \n\r'` if [ "${exit_code}" != "0" ] ; then + if [ ${exit_code} -gt 1 ]; then + # mercurial exit codes greater than "1" signal errors. repo="`echo ${rc} | sed -e 's@^'${tmp}'@@' -e 's@/*\([^/]*\)\.pid\.rc$@\1@' -e 's@_@/@g'`" echo "WARNING: ${repo} exited abnormally (${exit_code})" > ${status_output} - ec=1 + fi + if [ ${exit_code} -gt ${ec} ]; then + # assume that larger exit codes are more significant + ec=${exit_code} + fi fi done fi diff --git a/corba/.hgtags b/corba/.hgtags index d7401bcb630..346a38ca219 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -269,3 +269,5 @@ ddc07abf4307855c0dc904cc5c96cc764023a930 jdk9-b22 8a44142bb7fc8118f70f91a1b97c12dfc50563ee jdk9-b24 da08cca6b97f41b7081a3e176dcb400af6e4bb26 jdk9-b25 6c777df597bbf5abba3488d44c401edfe73c74af jdk9-b26 +7e06bf1dcb0907b80ddf59315426ce9ce775e56d jdk9-b27 +a00b04ef067e39f50b9a0fea6f1904e35d632a73 jdk9-b28 diff --git a/corba/make/GensrcCorba.gmk b/corba/make/GensrcCorba.gmk index 8b814238272..1951cd43e37 100644 --- a/corba/make/GensrcCorba.gmk +++ b/corba/make/GensrcCorba.gmk @@ -50,8 +50,9 @@ $(eval $(call SetupJavaCompilation,BUILD_IDLJ, \ INCLUDES := com/sun/tools/corba/se/idl, \ EXCLUDE_FILES := ResourceBundleUtil.java)) +# Force the language to english for predictable source code generation. TOOL_IDLJ_CMD := $(JAVA) -cp $(CORBA_OUTPUTDIR)/idlj_classes \ - com.sun.tools.corba.se.idl.toJavaPortable.Compile + -Duser.language=en com.sun.tools.corba.se.idl.toJavaPortable.Compile ################################################################################ diff --git a/corba/src/java.corba/share/classes/org/omg/CORBA/FloatSeqHelper.java b/corba/src/java.corba/share/classes/org/omg/CORBA/FloatSeqHelper.java index ad02ae3b56a..8cf9684c585 100644 --- a/corba/src/java.corba/share/classes/org/omg/CORBA/FloatSeqHelper.java +++ b/corba/src/java.corba/share/classes/org/omg/CORBA/FloatSeqHelper.java @@ -38,11 +38,11 @@ package org.omg.CORBA; * OMG specifications : * */ diff --git a/get_source.sh b/get_source.sh index 5e874d1cb51..72049bdec8a 100644 --- a/get_source.sh +++ b/get_source.sh @@ -67,7 +67,7 @@ if [ "x$hgwhere" = "x" ]; then error "Could not locate Mercurial command" fi -hgversion="`hg --version 2> /dev/null | sed -n -e 's@^Mercurial Distributed SCM (version \([^+]*\).*)\$@\1@p'`" +hgversion="`LANGUAGE=en hg --version 2> /dev/null | sed -n -e 's@^Mercurial Distributed SCM (version \([^+]*\).*)\$@\1@p'`" if [ "x${hgversion}" = "x" ] ; then error "Could not determine Mercurial version of $hgwhere" fi diff --git a/hotspot/.hgtags b/hotspot/.hgtags index 2dbb04816d9..518ab26c6a0 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -429,3 +429,6 @@ dd472cdacc32e3afc7c5bfa7ef16ea0e0befb7fa jdk9-b23 dde2d03b0ea46a27650839e3a1d212c7c1f7b4c8 jdk9-b24 6de94e8693240cec8aae11f6b42f43433456a733 jdk9-b25 48b95a073d752d6891cc0d1d2836b321ecf3ce0c jdk9-b26 +f95347244306affc32ce3056f27ceff7b2100810 jdk9-b27 +657294869d7ff063e055f5492cab7ce5612ca851 jdk9-b28 +deb29e92f68ace2808a36ecfa18c7d61dcb645bb jdk9-b29 diff --git a/jaxp/.hgtags b/jaxp/.hgtags index 051c0879c7b..40f6d552164 100644 --- a/jaxp/.hgtags +++ b/jaxp/.hgtags @@ -269,3 +269,5 @@ f9c82769a6bc2b219a8f01c24afe5c91039267d7 jdk9-b19 345af113f57206711f75089c3ebf84a36a789122 jdk9-b24 73757f4b8aa353ca8937abc07e79e7ece4c011a1 jdk9-b25 a5aea8318ae4a9c2105228568688875142d70344 jdk9-b26 +2bfaf29cc90b19948938e3ef1a0983eee68806c7 jdk9-b27 +dc1e26434b3fd7e9b8eeab149103c1e30965f95c jdk9-b28 diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/Constants.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/Constants.java index 4e276fb6ad6..3a84797138b 100644 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/Constants.java +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/Constants.java @@ -1,13 +1,10 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. - */ - -/* - * Copyright 2005 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -41,6 +38,9 @@ public final class Constants { public static final String NS_XMLSCHEMA = "http://www.w3.org/2001/XMLSchema".intern(); public static final String NS_DTD = "http://www.w3.org/TR/REC-xml".intern(); + // Schema Versions: + public static final String W3C_XML_SCHEMA10_NS_URI = "http://www.w3.org/XML/XMLSchema/v1.0".intern(); + // Schema features public static final String SUN_SCHEMA_FEATURE_PREFIX = "http://java.sun.com/xml/schema/features/"; public static final String SUN_REPORT_IGNORED_ELEMENT_CONTENT_WHITESPACE = "report-ignored-element-content-whitespace"; @@ -487,6 +487,40 @@ public final class Constants { /** XInclude fixup language feature ("xinclude/fixup-language"). */ public static final String XINCLUDE_FIXUP_LANGUAGE_FEATURE = "xinclude/fixup-language"; + /** + * Feature to ignore xsi:type attributes on elements during validation, + * until a global element declaration is found. ("validation/schema/ignore-xsi-type-until-elemdecl") + * If this feature is on when validating a document, then beginning at the validation root + * element, xsi:type attributes are ignored until a global element declaration is + * found for an element. Once a global element declaration has been found, xsi:type + * attributes will start being processed for the sub-tree beginning at the element for + * which the declaration was found. + * + * Suppose an element A has two element children, B and C. + * + * If a global element declaration is found for A, xsi:type attributes on A, B and C, + * and all of B and C's descendents, will be processed. + * + * If no global element declaration is found for A or B, but one is found for C, + * then xsi:type attributes will be ignored on A and B (and any descendents of B, + * until a global element declaration is found), but xsi:type attributes will be + * processed for C and all of C's descendents. + * + * Once xsi:type attributes stop being ignored for a subtree, they do not start + * being ignored again, even if more elements are encountered for which no global + * element declaration can be found. + */ + public static final String IGNORE_XSI_TYPE_FEATURE = "validation/schema/ignore-xsi-type-until-elemdecl"; + + /** Perform checking of ID/IDREFs ("validation/id-idref-checking") */ + public static final String ID_IDREF_CHECKING_FEATURE = "validation/id-idref-checking"; + + /** Feature to ignore errors caused by identity constraints ("validation/identity-constraint-checking") */ + public static final String IDC_CHECKING_FEATURE = "validation/identity-constraint-checking"; + + /** Feature to ignore errors caused by unparsed entities ("validation/unparsed-entity-checking") */ + public static final String UNPARSED_ENTITY_CHECKING_FEATURE = "validation/unparsed-entity-checking"; + /** * Internal feature. When set to true the schema validator will only use * schema components from the grammar pool provided. @@ -598,6 +632,8 @@ public final class Constants { /** Validation manager property ("internal/validation-manager"). */ public static final String VALIDATION_MANAGER_PROPERTY = "internal/validation-manager"; + /** Schema type of the root element in a document ("validation/schema/root-type-definition"). */ + public static final String ROOT_TYPE_DEFINITION_PROPERTY = "validation/schema/root-type-definition"; /** XPointer Schema property ("xpointer-schema"). */ public static final String XPOINTER_SCHEMA_PROPERTY = "xpointer-schema"; @@ -739,6 +775,10 @@ public final class Constants { XINCLUDE_FEATURE, XINCLUDE_FIXUP_BASE_URIS_FEATURE, XINCLUDE_FIXUP_LANGUAGE_FEATURE, + IGNORE_XSI_TYPE_FEATURE, + ID_IDREF_CHECKING_FEATURE, + IDC_CHECKING_FEATURE, + UNPARSED_ENTITY_CHECKING_FEATURE, NAMESPACE_GROWTH_FEATURE, TOLERATE_DUPLICATES_FEATURE, }; @@ -762,6 +802,7 @@ public final class Constants { VALIDATION_MANAGER_PROPERTY, BUFFER_SIZE_PROPERTY, SECURITY_MANAGER_PROPERTY, + ROOT_TYPE_DEFINITION_PROPERTY, LOCALE_PROPERTY, SCHEMA_DV_FACTORY_PROPERTY, }; diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/ValidatedInfo.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/ValidatedInfo.java index e6b8f267a5d..cc84353bd64 100644 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/ValidatedInfo.java +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/dv/ValidatedInfo.java @@ -1,13 +1,10 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -/* - * Copyright 2001, 2002,2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -21,6 +18,7 @@ package com.sun.org.apache.xerces.internal.impl.dv; import com.sun.org.apache.xerces.internal.xs.ShortList; +import com.sun.org.apache.xerces.internal.xs.XSConstants; /** * Class to get the information back after content is validated. This info @@ -95,4 +93,60 @@ public class ValidatedInfo { else return actualValue.toString(); } + + /** + * Returns true if the two ValidatedInfo objects can be compared in the same + * value space. + */ + public static boolean isComparable(ValidatedInfo info1, ValidatedInfo info2) { + final short primitiveType1 = convertToPrimitiveKind(info1.actualValueType); + final short primitiveType2 = convertToPrimitiveKind(info2.actualValueType); + if (primitiveType1 != primitiveType2) { + return (primitiveType1 == XSConstants.ANYSIMPLETYPE_DT && primitiveType2 == XSConstants.STRING_DT || + primitiveType1 == XSConstants.STRING_DT && primitiveType2 == XSConstants.ANYSIMPLETYPE_DT); + } + else if (primitiveType1 == XSConstants.LIST_DT || primitiveType1 == XSConstants.LISTOFUNION_DT) { + final ShortList typeList1 = info1.itemValueTypes; + final ShortList typeList2 = info2.itemValueTypes; + final int typeList1Length = typeList1 != null ? typeList1.getLength() : 0; + final int typeList2Length = typeList2 != null ? typeList2.getLength() : 0; + if (typeList1Length != typeList2Length) { + return false; + } + for (int i = 0; i < typeList1Length; ++i) { + final short primitiveItem1 = convertToPrimitiveKind(typeList1.item(i)); + final short primitiveItem2 = convertToPrimitiveKind(typeList2.item(i)); + if (primitiveItem1 != primitiveItem2) { + if (primitiveItem1 == XSConstants.ANYSIMPLETYPE_DT && primitiveItem2 == XSConstants.STRING_DT || + primitiveItem1 == XSConstants.STRING_DT && primitiveItem2 == XSConstants.ANYSIMPLETYPE_DT) { + continue; + } + return false; + } + } + } + return true; + } + + /** + * Returns the primitive type of the given type. + * @param valueType A value type as defined in XSConstants. + * @return The primitive type from which valueType was derived. + */ + private static short convertToPrimitiveKind(short valueType) { + /** Primitive datatypes. */ + if (valueType <= XSConstants.NOTATION_DT) { + return valueType; + } + /** Types derived from string. */ + if (valueType <= XSConstants.ENTITY_DT) { + return XSConstants.STRING_DT; + } + /** Types derived from decimal. */ + if (valueType <= XSConstants.POSITIVEINTEGER_DT) { + return XSConstants.DECIMAL_DT; + } + /** Other types. */ + return valueType; + } } diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages.properties b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages.properties index d986140a86e..5b73376eb50 100644 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages.properties +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLSchemaMessages.properties @@ -14,20 +14,18 @@ # Identity constraints - AbsentKeyValue = Identity Constraint error (cvc-identity-constraint.4.2.1): element \"{0}\" has a key with no value. + AbsentKeyValue = cvc-identity-constraint.4.2.1.a: Element \"{0}\" has no value for the key \"{1}\". DuplicateField = Duplicate match in scope for field \"{0}\". - DuplicateKey = Duplicate key value [{0}] declared for identity constraint of element \"{1}\". - DuplicateUnique = Duplicate unique value [{0}] declared for identity constraint of element \"{1}\". - FieldMultipleMatch = Identity constraint error: field \"{0}\" matches more than one value within the scope of its selector; fields must match unique values. + DuplicateKey = cvc-identity-constraint.4.2.2: Duplicate key value [{0}] declared for identity constraint \"{2}\" of element \"{1}\". + DuplicateUnique = cvc-identity-constraint.4.1: Duplicate unique value [{0}] declared for identity constraint \"{2}\" of element \"{1}\". + FieldMultipleMatch = cvc-identity-constraint.3: Field \"{0}\" of identity constraint \"{1}\" matches more than one value within the scope of its selector; fields must match unique values. FixedDiffersFromActual = The content of this element is not equivalent to the value of the \"fixed\" attribute in the element's declaration in the schema. - KeyMatchesNillable = Identity Constraint error (cvc-identity-constraint.4.2.3): element \"{0}\" has a key which matches an element which has nillable set to true. - KeyNotEnoughValues = Not enough values specified for identity constraint specified for element \"{0}\". - KeyNotFound = Key ''{0}'' with value ''{1}'' not found for identity constraint of element ''{2}''. - KeyRefNotEnoughValues = Not enough values specified for identity constraint specified for element \"{0}\". + KeyMatchesNillable = cvc-identity-constraint.4.2.3: Element \"{0}\" has the key \"{1}\" which matches an element which has nillable set to true. + KeyNotEnoughValues = cvc-identity-constraint.4.2.1.b: Not enough values specified for identity constraint specified for element \"{0}\". + KeyNotFound = cvc-identity-constraint.4.3: Key ''{0}'' with value ''{1}'' not found for identity constraint of element ''{2}''. KeyRefOutOfScope = Identity Constraint error: identity constraint \"{0}\" has a keyref which refers to a key or unique that is out of scope. KeyRefReferNotFound = Key reference declaration \"{0}\" refers to unknown key with name \"{1}\". - UniqueNotEnoughValues = Not enough values specified for identity constraint specified for element \"{0}\". - UnknownField = Internal identity constraint error; unknown field \"{0}\". + UnknownField = Internal identity constraint error; unknown field \"{0}\" for identity constraint \"{2}\" specified for element \"{1}\". # Ideally, we should only use the following error keys, not the ones under # "Identity constraints". And we should cover all of the following errors. @@ -79,6 +77,7 @@ cvc-minLength-valid = cvc-minLength-valid: Value ''{0}'' with length = ''{1}'' is not facet-valid with respect to minLength ''{2}'' for type ''{3}''. cvc-pattern-valid = cvc-pattern-valid: Value ''{0}'' is not facet-valid with respect to pattern ''{1}'' for type ''{2}''. cvc-totalDigits-valid = cvc-totalDigits-valid: Value ''{0}'' has {1} total digits, but the number of total digits has been limited to {2}. + cvc-type.1 = cvc-type.1: The type definition ''{0}'' was not found. cvc-type.2 = cvc-type.2: The type definition cannot be abstract for element {0}. cvc-type.3.1.1 = cvc-type.3.1.1: Element ''{0}'' is a simple type, so it cannot have attributes, excepting those whose namespace name is identical to ''http://www.w3.org/2001/XMLSchema-instance'' and whose [local name] is one of ''type'', ''nil'', ''schemaLocation'' or ''noNamespaceSchemaLocation''. However, the attribute, ''{1}'' was found. cvc-type.3.1.2 = cvc-type.3.1.2: Element ''{0}'' is a simple type, so it must have no element information item [children]. diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/validation/ConfigurableValidationState.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/validation/ConfigurableValidationState.java new file mode 100644 index 00000000000..ac8406dd325 --- /dev/null +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/validation/ConfigurableValidationState.java @@ -0,0 +1,123 @@ +/* + * Copyright 2006 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.sun.org.apache.xerces.internal.impl.validation; + +/** + *

An extension of ValidationState which can be configured to turn + * off checking for ID/IDREF errors and unparsed entity errors.

+ * + * @xerces.internal + * + * @author Peter McCracken, IBM + */ +public final class ConfigurableValidationState extends ValidationState { + + /** + * Whether to check for ID/IDREF errors + */ + private boolean fIdIdrefChecking; + + /** + * Whether to check for unparsed entity errors + */ + private boolean fUnparsedEntityChecking; + + /** + * Creates a new ConfigurableValidationState. + * By default, error checking for both ID/IDREFs + * and unparsed entities are turned on. + */ + public ConfigurableValidationState() { + super(); + fIdIdrefChecking = true; + fUnparsedEntityChecking = true; + } + + /** + * Turns checking for ID/IDREF errors on and off. + * @param setting: true to turn on error checking + * false to turn off error checking + */ + public void setIdIdrefChecking(boolean setting) { + fIdIdrefChecking = setting; + } + + /** + * Turns checking for unparsed entity errors on and off. + * @param setting: true to turn on error checking + * false to turn off error checking + */ + public void setUnparsedEntityChecking(boolean setting) { + fUnparsedEntityChecking = setting; + } + + /** + * Checks if all IDREFs have a corresponding ID. + * @return null, if ID/IDREF checking is turned off + * otherwise, returns the value of the super implementation + */ + public String checkIDRefID() { + return (fIdIdrefChecking) ? super.checkIDRefID() : null; + } + + /** + * Checks if an ID has already been declared. + * @return false, if ID/IDREF checking is turned off + * otherwise, returns the value of the super implementation + */ + public boolean isIdDeclared(String name) { + return (fIdIdrefChecking) ? super.isIdDeclared(name) : false; + } + + /** + * Checks if an entity is declared. + * @return true, if unparsed entity checking is turned off + * otherwise, returns the value of the super implementation + */ + public boolean isEntityDeclared(String name) { + return (fUnparsedEntityChecking) ? super.isEntityDeclared(name) : true; + } + + /** + * Checks if an entity is unparsed. + * @return true, if unparsed entity checking is turned off + * otherwise, returns the value of the super implementation + */ + public boolean isEntityUnparsed(String name) { + return (fUnparsedEntityChecking) ? super.isEntityUnparsed(name) : true; + } + + /** + * Adds the ID, if ID/IDREF checking is enabled. + * @param the ID to add + */ + public void addId(String name) { + if (fIdIdrefChecking) { + super.addId(name); + } + } + + /** + * Adds the IDREF, if ID/IDREF checking is enabled. + * @param the IDREF to add + */ + public void addIdRef(String name) { + if (fIdIdrefChecking) { + super.addIdRef(name); + } + } +} diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java index fd03b7a8f75..dbe788ac599 100644 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java @@ -1,13 +1,10 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -/* - * Copyright 1999-2005 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -38,6 +35,7 @@ import com.sun.org.apache.xerces.internal.impl.dv.DatatypeException; import com.sun.org.apache.xerces.internal.impl.dv.InvalidDatatypeValueException; import com.sun.org.apache.xerces.internal.impl.dv.ValidatedInfo; import com.sun.org.apache.xerces.internal.impl.dv.XSSimpleType; +import com.sun.org.apache.xerces.internal.impl.validation.ConfigurableValidationState; import com.sun.org.apache.xerces.internal.impl.validation.ValidationManager; import com.sun.org.apache.xerces.internal.impl.validation.ValidationState; import com.sun.org.apache.xerces.internal.impl.xs.identity.Field; @@ -185,6 +183,22 @@ public class XMLSchemaValidator protected static final String TOLERATE_DUPLICATES = Constants.XERCES_FEATURE_PREFIX + Constants.TOLERATE_DUPLICATES_FEATURE; + /** Feature identifier: whether to ignore xsi:type attributes until a global element declaration is encountered */ + protected static final String IGNORE_XSI_TYPE = + Constants.XERCES_FEATURE_PREFIX + Constants.IGNORE_XSI_TYPE_FEATURE; + + /** Feature identifier: whether to ignore ID/IDREF errors */ + protected static final String ID_IDREF_CHECKING = + Constants.XERCES_FEATURE_PREFIX + Constants.ID_IDREF_CHECKING_FEATURE; + + /** Feature identifier: whether to ignore unparsed entity errors */ + protected static final String UNPARSED_ENTITY_CHECKING = + Constants.XERCES_FEATURE_PREFIX + Constants.UNPARSED_ENTITY_CHECKING_FEATURE; + + /** Feature identifier: whether to ignore identity constraint errors */ + protected static final String IDENTITY_CONSTRAINT_CHECKING = + Constants.XERCES_FEATURE_PREFIX + Constants.IDC_CHECKING_FEATURE; + protected static final String REPORT_WHITESPACE = Constants.SUN_SCHEMA_FEATURE_PREFIX + Constants.SUN_REPORT_IGNORED_ELEMENT_CONTENT_WHITESPACE; @@ -228,6 +242,10 @@ public class XMLSchemaValidator protected static final String JAXP_SCHEMA_LANGUAGE = Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_LANGUAGE; + /** Property identifier: root type definition. */ + protected static final String ROOT_TYPE_DEF = + Constants.XERCES_PROPERTY_PREFIX + Constants.ROOT_TYPE_DEFINITION_PROPERTY; + /** Property identifier: Schema DV Factory */ protected static final String SCHEMA_DV_FACTORY = Constants.XERCES_PROPERTY_PREFIX + Constants.SCHEMA_DV_FACTORY_PROPERTY; @@ -254,6 +272,10 @@ public class XMLSchemaValidator VALIDATE_ANNOTATIONS, HONOUR_ALL_SCHEMALOCATIONS, USE_GRAMMAR_POOL_ONLY, + IGNORE_XSI_TYPE, + ID_IDREF_CHECKING, + IDENTITY_CONSTRAINT_CHECKING, + UNPARSED_ENTITY_CHECKING, NAMESPACE_GROWTH, TOLERATE_DUPLICATES, USE_SERVICE_MECHANISM @@ -267,6 +289,10 @@ public class XMLSchemaValidator // those set by the application. This goes against the // whole purpose of XMLComponent#getFeatureDefault but // it can't be helped in this case. -Ac + // NOTE: Instead of adding default values here, add them (and + // the corresponding recognized features) to the objects + // that have an XMLSchemaValidator instance as a member, + // such as the parser configurations. -PM null, //Boolean.FALSE, null, //Boolean.FALSE, null, //Boolean.FALSE, @@ -279,6 +305,10 @@ public class XMLSchemaValidator null, null, null, + null, + null, + null, + null, Boolean.TRUE }; @@ -293,13 +323,14 @@ public class XMLSchemaValidator SCHEMA_NONS_LOCATION, JAXP_SCHEMA_SOURCE, JAXP_SCHEMA_LANGUAGE, + ROOT_TYPE_DEF, SCHEMA_DV_FACTORY, XML_SECURITY_PROPERTY_MANAGER }; /** Property defaults. */ private static final Object[] PROPERTY_DEFAULTS = - { null, null, null, null, null, null, null, null, null, null, null, null, null}; + { null, null, null, null, null, null, null, null, null, null, null}; // this is the number of valuestores of each kind // we expect an element to have. It's almost @@ -482,7 +513,7 @@ public class XMLSchemaValidator // updated during reset protected ValidationManager fValidationManager = null; - protected ValidationState fValidationState = new ValidationState(); + protected ConfigurableValidationState fValidationState = new ConfigurableValidationState(); protected XMLGrammarPool fGrammarPool; // schema location property values @@ -562,6 +593,9 @@ public class XMLSchemaValidator * this exception. */ public void setProperty(String propertyId, Object value) throws XMLConfigurationException { + if (propertyId.equals(ROOT_TYPE_DEF)) { + fRootTypeQName = (javax.xml.namespace.QName)value; + } } // setProperty(String,Object) /** @@ -1234,6 +1268,12 @@ public class XMLSchemaValidator /** temporary qname */ private final QName fTempQName = new QName(); + private javax.xml.namespace.QName fRootTypeQName = null; + + private int fIgnoreXSITypeDepth; + + private boolean fIDCChecking; + /** temporary validated info */ private ValidatedInfo fValidatedInfo = new ValidatedInfo(); @@ -1384,6 +1424,38 @@ public class XMLSchemaValidator fValidationManager.addValidationState(fValidationState); fValidationState.setSymbolTable(fSymbolTable); + boolean ignoreXSIType; + try { + ignoreXSIType = componentManager.getFeature(IGNORE_XSI_TYPE); + } + catch (XMLConfigurationException e) { + ignoreXSIType = false; + } + // An initial value of -1 means that the root element considers itself + // below the depth where xsi:type stopped being ignored (which means that + // xsi:type attributes will not be ignored for the entire document) + fIgnoreXSITypeDepth = ignoreXSIType ? 0 : -1; + + try { + fIDCChecking = componentManager.getFeature(IDENTITY_CONSTRAINT_CHECKING); + } + catch (XMLConfigurationException e) { + fIDCChecking = true; + } + + try { + fValidationState.setIdIdrefChecking(componentManager.getFeature(ID_IDREF_CHECKING)); + } + catch (XMLConfigurationException e) { + fValidationState.setIdIdrefChecking(true); + } + + try { + fValidationState.setUnparsedEntityChecking(componentManager.getFeature(UNPARSED_ENTITY_CHECKING)); + } + catch (XMLConfigurationException e) { + fValidationState.setUnparsedEntityChecking(true); + } // get schema location properties try { @@ -1550,7 +1622,9 @@ public class XMLSchemaValidator // handle start document void handleStartDocument(XMLLocator locator, String encoding) { - fValueStoreCache.startDocument(); + if (fIDCChecking) { + fValueStoreCache.startDocument(); + } if (fAugPSVI) { fCurrentPSVI.fGrammars = null; fCurrentPSVI.fSchemaInformation = null; @@ -1558,7 +1632,9 @@ public class XMLSchemaValidator } // handleStartDocument(XMLLocator,String) void handleEndDocument() { - fValueStoreCache.endDocument(); + if (fIDCChecking) { + fValueStoreCache.endDocument(); + } } // handleEndDocument() // handle character contents @@ -1850,22 +1926,54 @@ public class XMLSchemaValidator return augs; } - // try again to get the element decl: - // case 1: find declaration for root element - // case 2: find declaration for element from another namespace - if (fCurrentElemDecl == null) { - if (sGrammar != null) { - fCurrentElemDecl = sGrammar.getGlobalElementDecl(element.localpart); + // 1.2.1.1 A type definition was stipulated by the processor + if (fElementDepth == 0 && fRootTypeQName != null) { + String rootTypeNamespace = fRootTypeQName.getNamespaceURI(); + if (rootTypeNamespace != null && rootTypeNamespace.equals(XMLConstants.NULL_NS_URI)) { + rootTypeNamespace = null; + } + SchemaGrammar grammarForRootType = + findSchemaGrammar( + XSDDescription.CONTEXT_ELEMENT, rootTypeNamespace, null, null, null); + if (grammarForRootType != null) { + fCurrentType = grammarForRootType.getGlobalTypeDecl(fRootTypeQName.getLocalPart()); + } + if (fCurrentType == null) { + String typeName = (fRootTypeQName.getPrefix().equals(XMLConstants.DEFAULT_NS_PREFIX)) ? + fRootTypeQName.getLocalPart() : + fRootTypeQName.getPrefix()+":"+fRootTypeQName.getLocalPart(); + reportSchemaError("cvc-type.1", new Object[] {typeName}); } } - if (fCurrentElemDecl != null) { - // then get the type - fCurrentType = fCurrentElemDecl.fType; + // if there was no processor stipulated type + if (fCurrentType == null) { + // try again to get the element decl: + // case 1: find declaration for root element + // case 2: find declaration for element from another namespace + if (fCurrentElemDecl == null) { + if (sGrammar != null) { + fCurrentElemDecl = sGrammar.getGlobalElementDecl(element.localpart); + } + } + + if (fCurrentElemDecl != null) { + // then get the type + fCurrentType = fCurrentElemDecl.fType; + } } - // get type from xsi:type - String xsiType = attributes.getValue(SchemaSymbols.URI_XSI, SchemaSymbols.XSI_TYPE); + + // check if we should be ignoring xsi:type on this element + if (fElementDepth == fIgnoreXSITypeDepth && fCurrentElemDecl == null) { + fIgnoreXSITypeDepth++; + } + + // process xsi:type attribute information + String xsiType = null; + if (fElementDepth >= fIgnoreXSITypeDepth) { + xsiType = attributes.getValue(SchemaSymbols.URI_XSI, SchemaSymbols.XSI_TYPE); + } // if no decl/type found for the current element if (fCurrentType == null && xsiType == null) { @@ -2044,13 +2152,17 @@ public class XMLSchemaValidator XSComplexTypeDecl ctype = (XSComplexTypeDecl) fCurrentType; attrGrp = ctype.getAttrGrp(); } - // activate identity constraints - fValueStoreCache.startElement(); - fMatcherStack.pushContext(); - if (fCurrentElemDecl != null && fCurrentElemDecl.fIDCPos > 0) { - fIdConstraint = true; - // initialize when identity constrains are defined for the elem - fValueStoreCache.initValueStoresFor(fCurrentElemDecl, this); + + if (fIDCChecking) { + // activate identity constraints + fValueStoreCache.startElement(); + fMatcherStack.pushContext(); + //if (fCurrentElemDecl != null && fCurrentElemDecl.fIDCPos > 0 && !fIgnoreIDC) { + if (fCurrentElemDecl != null && fCurrentElemDecl.fIDCPos > 0) { + fIdConstraint = true; + // initialize when identity constrains are defined for the elem + fValueStoreCache.initValueStoresFor(fCurrentElemDecl, this); + } } processAttributes(element, attributes, attrGrp); @@ -2138,66 +2250,75 @@ public class XMLSchemaValidator // now validate the content of the element processElementContent(element); - // Element Locally Valid (Element) - // 6 The element information item must be valid with respect to each of the {identity-constraint definitions} as per Identity-constraint Satisfied (3.11.4). + if (fIDCChecking) { + // Element Locally Valid (Element) + // 6 The element information item must be valid with respect to each of the {identity-constraint definitions} as per Identity-constraint Satisfied (3.11.4). - // call matchers and de-activate context - int oldCount = fMatcherStack.getMatcherCount(); - for (int i = oldCount - 1; i >= 0; i--) { - XPathMatcher matcher = fMatcherStack.getMatcherAt(i); - if (fCurrentElemDecl == null) - matcher.endElement(element, null, false, fValidatedInfo.actualValue, fValidatedInfo.actualValueType, fValidatedInfo.itemValueTypes); + // call matchers and de-activate context + int oldCount = fMatcherStack.getMatcherCount(); + for (int i = oldCount - 1; i >= 0; i--) { + XPathMatcher matcher = fMatcherStack.getMatcherAt(i); + if (fCurrentElemDecl == null) + matcher.endElement(element, null, false, fValidatedInfo.actualValue, fValidatedInfo.actualValueType, fValidatedInfo.itemValueTypes); - else - matcher.endElement( - element, - fCurrentType, - fCurrentElemDecl.getNillable(), - fDefaultValue == null - ? fValidatedInfo.actualValue - : fCurrentElemDecl.fDefault.actualValue, - fDefaultValue == null - ? fValidatedInfo.actualValueType - : fCurrentElemDecl.fDefault.actualValueType, - fDefaultValue == null - ? fValidatedInfo.itemValueTypes - : fCurrentElemDecl.fDefault.itemValueTypes); - } + else + matcher.endElement( + element, + fCurrentType, + fCurrentElemDecl.getNillable(), + fDefaultValue == null + ? fValidatedInfo.actualValue + : fCurrentElemDecl.fDefault.actualValue, + fDefaultValue == null + ? fValidatedInfo.actualValueType + : fCurrentElemDecl.fDefault.actualValueType, + fDefaultValue == null + ? fValidatedInfo.itemValueTypes + : fCurrentElemDecl.fDefault.itemValueTypes); + } - if (fMatcherStack.size() > 0) { - fMatcherStack.popContext(); - } + if (fMatcherStack.size() > 0) { + fMatcherStack.popContext(); + } - int newCount = fMatcherStack.getMatcherCount(); - // handle everything *but* keyref's. - for (int i = oldCount - 1; i >= newCount; i--) { - XPathMatcher matcher = fMatcherStack.getMatcherAt(i); - if (matcher instanceof Selector.Matcher) { - Selector.Matcher selMatcher = (Selector.Matcher) matcher; - IdentityConstraint id; - if ((id = selMatcher.getIdentityConstraint()) != null - && id.getCategory() != IdentityConstraint.IC_KEYREF) { - fValueStoreCache.transplant(id, selMatcher.getInitialDepth()); + int newCount = fMatcherStack.getMatcherCount(); + // handle everything *but* keyref's. + for (int i = oldCount - 1; i >= newCount; i--) { + XPathMatcher matcher = fMatcherStack.getMatcherAt(i); + if (matcher instanceof Selector.Matcher) { + Selector.Matcher selMatcher = (Selector.Matcher) matcher; + IdentityConstraint id; + if ((id = selMatcher.getIdentityConstraint()) != null + && id.getCategory() != IdentityConstraint.IC_KEYREF) { + fValueStoreCache.transplant(id, selMatcher.getInitialDepth()); + } } } - } - // now handle keyref's/... - for (int i = oldCount - 1; i >= newCount; i--) { - XPathMatcher matcher = fMatcherStack.getMatcherAt(i); - if (matcher instanceof Selector.Matcher) { - Selector.Matcher selMatcher = (Selector.Matcher) matcher; - IdentityConstraint id; - if ((id = selMatcher.getIdentityConstraint()) != null - && id.getCategory() == IdentityConstraint.IC_KEYREF) { - ValueStoreBase values = - fValueStoreCache.getValueStoreFor(id, selMatcher.getInitialDepth()); - if (values != null) // nothing to do if nothing matched! - values.endDocumentFragment(); + // now handle keyref's/... + for (int i = oldCount - 1; i >= newCount; i--) { + XPathMatcher matcher = fMatcherStack.getMatcherAt(i); + if (matcher instanceof Selector.Matcher) { + Selector.Matcher selMatcher = (Selector.Matcher) matcher; + IdentityConstraint id; + if ((id = selMatcher.getIdentityConstraint()) != null + && id.getCategory() == IdentityConstraint.IC_KEYREF) { + ValueStoreBase values = + fValueStoreCache.getValueStoreFor(id, selMatcher.getInitialDepth()); + if (values != null) // nothing to do if nothing matched! + values.endDocumentFragment(); + } } } + fValueStoreCache.endElement(); + } + + // Check if we should modify the xsi:type ignore depth + // This check is independent of whether this is the validation root, + // and should be done before the element depth is decremented. + if (fElementDepth < fIgnoreXSITypeDepth) { + fIgnoreXSITypeDepth--; } - fValueStoreCache.endElement(); SchemaGrammar[] grammars = null; // have we reached the end tag of the validation root? @@ -2290,7 +2411,14 @@ public class XMLSchemaValidator // otherwise partial, and anything above this level will be partial else { fCurrentPSVI.fValidationAttempted = ElementPSVI.VALIDATION_PARTIAL; - fNFullValidationDepth = fNNoneValidationDepth = fElementDepth - 1; + } + + // this guarantees that depth settings do not cross-over between sibling nodes + if (fNFullValidationDepth == fElementDepth) { + fNFullValidationDepth = fElementDepth - 1; + } + if (fNNoneValidationDepth == fElementDepth) { + fNNoneValidationDepth = fElementDepth - 1; } if (fDefaultValue != null) @@ -2554,14 +2682,22 @@ public class XMLSchemaValidator // if there is no current type, set this one as current. // and we don't need to do extra checking if (fCurrentType != null) { + short block = XSConstants.DERIVATION_NONE; // 4.3 The local type definition must be validly derived from the {type definition} given the union of the {disallowed substitutions} and the {type definition}'s {prohibited substitutions}, as defined in Type Derivation OK (Complex) (3.4.6) (if it is a complex type definition), or given {disallowed substitutions} as defined in Type Derivation OK (Simple) (3.14.6) (if it is a simple type definition). - short block = fCurrentElemDecl.fBlock; - if (fCurrentType.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) + // Note: It's possible to have fCurrentType be non-null and fCurrentElemDecl + // be null, if the current type is set using the property "root-type-definition". + // In that case, we don't disallow any substitutions. -PM + if (fCurrentElemDecl != null) { + block = fCurrentElemDecl.fBlock; + } + if (fCurrentType.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) { block |= ((XSComplexTypeDecl) fCurrentType).fBlock; - if (!XSConstraints.checkTypeDerivationOk(type, fCurrentType, block)) + } + if (!XSConstraints.checkTypeDerivationOk(type, fCurrentType, block)) { reportSchemaError( - "cvc-elt.4.3", - new Object[] { element.rawname, xsiType, fCurrentType.getName()}); + "cvc-elt.4.3", + new Object[] { element.rawname, xsiType, fCurrentType.getName()}); + } } return type; @@ -2835,9 +2971,10 @@ public class XMLSchemaValidator } // get the value constraint from use or decl - // 4 The item's actual value must match the value of the {value constraint}, if it is present and fixed. // now check the value against the simpleType + // 4 The item's actual value must match the value of the {value constraint}, if it is present and fixed. + // now check the value against the simpleType if (actualValue != null && currDecl.getConstraintType() == XSConstants.VC_FIXED) { - if (!isComparable(fValidatedInfo, currDecl.fDefault) || !actualValue.equals(currDecl.fDefault.actualValue)) { + if (!ValidatedInfo.isComparable(fValidatedInfo, currDecl.fDefault) || !actualValue.equals(currDecl.fDefault.actualValue)) { reportSchemaError( "cvc-attribute.4", new Object[] { @@ -2852,7 +2989,7 @@ public class XMLSchemaValidator if (actualValue != null && currUse != null && currUse.fConstraintType == XSConstants.VC_FIXED) { - if (!isComparable(fValidatedInfo, currUse.fDefault) || !actualValue.equals(currUse.fDefault.actualValue)) { + if (!ValidatedInfo.isComparable(fValidatedInfo, currUse.fDefault) || !actualValue.equals(currUse.fDefault.actualValue)) { reportSchemaError( "cvc-complex-type.3.1", new Object[] { @@ -3083,7 +3220,7 @@ public class XMLSchemaValidator } // 5.2.2.2.2 If the {content type} of the actual type definition is a simple type definition, then the actual value of the item must match the canonical lexical representation of the {value constraint} value. else if (ctype.fContentType == XSComplexTypeDecl.CONTENTTYPE_SIMPLE) { - if (actualValue != null && (!isComparable(fValidatedInfo, fCurrentElemDecl.fDefault) + if (actualValue != null && (!ValidatedInfo.isComparable(fValidatedInfo, fCurrentElemDecl.fDefault) || !actualValue.equals(fCurrentElemDecl.fDefault.actualValue))) { reportSchemaError( "cvc-elt.5.2.2.2.2", @@ -3094,7 +3231,7 @@ public class XMLSchemaValidator } } } else if (fCurrentType.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) { - if (actualValue != null && (!isComparable(fValidatedInfo, fCurrentElemDecl.fDefault) + if (actualValue != null && (!ValidatedInfo.isComparable(fValidatedInfo, fCurrentElemDecl.fDefault) || !actualValue.equals(fCurrentElemDecl.fDefault.actualValue))) { // REVISIT: the spec didn't mention this case: fixed // value with simple type @@ -3240,53 +3377,6 @@ public class XMLSchemaValidator XMLErrorReporter.SEVERITY_ERROR); } - /** Returns true if the two ValidatedInfo objects can be compared in the same value space. **/ - private boolean isComparable(ValidatedInfo info1, ValidatedInfo info2) { - final short primitiveType1 = convertToPrimitiveKind(info1.actualValueType); - final short primitiveType2 = convertToPrimitiveKind(info2.actualValueType); - if (primitiveType1 != primitiveType2) { - return (primitiveType1 == XSConstants.ANYSIMPLETYPE_DT && primitiveType2 == XSConstants.STRING_DT || - primitiveType1 == XSConstants.STRING_DT && primitiveType2 == XSConstants.ANYSIMPLETYPE_DT); - } - else if (primitiveType1 == XSConstants.LIST_DT || primitiveType1 == XSConstants.LISTOFUNION_DT) { - final ShortList typeList1 = info1.itemValueTypes; - final ShortList typeList2 = info2.itemValueTypes; - final int typeList1Length = typeList1 != null ? typeList1.getLength() : 0; - final int typeList2Length = typeList2 != null ? typeList2.getLength() : 0; - if (typeList1Length != typeList2Length) { - return false; - } - for (int i = 0; i < typeList1Length; ++i) { - final short primitiveItem1 = convertToPrimitiveKind(typeList1.item(i)); - final short primitiveItem2 = convertToPrimitiveKind(typeList2.item(i)); - if (primitiveItem1 != primitiveItem2) { - if (primitiveItem1 == XSConstants.ANYSIMPLETYPE_DT && primitiveItem2 == XSConstants.STRING_DT || - primitiveItem1 == XSConstants.STRING_DT && primitiveItem2 == XSConstants.ANYSIMPLETYPE_DT) { - continue; - } - return false; - } - } - } - return true; - } - - private short convertToPrimitiveKind(short valueType) { - /** Primitive datatypes. */ - if (valueType <= XSConstants.NOTATION_DT) { - return valueType; - } - /** Types derived from string. */ - if (valueType <= XSConstants.ENTITY_DT) { - return XSConstants.STRING_DT; - } - /** Types derived from decimal. */ - if (valueType <= XSConstants.POSITIVEINTEGER_DT) { - return XSConstants.DECIMAL_DT; - } - /** Other types. */ - return valueType; - } private String expectedStr(Vector expected) { StringBuffer ret = new StringBuffer("{"); diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchema.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchema.java index 070086aa98b..5b05a6d1c28 100644 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchema.java +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchema.java @@ -1,13 +1,10 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -/* - * Copyright 2005 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -32,11 +29,19 @@ final class XMLSchema extends AbstractXMLSchema { /** The grammar pool is immutable */ private final XMLGrammarPool fGrammarPool; + /** Whether to consider this schema to be fully composed */ + private final boolean fFullyComposed; + /** Constructor */ public XMLSchema(XMLGrammarPool grammarPool) { - fGrammarPool = grammarPool; + this(grammarPool, true); } + public XMLSchema(XMLGrammarPool grammarPool, boolean fullyComposed) { + fGrammarPool = grammarPool; + fFullyComposed = fullyComposed; + } + /* * XSGrammarPoolContainer methods */ @@ -60,7 +65,7 @@ final class XMLSchema extends AbstractXMLSchema { * can be considered to be a fully composed schema */ public boolean isFullyComposed() { - return true; + return fFullyComposed; } } // XMLSchema diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java index a453dbf4227..3542750efaf 100644 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java @@ -1,13 +1,10 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -/* - * Copyright 2005 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -68,12 +65,21 @@ import org.xml.sax.SAXParseException; */ public final class XMLSchemaFactory extends SchemaFactory { - // property identifiers + // feature identifiers + + /** JAXP Source feature prefix. */ + private static final String JAXP_SOURCE_FEATURE_PREFIX = "http://javax.xml.transform"; /** Feature identifier: schema full checking. */ private static final String SCHEMA_FULL_CHECKING = Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_FULL_CHECKING; + /** Feature identifier: use grammar pool only. */ + private static final String USE_GRAMMAR_POOL_ONLY = + Constants.XERCES_FEATURE_PREFIX + Constants.USE_GRAMMAR_POOL_ONLY_FEATURE; + + // property identifiers + /** Property identifier: grammar pool. */ private static final String XMLGRAMMAR_POOL = Constants.XERCES_PROPERTY_PREFIX + Constants.XMLGRAMMAR_POOL_PROPERTY; @@ -104,7 +110,7 @@ public final class XMLSchemaFactory extends SchemaFactory { private final DOMEntityResolverWrapper fDOMEntityResolverWrapper; /** The ErrorHandlerWrapper */ - private ErrorHandlerWrapper fErrorHandlerWrapper; + private final ErrorHandlerWrapper fErrorHandlerWrapper; /** The SecurityManager. */ private XMLSecurityManager fSecurityManager; @@ -113,7 +119,10 @@ public final class XMLSchemaFactory extends SchemaFactory { private XMLSecurityPropertyManager fSecurityPropertyMgr; /** The container for the real grammar pool. */ - private XMLGrammarPoolWrapper fXMLGrammarPoolWrapper; + private final XMLGrammarPoolWrapper fXMLGrammarPoolWrapper; + + /** Whether or not to allow new schemas to be added to the grammar pool */ + private boolean fUseGrammarPoolOnly; /** * Indicates whether implementation parts should use @@ -138,6 +147,7 @@ public final class XMLSchemaFactory extends SchemaFactory { fXMLSchemaLoader.setProperty(XMLGRAMMAR_POOL, fXMLGrammarPoolWrapper); fXMLSchemaLoader.setEntityResolver(fDOMEntityResolverWrapper); fXMLSchemaLoader.setErrorHandler(fErrorHandlerWrapper); + fUseGrammarPoolOnly = true; // Enable secure processing feature by default fSecurityManager = new XMLSecurityManager(true); @@ -170,7 +180,8 @@ public final class XMLSchemaFactory extends SchemaFactory { "SchemaLanguageLengthZero", null)); } // only W3C XML Schema 1.0 is supported - return schemaLanguage.equals(XMLConstants.W3C_XML_SCHEMA_NS_URI); + return schemaLanguage.equals(XMLConstants.W3C_XML_SCHEMA_NS_URI) || + schemaLanguage.equals(Constants.W3C_XML_SCHEMA10_NS_URI); } public LSResourceResolver getResourceResolver() { @@ -202,7 +213,7 @@ public final class XMLSchemaFactory extends SchemaFactory { XMLInputSource[] xmlInputSources = new XMLInputSource[schemas.length]; InputStream inputStream; Reader reader; - for( int i=0; i 1) { - schema = new XMLSchema(new ReadOnlyGrammarPool(pool)); - } - else if (grammarCount == 1) { - Grammar[] grammars = pool.retrieveInitialGrammarSet(XMLGrammarDescription.XML_SCHEMA); - schema = new SimpleXMLSchema(grammars[0]); + if (fUseGrammarPoolOnly) { + if (grammarCount > 1) { + schema = new XMLSchema(new ReadOnlyGrammarPool(pool)); + } + else if (grammarCount == 1) { + Grammar[] grammars = pool.retrieveInitialGrammarSet(XMLGrammarDescription.XML_SCHEMA); + schema = new SimpleXMLSchema(grammars[0]); + } + else { + schema = new EmptyXMLSchema(); + } } else { - schema = new EmptyXMLSchema(); + schema = new XMLSchema(new ReadOnlyGrammarPool(pool), false); } propagateFeatures(schema); propagateProperties(schema); @@ -286,6 +305,14 @@ public final class XMLSchemaFactory extends SchemaFactory { } public Schema newSchema() throws SAXException { + /* + * It would make sense to return an EmptyXMLSchema object here, if + * fUseGrammarPoolOnly is set to true. However, because the default + * value of this feature is true, doing so would change the default + * behaviour of this method. Thus, we return a WeakReferenceXMLSchema + * regardless of the value of fUseGrammarPoolOnly. -PM + */ + // Use a Schema that uses the system id as the equality source. AbstractXMLSchema schema = new WeakReferenceXMLSchema(); propagateFeatures(schema); @@ -293,15 +320,38 @@ public final class XMLSchemaFactory extends SchemaFactory { return schema; } + public Schema newSchema(XMLGrammarPool pool) throws SAXException { + // If the "use-grammar-pool-only" feature is set to true + // prevent the application's grammar pool from being mutated + // by wrapping it in a ReadOnlyGrammarPool. + final AbstractXMLSchema schema = (fUseGrammarPoolOnly) ? + new XMLSchema(new ReadOnlyGrammarPool(pool)) : + new XMLSchema(pool, false); + propagateFeatures(schema); + return schema; + } + public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException { if (name == null) { throw new NullPointerException(JAXPValidationMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(), "FeatureNameNull", null)); } + if (name.startsWith(JAXP_SOURCE_FEATURE_PREFIX)) { + // Indicates to the caller that this SchemaFactory supports a specific JAXP Source. + if (name.equals(StreamSource.FEATURE) || + name.equals(SAXSource.FEATURE) || + name.equals(DOMSource.FEATURE) || + name.equals(StAXSource.FEATURE)) { + return true; + } + } if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) { return (fSecurityManager != null && fSecurityManager.isSecureProcessing()); } + else if (name.equals(USE_GRAMMAR_POOL_ONLY)) { + return fUseGrammarPoolOnly; + } try { return fXMLSchemaLoader.getFeature(name); } @@ -358,6 +408,16 @@ public final class XMLSchemaFactory extends SchemaFactory { throw new NullPointerException(JAXPValidationMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(), "FeatureNameNull", null)); } + if (name.startsWith(JAXP_SOURCE_FEATURE_PREFIX)) { + if (name.equals(StreamSource.FEATURE) || + name.equals(SAXSource.FEATURE) || + name.equals(DOMSource.FEATURE) || + name.equals(StAXSource.FEATURE)) { + throw new SAXNotSupportedException( + SAXMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(), + "feature-read-only", new Object [] {name})); + } + } if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) { if (System.getSecurityManager() != null && (!value)) { throw new SAXNotSupportedException( @@ -377,7 +437,12 @@ public final class XMLSchemaFactory extends SchemaFactory { fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager); return; - } else if (name.equals(Constants.ORACLE_FEATURE_SERVICE_MECHANISM)) { + } + else if (name.equals(USE_GRAMMAR_POOL_ONLY)) { + fUseGrammarPoolOnly = value; + return; + } + else if (name.equals(Constants.ORACLE_FEATURE_SERVICE_MECHANISM)) { //in secure mode, let _useServicesMechanism be determined by the constructor if (System.getSecurityManager() != null) return; diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java index 58a74191cf0..807dc917908 100644 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java @@ -1,13 +1,10 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -/* - * Copyright 2005 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -69,13 +66,41 @@ final class XMLSchemaValidatorComponentManager extends ParserConfigurationSettin private static final String VALIDATION = Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE; + /** Feature identifier: use grammar pool only. */ + private static final String USE_GRAMMAR_POOL_ONLY = + Constants.XERCES_FEATURE_PREFIX + Constants.USE_GRAMMAR_POOL_ONLY_FEATURE; + + /** Feature identifier: whether to ignore xsi:type attributes until a global element declaration is encountered */ + protected static final String IGNORE_XSI_TYPE = + Constants.XERCES_FEATURE_PREFIX + Constants.IGNORE_XSI_TYPE_FEATURE; + + /** Feature identifier: whether to ignore ID/IDREF errors */ + protected static final String ID_IDREF_CHECKING = + Constants.XERCES_FEATURE_PREFIX + Constants.ID_IDREF_CHECKING_FEATURE; + + /** Feature identifier: whether to ignore unparsed entity errors */ + protected static final String UNPARSED_ENTITY_CHECKING = + Constants.XERCES_FEATURE_PREFIX + Constants.UNPARSED_ENTITY_CHECKING_FEATURE; + + /** Feature identifier: whether to ignore identity constraint errors */ + protected static final String IDENTITY_CONSTRAINT_CHECKING = + Constants.XERCES_FEATURE_PREFIX + Constants.IDC_CHECKING_FEATURE; + + /** Feature identifier: disallow DOCTYPE declaration */ + private static final String DISALLOW_DOCTYPE_DECL_FEATURE = + Constants.XERCES_FEATURE_PREFIX + Constants.DISALLOW_DOCTYPE_DECL_FEATURE; + + /** Feature identifier: expose schema normalized value */ + private static final String NORMALIZE_DATA = + Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_NORMALIZED_VALUE; + /** Feature identifier: send element default value via characters() */ private static final String SCHEMA_ELEMENT_DEFAULT = Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_ELEMENT_DEFAULT; - /** Feature identifier: use grammar pool only. */ - private static final String USE_GRAMMAR_POOL_ONLY = - Constants.XERCES_FEATURE_PREFIX + Constants.USE_GRAMMAR_POOL_ONLY_FEATURE; + /** Feature identifier: augment PSVI */ + private static final String SCHEMA_AUGMENT_PSVI = + Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_AUGMENT_PSVI; // property identifiers @@ -230,10 +255,32 @@ final class XMLSchemaValidatorComponentManager extends ParserConfigurationSettin fErrorReporter.putMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN, new XSMessageFormatter()); // add all recognized features and properties and apply their defaults + final String [] recognizedFeatures = { + DISALLOW_DOCTYPE_DECL_FEATURE, + NORMALIZE_DATA, + SCHEMA_ELEMENT_DEFAULT, + SCHEMA_AUGMENT_PSVI + }; + addRecognizedFeatures(recognizedFeatures); + fFeatures.put(DISALLOW_DOCTYPE_DECL_FEATURE, Boolean.FALSE); + fFeatures.put(NORMALIZE_DATA, Boolean.FALSE); + fFeatures.put(SCHEMA_ELEMENT_DEFAULT, Boolean.FALSE); + fFeatures.put(SCHEMA_AUGMENT_PSVI, Boolean.TRUE); + addRecognizedParamsAndSetDefaults(fEntityManager, grammarContainer); addRecognizedParamsAndSetDefaults(fErrorReporter, grammarContainer); addRecognizedParamsAndSetDefaults(fSchemaValidator, grammarContainer); + /* TODO: are other XMLSchemaValidator default values never set? + * Initial investigation indicates that they aren't set, but + * that they all have default values of false, so it works out + * anyway -PM + */ + fFeatures.put(IGNORE_XSI_TYPE, Boolean.FALSE); + fFeatures.put(ID_IDREF_CHECKING, Boolean.TRUE); + fFeatures.put(IDENTITY_CONSTRAINT_CHECKING, Boolean.TRUE); + fFeatures.put(UNPARSED_ENTITY_CHECKING, Boolean.TRUE); + boolean secureProcessing = grammarContainer.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING); if (System.getSecurityManager() != null) { _isSecureMode = true; diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/StandardParserConfiguration.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/StandardParserConfiguration.java index 5ac09f8f866..464f93e8c92 100644 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/StandardParserConfiguration.java +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/StandardParserConfiguration.java @@ -1,13 +1,10 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -/* - * Copyright 2001-2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -109,6 +106,22 @@ public class StandardParserConfiguration protected static final String HONOUR_ALL_SCHEMALOCATIONS = Constants.XERCES_FEATURE_PREFIX + Constants.HONOUR_ALL_SCHEMALOCATIONS_FEATURE; + /** Feature identifier: whether to ignore xsi:type attributes until a global element declaration is encountered */ + protected static final String IGNORE_XSI_TYPE = + Constants.XERCES_FEATURE_PREFIX + Constants.IGNORE_XSI_TYPE_FEATURE; + + /** Feature identifier: whether to ignore ID/IDREF errors */ + protected static final String ID_IDREF_CHECKING = + Constants.XERCES_FEATURE_PREFIX + Constants.ID_IDREF_CHECKING_FEATURE; + + /** Feature identifier: whether to ignore unparsed entity errors */ + protected static final String UNPARSED_ENTITY_CHECKING = + Constants.XERCES_FEATURE_PREFIX + Constants.UNPARSED_ENTITY_CHECKING_FEATURE; + + /** Feature identifier: whether to ignore identity constraint errors */ + protected static final String IDENTITY_CONSTRAINT_CHECKING = + Constants.XERCES_FEATURE_PREFIX + Constants.IDC_CHECKING_FEATURE; + /** Feature identifier: namespace growth */ protected static final String NAMESPACE_GROWTH = Constants.XERCES_FEATURE_PREFIX + Constants.NAMESPACE_GROWTH_FEATURE; @@ -135,6 +148,10 @@ public class StandardParserConfiguration protected static final String SCHEMA_DV_FACTORY = Constants.XERCES_PROPERTY_PREFIX + Constants.SCHEMA_DV_FACTORY_PROPERTY; + /** Property identifier: root type definition. */ + protected static final String ROOT_TYPE_DEF = + Constants.XERCES_PROPERTY_PREFIX + Constants.ROOT_TYPE_DEFINITION_PROPERTY; + // // Data // @@ -211,6 +228,10 @@ public class StandardParserConfiguration // not-recognized exception to be thrown. -Ac XMLSCHEMA_VALIDATION, XMLSCHEMA_FULL_CHECKING, + IGNORE_XSI_TYPE, + ID_IDREF_CHECKING, + IDENTITY_CONSTRAINT_CHECKING, + UNPARSED_ENTITY_CHECKING, }; addRecognizedFeatures(recognizedFeatures); @@ -221,6 +242,10 @@ public class StandardParserConfiguration setFeature(GENERATE_SYNTHETIC_ANNOTATIONS, false); setFeature(VALIDATE_ANNOTATIONS, false); setFeature(HONOUR_ALL_SCHEMALOCATIONS, false); + setFeature(IGNORE_XSI_TYPE, false); + setFeature(ID_IDREF_CHECKING, true); + setFeature(IDENTITY_CONSTRAINT_CHECKING, true); + setFeature(UNPARSED_ENTITY_CHECKING, true); setFeature(NAMESPACE_GROWTH, false); setFeature(TOLERATE_DUPLICATES, false); @@ -233,11 +258,11 @@ public class StandardParserConfiguration // not-recognized exception to be thrown. -Ac SCHEMA_LOCATION, SCHEMA_NONS_LOCATION, + ROOT_TYPE_DEF, SCHEMA_DV_FACTORY, - }; - - addRecognizedProperties(recognizedProperties); + }; + addRecognizedProperties(recognizedProperties); } // (SymbolTable,XMLGrammarPool) // diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java index c0283f74e3c..975367eb2be 100644 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java @@ -1,13 +1,10 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! - */ -/* - * Copyright 2001-2005 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -184,7 +181,21 @@ public class XML11Configuration extends ParserConfigurationSettings protected static final String EXTERNAL_PARAMETER_ENTITIES = Constants.SAX_FEATURE_PREFIX + Constants.EXTERNAL_PARAMETER_ENTITIES_FEATURE; + /** Feature identifier: whether to ignore xsi:type attributes until a global element declaration is encountered */ + protected static final String IGNORE_XSI_TYPE = + Constants.XERCES_FEATURE_PREFIX + Constants.IGNORE_XSI_TYPE_FEATURE; + /** Feature identifier: whether to ignore ID/IDREF errors */ + protected static final String ID_IDREF_CHECKING = + Constants.XERCES_FEATURE_PREFIX + Constants.ID_IDREF_CHECKING_FEATURE; + + /** Feature identifier: whether to ignore unparsed entity errors */ + protected static final String UNPARSED_ENTITY_CHECKING = + Constants.XERCES_FEATURE_PREFIX + Constants.UNPARSED_ENTITY_CHECKING_FEATURE; + + /** Feature identifier: whether to ignore identity constraint errors */ + protected static final String IDENTITY_CONSTRAINT_CHECKING = + Constants.XERCES_FEATURE_PREFIX + Constants.IDC_CHECKING_FEATURE; // property identifiers @@ -267,6 +278,10 @@ public class XML11Configuration extends ParserConfigurationSettings protected static final String JAXP_SCHEMA_SOURCE = Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_SOURCE; + /** Property identifier: root type definition. */ + protected static final String ROOT_TYPE_DEF = + Constants.XERCES_PROPERTY_PREFIX + Constants.ROOT_TYPE_DEFINITION_PROPERTY; + /** Property identifier: locale. */ protected static final String LOCALE = Constants.XERCES_PROPERTY_PREFIX + Constants.LOCALE_PROPERTY; @@ -467,25 +482,27 @@ public class XML11Configuration extends ParserConfigurationSettings // add default recognized features final String[] recognizedFeatures = - { - CONTINUE_AFTER_FATAL_ERROR, LOAD_EXTERNAL_DTD, // from XMLDTDScannerImpl - VALIDATION, - NAMESPACES, - NORMALIZE_DATA, SCHEMA_ELEMENT_DEFAULT, SCHEMA_AUGMENT_PSVI, - GENERATE_SYNTHETIC_ANNOTATIONS, VALIDATE_ANNOTATIONS, - HONOUR_ALL_SCHEMALOCATIONS, NAMESPACE_GROWTH, - TOLERATE_DUPLICATES, - USE_GRAMMAR_POOL_ONLY, - // NOTE: These shouldn't really be here but since the XML Schema - // validator is constructed dynamically, its recognized - // features might not have been set and it would cause a - // not-recognized exception to be thrown. -Ac - XMLSCHEMA_VALIDATION, XMLSCHEMA_FULL_CHECKING, - EXTERNAL_GENERAL_ENTITIES, - EXTERNAL_PARAMETER_ENTITIES, - PARSER_SETTINGS, - XMLConstants.FEATURE_SECURE_PROCESSING - }; + { + CONTINUE_AFTER_FATAL_ERROR, LOAD_EXTERNAL_DTD, // from XMLDTDScannerImpl + VALIDATION, + NAMESPACES, + NORMALIZE_DATA, SCHEMA_ELEMENT_DEFAULT, SCHEMA_AUGMENT_PSVI, + GENERATE_SYNTHETIC_ANNOTATIONS, VALIDATE_ANNOTATIONS, + HONOUR_ALL_SCHEMALOCATIONS, IGNORE_XSI_TYPE, + ID_IDREF_CHECKING, IDENTITY_CONSTRAINT_CHECKING, + UNPARSED_ENTITY_CHECKING, + NAMESPACE_GROWTH, TOLERATE_DUPLICATES, + USE_GRAMMAR_POOL_ONLY, + // NOTE: These shouldn't really be here but since the XML Schema + // validator is constructed dynamically, its recognized + // features might not have been set and it would cause a + // not-recognized exception to be thrown. -Ac + XMLSCHEMA_VALIDATION, XMLSCHEMA_FULL_CHECKING, + EXTERNAL_GENERAL_ENTITIES, + EXTERNAL_PARAMETER_ENTITIES, + PARSER_SETTINGS, + XMLConstants.FEATURE_SECURE_PROCESSING + }; addRecognizedFeatures(recognizedFeatures); // set state for default features fFeatures.put(VALIDATION, Boolean.FALSE); @@ -500,6 +517,10 @@ public class XML11Configuration extends ParserConfigurationSettings fFeatures.put(GENERATE_SYNTHETIC_ANNOTATIONS, Boolean.FALSE); fFeatures.put(VALIDATE_ANNOTATIONS, Boolean.FALSE); fFeatures.put(HONOUR_ALL_SCHEMALOCATIONS, Boolean.FALSE); + fFeatures.put(IGNORE_XSI_TYPE, Boolean.FALSE); + fFeatures.put(ID_IDREF_CHECKING, Boolean.TRUE); + fFeatures.put(IDENTITY_CONSTRAINT_CHECKING, Boolean.TRUE); + fFeatures.put(UNPARSED_ENTITY_CHECKING, Boolean.TRUE); fFeatures.put(NAMESPACE_GROWTH, Boolean.FALSE); fFeatures.put(TOLERATE_DUPLICATES, Boolean.FALSE); fFeatures.put(USE_GRAMMAR_POOL_ONLY, Boolean.FALSE); @@ -508,41 +529,42 @@ public class XML11Configuration extends ParserConfigurationSettings // add default recognized properties final String[] recognizedProperties = - { - SYMBOL_TABLE, - ERROR_HANDLER, - ENTITY_RESOLVER, - ERROR_REPORTER, - ENTITY_MANAGER, - DOCUMENT_SCANNER, - DTD_SCANNER, - DTD_PROCESSOR, - DTD_VALIDATOR, - DATATYPE_VALIDATOR_FACTORY, - VALIDATION_MANAGER, - SCHEMA_VALIDATOR, - XML_STRING, - XMLGRAMMAR_POOL, - JAXP_SCHEMA_SOURCE, - JAXP_SCHEMA_LANGUAGE, - // NOTE: These shouldn't really be here but since the XML Schema - // validator is constructed dynamically, its recognized - // properties might not have been set and it would cause a - // not-recognized exception to be thrown. -Ac - SCHEMA_LOCATION, - SCHEMA_NONS_LOCATION, - LOCALE, - SCHEMA_DV_FACTORY, - SECURITY_MANAGER, - XML_SECURITY_PROPERTY_MANAGER + { + SYMBOL_TABLE, + ERROR_HANDLER, + ENTITY_RESOLVER, + ERROR_REPORTER, + ENTITY_MANAGER, + DOCUMENT_SCANNER, + DTD_SCANNER, + DTD_PROCESSOR, + DTD_VALIDATOR, + DATATYPE_VALIDATOR_FACTORY, + VALIDATION_MANAGER, + SCHEMA_VALIDATOR, + XML_STRING, + XMLGRAMMAR_POOL, + JAXP_SCHEMA_SOURCE, + JAXP_SCHEMA_LANGUAGE, + // NOTE: These shouldn't really be here but since the XML Schema + // validator is constructed dynamically, its recognized + // properties might not have been set and it would cause a + // not-recognized exception to be thrown. -Ac + SCHEMA_LOCATION, + SCHEMA_NONS_LOCATION, + ROOT_TYPE_DEF, + LOCALE, + SCHEMA_DV_FACTORY, + SECURITY_MANAGER, + XML_SECURITY_PROPERTY_MANAGER }; addRecognizedProperties(recognizedProperties); - if (symbolTable == null) { - symbolTable = new SymbolTable(); - } - fSymbolTable = symbolTable; - fProperties.put(SYMBOL_TABLE, fSymbolTable); + if (symbolTable == null) { + symbolTable = new SymbolTable(); + } + fSymbolTable = symbolTable; + fProperties.put(SYMBOL_TABLE, fSymbolTable); fGrammarPool = grammarPool; if (fGrammarPool != null) { @@ -597,8 +619,7 @@ public class XML11Configuration extends ParserConfigurationSettings // REVISIT: What is the right thing to do? -Ac } - fConfigUpdated = false; - + fConfigUpdated = false; } // (SymbolTable,XMLGrammarPool) // diff --git a/jaxws/.hgtags b/jaxws/.hgtags index 121910c3483..f1c5ee39bb4 100644 --- a/jaxws/.hgtags +++ b/jaxws/.hgtags @@ -272,3 +272,5 @@ ce19e0403ec8a80223cc47320c905b2a4d45881d jdk9-b23 0b35542d6bf32af23a9fc59a37c52aa091fee388 jdk9-b24 ab8726a0fcde897e4cfd1ea581ed90b0d8a7cbb7 jdk9-b25 9b43f3993b96c2213428e95127a2d3fd0e709d3a jdk9-b26 +dcaa586ab756420e9a62643793bacef2c84bf637 jdk9-b27 +5282a14f131f897cc9575872c0fae72d47dc4e65 jdk9-b28 diff --git a/jdk/.hgtags b/jdk/.hgtags index 9b0360a42ef..51acdfa12e1 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -269,3 +269,5 @@ f87c5be90e01a7ffb47947108eb3e0b0b1920880 jdk9-b20 875450e7ef8dde8f59db662ec1351ea30b8cb35d jdk9-b24 a31efe49556a7c12f9ea2c9ee8b4fae8aa67723a jdk9-b25 dde9f5cfde5f46e62ceb5fab81151578e5277aef jdk9-b26 +f0870554049807d3392bd7976ab114f7f2b7bafa jdk9-b27 +1828f73b35cfe35e460e41fd6e087ab1f83e0621 jdk9-b28 diff --git a/jdk/make/Bundles.gmk b/jdk/make/Bundles.gmk index 57ab08784cf..470a1e9bfb5 100644 --- a/jdk/make/Bundles.gmk +++ b/jdk/make/Bundles.gmk @@ -35,7 +35,7 @@ ifeq ($(OPENJDK_TARGET_OS), macosx) # JDK_BUNDLE_DIR and JRE_BUNDLE_DIR are defined in SPEC. - MACOSX_PLIST_SRC := $(JDK_TOPDIR)/make/bundle + MACOSX_PLIST_SRC := $(JDK_TOPDIR)/make/data/bundle # All these OPENJDK checks are needed since there is no coherency between # these values in open and closed. Should probably be fixed. diff --git a/jdk/make/CompileDemos.gmk b/jdk/make/CompileDemos.gmk index 531e61765a2..35bf0b4a691 100644 --- a/jdk/make/CompileDemos.gmk +++ b/jdk/make/CompileDemos.gmk @@ -29,9 +29,7 @@ include $(SPEC) include MakeBase.gmk include JavaCompilation.gmk include NativeCompilation.gmk - -# Setup the java compilers for the JDK build. -include SetupJava.gmk +include SetupJavaCompilers.gmk # Prepare the find cache. $(eval $(call FillCacheFind, $(JDK_TOPDIR)/src)) @@ -316,19 +314,6 @@ $(eval $(call SetupJVMTIDemo,compiledMethodLoad, agent_util)) $(eval $(call SetupJVMTIDemo,gctest, agent_util)) $(eval $(call SetupJVMTIDemo,heapTracker, agent_util java_crw_demo)) $(eval $(call SetupJVMTIDemo,heapViewer, agent_util)) - -# On AIX, hprof requires 'dladdr' from src/aix/porting/porting_aix.cpp -BUILD_LIBHPROF_AIX_EXTRA_SRC := -BUILD_LIBHPROF_AIX_EXTRA_CFLAGS := -ifeq ($(OPENJDK_TARGET_OS), aix) - BUILD_LIBHPROF_AIX_EXTRA_SRC += $(JDK_TOPDIR)/src/aix/porting - BUILD_LIBHPROF_AIX_EXTRA_CFLAGS += -I$(JDK_TOPDIR)/src/aix/porting -endif - -$(eval $(call SetupJVMTIDemo,hprof, java_crw_demo, \ - $(BUILD_LIBHPROF_AIX_EXTRA_CFLAGS), C, \ - -ldl, ws2_32.lib winmm.lib, -lsocket -lnsl, -lpthread, $(BUILD_LIBHPROF_AIX_EXTRA_SRC))) - $(eval $(call SetupJVMTIDemo,minst, agent_util java_crw_demo)) $(eval $(call SetupJVMTIDemo,mtrace, agent_util java_crw_demo)) $(eval $(call SetupJVMTIDemo,waiters, agent_util, , C++)) @@ -336,34 +321,6 @@ $(eval $(call SetupJVMTIDemo,versionCheck, agent_util)) ################################################################################################## -$(JDK_OUTPUTDIR)/demo/jpda/com/sun/tools/example/README: \ - $(JDK_TOPDIR)/src/demo/share/jpda/com/sun/tools/example/README - $(call install-file) - $(CHMOD) -f ug+w $@ - -$(eval $(call SetupArchive,JPDA_JAR, \ - $(JDK_OUTPUTDIR)/demo/jpda/com/sun/tools/example/README, \ - SRCS := $(JDK_TOPDIR)/src/demo/share/jpda \ - $(JDK_TOPDIR)/src/jdk.jdi/share/classes \ - $(JDK_OUTPUTDIR)/demo/jpda/com/sun/tools/example, \ - INCLUDES := com/sun/tools/example README, \ - SUFFIXES := .java .html .jj README, \ - JAR := $(JDK_OUTPUTDIR)/demo/jpda/examples.jar, \ - MANIFEST := $(JDK_TOPDIR)/make/data/mainmanifest/manifest.mf, \ - EXTRA_MANIFEST_ATTR := Main-Class:$$(SPACE), \ - SKIP_METAINF := true)) - -$(eval $(call SetupZipArchive,JPDA_ZIP, \ - SRC := $(JDK_TOPDIR)/src/demo/share/jpda \ - $(JDK_TOPDIR)/src/jdk.jdi/share/classes, \ - INCLUDES := com/sun/tools/example, \ - SUFFIXES := .java .html .jj README, \ - ZIP := $(JDK_OUTPUTDIR)/demo/jpda/src.zip)) - -BUILD_DEMOS += $(JPDA_JAR) $(JPDA_ZIP) - -################################################################################################## - $(JDK_OUTPUTDIR)/demo/management/index.html: $(DEMO_SHARE_SRC)/management/index.html $(call install-file) $(CHMOD) -f ug+w $@ diff --git a/jdk/make/CompileInterimRmic.gmk b/jdk/make/CompileInterimRmic.gmk index 74f789dfa61..79082cd415c 100644 --- a/jdk/make/CompileInterimRmic.gmk +++ b/jdk/make/CompileInterimRmic.gmk @@ -28,7 +28,7 @@ default: all include $(SPEC) include MakeBase.gmk include JavaCompilation.gmk -include SetupJava.gmk +include SetupJavaCompilers.gmk ########################################################################################## diff --git a/jdk/make/CopyIntoClasses.gmk b/jdk/make/CopyIntoClasses.gmk deleted file mode 100644 index a80c661ace9..00000000000 --- a/jdk/make/CopyIntoClasses.gmk +++ /dev/null @@ -1,202 +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. -# - -# Copy icu and _dict files used by the text break iterator - -COPY_PATTERNS := .icu _dict .dat _options .js aliasmap .spp .wav .css \ - .png .gif .xml .dtd .txt oqlhelp.html content-types.properties - -# These directories should not be copied at all -EXCLUDES += \ - java/awt/doc-files \ - java/lang/doc-files \ - javax/swing/doc-files \ - javax/swing/text/doc-files \ - javax/swing/plaf/synth/doc-files \ - javax/swing/undo/doc-files \ - sun/awt/X11/doc-files \ - sun/util/cldr/resources \ - # - -# These files should never be included -EXFILES += build.xml README.txt version.txt - -# These icons are handled in GensrcIcons.gmk -EXFILES += \ - sun/awt/X11/java-icon16.png \ - sun/awt/X11/java-icon24.png \ - sun/awt/X11/java-icon32.png \ - sun/awt/X11/java-icon48.png \ - $(wildcard $(JDK_TOPDIR)/src/share/classes/sun/awt/resources/*.png) \ - # - -ifndef OPENJDK - # Theses icons have closed replacements - SWING_PLAF_MOTIF_RESOURCES_DIR := $(JDK_TOPDIR)/src/share/classes/com/sun/java/swing/plaf/motif - EXFILES += \ - $(JDK_TOPDIR)/src/share/classes/com/sun/java/swing/plaf/windows/icons/JavaCup32.png \ - $(JDK_TOPDIR)/src/share/classes/javax/swing/plaf/basic/icons/JavaCup16.png \ - $(wildcard $(SWING_PLAF_MOTIF_RESOURCES_DIR)/icons/*.gif) \ - $(wildcard $(SWING_PLAF_MOTIF_RESOURCES_DIR)/icons/*.png) \ - # - - EXFILES += mib_core.txt -endif - -ifeq ($(ENABLE_JFR), true) - JFR_CONFIGURATION_DIR_CLOSED := $(JDK_TOPDIR)/src/closed/share/classes/oracle/jrockit/jfr/settings - COPY_FILES += \ - $(JFR_CONFIGURATION_DIR_CLOSED)/jfc.xsd -endif - -SWING_BEANINFO_RESOURCES_SRC_DIR = $(JDK_TOPDIR)/make/data/swingbeaninfo/images -SWING_BEANINFO_RESOURCES_SRC = $(wildcard $(SWING_BEANINFO_RESOURCES_SRC_DIR)/*.gif) -OUT_BEANINFO_RESOURCES = $(patsubst $(SWING_BEANINFO_RESOURCES_SRC_DIR)%, \ - $(JDK_OUTPUTDIR)/classes/javax/swing/beaninfo/images/%, \ - $(SWING_BEANINFO_RESOURCES_SRC)) - -COPY_EXTRA += $(OUT_BEANINFO_RESOURCES) - -# The exception handling of swing beaninfo -# These resources violates the convention of having code and resources together under -# $(JDK_TOPDIR)/src/.../classes directories -$(JDK_OUTPUTDIR)/classes/javax/swing/beaninfo/images/%.gif: \ - $(JDK_TOPDIR)/make/data/swingbeaninfo/images/%.gif - $(call install-file) - -########################################################################################## -# -# Copy the META-INF/services configuration files that are scattered around the source tree -# into classes/META-INF/services. Be aware that META-INF directories that are located at a -# source root (.../classes/META-INF) are automatically copied verbatim by the -# SetupJavaCompilation macro. -# -# Any other META-INF/services configuration file is found here and platform specific comments -# are uncommented and the configuration file is stored in the output META-INF directory. - -# Make sure the output directory is created. -$(eval $(call MakeDir, $(JDK_OUTPUTDIR)/classes/META-INF/services)) -# Find all META-INF/services/* files -ALL_META-INF_DIRS_share := $(shell $(FIND) $(JDK_TOPDIR)/src/share/classes -type d -a -name META-INF) -ALL_META-INF_DIRS_targetapi := $(shell $(FIND) $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/classes -type d -a -name META-INF) -# Platform specific overrides shared -ifneq ($(ALL_META-INF_DIRS_targetapi), ) - ALL_META-INF_DIRS := $(ALL_META-INF_DIRS_targetapi) \ - $(filter-out %$(patsubst $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/classes%,%,$(ALL_META-INF_DIRS_targetapi)), \ - $(ALL_META-INF_DIRS_share)) -else - ALL_META-INF_DIRS := $(ALL_META-INF_DIRS_share) -endif - -SRC_SERVICES_FILES := $(wildcard $(addsuffix /services/*, $(ALL_META-INF_DIRS))) - -# The number of services files are relatively few. If the increase in numbers, then -# we have to use ListPathsSafelyNow here. -# Change $(JDK_TOPDIR)/src/.../META-INF/services/yyyy into $(JDK_OUTPUTDIR)/classes/META-INF/services/yyyy -# The \n in the printf command is needed to make sed work on Solaris. -OUT_SERVICES_FILES := $(addprefix $(JDK_OUTPUTDIR)/classes/META-INF/services/, \ - $(shell $(PRINTF) "$(SRC_SERVICES_FILES)\n" | $(SED) -e 's|/[^ ]*/META-INF/services/||g')) -OUT_SERVICES_FILES_COLON := $(addsuffix :, $(OUT_SERVICES_FILES)) -# Exception handling for print services with no META-INF directory -SRC_SERVICES_FILES_PRINT = $(wildcard $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/classes/sun/print/services/*) -OUT_SERVICES_FILES_PRINT = $(addprefix $(JDK_OUTPUTDIR)/classes/META-INF/services/, \ - $(patsubst $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/classes/sun/print/services/%, %, \ - $(SRC_SERVICES_FILES_PRINT))) -OUT_SERVICES_FILES_PRINT_COLON = $(addsuffix :, $(OUT_SERVICES_FILES_PRINT)) -RULES_SERVICES_PRINT = $(join $(OUT_SERVICES_FILES_PRINT_COLON), $(SRC_SERVICES_FILES_PRINT)) - -# Now setup the dependency rules to generate a META-INF/services/... from the correct source. -META-INF_RULES_SERVICES := $(RULES_SERVICES_PRINT) $(join $(OUT_SERVICES_FILES_COLON), $(SRC_SERVICES_FILES)) -# Eval the newly created rules to incorporate them into the make tree. -define addto_meta-inf_services - $1 - echo $(LOG_INFO) Installing META-INF/services/$$(@F) - $(CAT) $$< | $(SED) -e "s/^#\[$(OPENJDK_TARGET_OS)\]//" > $$@ -endef -$(foreach i, $(META-INF_RULES_SERVICES), $(eval $(call addto_meta-inf_services, $i))) -# Here is the generic rule, whose receipt the above rules will trigger. - -COPY_EXTRA += $(OUT_SERVICES_FILES) -COPY_EXTRA += $(OUT_SERVICES_FILES_PRINT) - -################################################################################ - -JAVAX_SOUND_SRC := $(JDK_TOPDIR)/src/share/classes/com/sun/media/sound/services - -JAVAX_SOUND_SRC_FILES := \ - javax.sound.midi.spi.MidiDeviceProvider \ - javax.sound.midi.spi.MidiFileReader \ - javax.sound.midi.spi.MidiFileWriter \ - javax.sound.midi.spi.SoundbankReader \ - javax.sound.sampled.spi.AudioFileReader \ - javax.sound.sampled.spi.AudioFileWriter \ - javax.sound.sampled.spi.FormatConversionProvider \ - javax.sound.sampled.spi.MixerProvider - -COPY_EXTRA += $(addprefix $(JDK_OUTPUTDIR)/classes/META-INF/services/, $(JAVAX_SOUND_SRC_FILES)) - -JAVAX_SOUND_RULES := $(foreach F, $(JAVAX_SOUND_SRC_FILES), $(JDK_OUTPUTDIR)/classes/META-INF/services/$(notdir $F):$(JAVAX_SOUND_SRC)/$F) - -$(foreach R, $(JAVAX_SOUND_RULES), $(eval $(call addto_meta-inf_services, $R))) - -################################################################################ - -ifneq ($(OPENJDK_TARGET_OS), macosx) - OPENJDK_TARGET_OS_FLAVORMAP_PROPERTIES = $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/classes/sun/awt/datatransfer/flavormap.properties -else - OPENJDK_TARGET_OS_FLAVORMAP_PROPERTIES = $(JDK_TOPDIR)/src/macosx/classes/sun/awt/datatransfer/flavormap.properties -endif - -$(JDK_OUTPUTDIR)/classes/sun/awt/datatransfer/flavormap.properties: $(OPENJDK_TARGET_OS_FLAVORMAP_PROPERTIES) - $(install-file) - -COPY_EXTRA += $(JDK_OUTPUTDIR)/classes/sun/awt/datatransfer/flavormap.properties - -################################################################################ - -CLEAN_FILES := $(wildcard \ - $(JDK_TOPDIR)/src/share/classes/com/sun/imageio/plugins/common/*.properties \ - $(JDK_TOPDIR)/src/share/classes/com/sun/java/util/jar/pack/*.properties \ - $(JDK_TOPDIR)/src/share/classes/com/sun/jndi/cosnaming/jndiprovider.properties \ - $(JDK_TOPDIR)/src/share/classes/com/sun/jndi/ldap/jndiprovider.properties \ - $(JDK_TOPDIR)/src/share/classes/com/sun/org/apache/xml/internal/security/resource/*.properties \ - $(JDK_TOPDIR)/src/share/classes/com/sun/rowset/*.properties \ - $(JDK_TOPDIR)/src/share/classes/com/sun/tools/script/shell/*.properties \ - $(JDK_TOPDIR)/src/share/classes/javax/sql/rowset/*.properties \ - $(JDK_TOPDIR)/src/share/classes/sun/rmi/registry/resources/*.properties \ - $(JDK_TOPDIR)/src/share/classes/sun/rmi/rmic/resources/*.properties \ - $(JDK_TOPDIR)/src/share/classes/sun/rmi/server/resources/*.properties \ - $(JDK_TOPDIR)/src/share/classes/sun/tools/javac/resources/*.properties \ - $(JDK_TOPDIR)/src/share/classes/sun/tools/jconsole/resources/*.properties \ - $(JDK_TOPDIR)/src/share/classes/sun/tools/serialver/resources/*.properties \ - ) - -# Copy zh_HK files from zh_TW - -$(JDK_OUTPUTDIR)/classes/%_zh_HK.properties: $(JDK_OUTPUTDIR)/classes/%_zh_TW.properties - $(install-file) - -COPY_EXTRA += $(patsubst $(JDK_TOPDIR)/src/share/classes/%, $(JDK_OUTPUTDIR)/classes/%, \ - $(subst _zh_TW,_zh_HK, $(filter %_zh_TW.properties, $(CLEAN_FILES)))) diff --git a/jdk/make/CreateJars.gmk b/jdk/make/CreateJars.gmk index 1e250456507..d65fb7ea737 100644 --- a/jdk/make/CreateJars.gmk +++ b/jdk/make/CreateJars.gmk @@ -524,7 +524,6 @@ $(eval $(call SetupArchive,BUILD_TOOLS_JAR, , \ EXCLUDES := $(TOOLS_JAR_EXCLUDES), \ EXTRA_FILES := \ $(JDK_OUTPUTDIR)/modules/jdk.jdi/META-INF/services/com.sun.jdi.connect.Connector \ - $(JDK_OUTPUTDIR)/classes/META-INF/services/com.sun.jdi.connect.Connector \ META-INF/services/com.sun.jdi.connect.spi.TransportService \ META-INF/services/com.sun.tools.attach.spi.AttachProvider \ META-INF/services/com.sun.tools.internal.ws.wscompile.Plugin \ diff --git a/jdk/make/CreateSecurityJars.gmk b/jdk/make/CreateSecurityJars.gmk index 1a3d3343c53..097ac813821 100644 --- a/jdk/make/CreateSecurityJars.gmk +++ b/jdk/make/CreateSecurityJars.gmk @@ -32,8 +32,6 @@ include JavaCompilation.gmk # The jars created in this file are required for the exploded jdk image to function and # cannot wait to be built in the images target. -SECURITY_CLASSES_SUBDIR := modules - ########################################################################################## # Create manifest for security jars # @@ -67,7 +65,7 @@ SUNPKCS11_JAR_DST := $(JDK_OUTPUTDIR)/lib/ext/sunpkcs11.jar SUNPKCS11_JAR_UNSIGNED := $(JDK_OUTPUTDIR)/jce/unsigned/sunpkcs11.jar $(eval $(call SetupArchive,BUILD_SUNPKCS11_JAR, , \ - SRCS := $(JDK_OUTPUTDIR)/$(SECURITY_CLASSES_SUBDIR)/jdk.crypto.pkcs11, \ + SRCS := $(JDK_OUTPUTDIR)/modules/jdk.crypto.pkcs11, \ SUFFIXES := .class, \ INCLUDES := sun/security/pkcs11, \ JAR := $(SUNPKCS11_JAR_UNSIGNED), \ @@ -94,7 +92,7 @@ SUNEC_JAR_DST := $(JDK_OUTPUTDIR)/lib/ext/sunec.jar SUNEC_JAR_UNSIGNED := $(JDK_OUTPUTDIR)/jce/unsigned/sunec.jar $(eval $(call SetupArchive,BUILD_SUNEC_JAR, , \ - SRCS := $(JDK_OUTPUTDIR)/$(SECURITY_CLASSES_SUBDIR)/jdk.crypto.ec, \ + SRCS := $(JDK_OUTPUTDIR)/modules/jdk.crypto.ec, \ SUFFIXES := .class, \ INCLUDES := sun/security/ec, \ JAR := $(SUNEC_JAR_UNSIGNED), \ @@ -122,7 +120,7 @@ SUNJCE_PROVIDER_JAR_UNSIGNED := $(JDK_OUTPUTDIR)/jce/unsigned/sunjce_provider.ja ifneq ($(BUILD_CRYPTO), no) $(eval $(call SetupArchive,BUILD_SUNJCE_PROVIDER_JAR, , \ - SRCS := $(JDK_OUTPUTDIR)/$(SECURITY_CLASSES_SUBDIR)/java.base, \ + SRCS := $(JDK_OUTPUTDIR)/modules/java.base, \ SUFFIXES := .class, \ INCLUDES := com/sun/crypto/provider, \ JAR := $(SUNJCE_PROVIDER_JAR_UNSIGNED), \ @@ -153,7 +151,7 @@ JCE_JAR_UNSIGNED := $(JDK_OUTPUTDIR)/jce/unsigned/jce.jar ifneq ($(BUILD_CRYPTO), no) $(eval $(call SetupArchive,BUILD_JCE_JAR, , \ - SRCS := $(JDK_OUTPUTDIR)/$(SECURITY_CLASSES_SUBDIR)/java.base, \ + SRCS := $(JDK_OUTPUTDIR)/modules/java.base, \ SUFFIXES := .class, \ INCLUDES := javax/crypto sun/security/internal, \ JAR := $(JCE_JAR_UNSIGNED), \ @@ -185,7 +183,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows) SUNMSCAPI_JAR_UNSIGNED := $(JDK_OUTPUTDIR)/jce/unsigned/sunmscapi.jar $(eval $(call SetupArchive,BUILD_SUNMSCAPI_JAR, , \ - SRCS := $(JDK_OUTPUTDIR)/$(SECURITY_CLASSES_SUBDIR)/jdk.crypto.mscapi, \ + SRCS := $(JDK_OUTPUTDIR)/modules/jdk.crypto.mscapi, \ SUFFIXES := .class, \ INCLUDES := sun/security/mscapi, \ JAR := $(SUNMSCAPI_JAR_UNSIGNED), \ @@ -218,7 +216,7 @@ ifeq ($(OPENJDK_TARGET_OS), solaris) UCRYPTO_JAR_SRC := $(JDK_TOPDIR)/make/closed/tools/crypto/ucrypto/ucrypto.jar $(eval $(call SetupArchive,BUILD_UCRYPTO_JAR, , \ - SRCS := $(JDK_OUTPUTDIR)/$(SECURITY_CLASSES_SUBDIR)/jdk.crypto.ucrypto, \ + SRCS := $(JDK_OUTPUTDIR)/modules/jdk.crypto.ucrypto, \ SUFFIXES := .class, \ INCLUDES := com/oracle/security/ucrypto, \ JAR := $(UCRYPTO_JAR_UNSIGNED), \ diff --git a/jdk/make/Tools.gmk b/jdk/make/Tools.gmk index c384643ab67..b68d19c3d34 100644 --- a/jdk/make/Tools.gmk +++ b/jdk/make/Tools.gmk @@ -32,10 +32,7 @@ include $(SPEC) include MakeBase.gmk include JavaCompilation.gmk include NativeCompilation.gmk -include SetupJava.gmk - -# Cache all finds needed for this file. -$(eval $(call FillCacheFind, $(JDK_TOPDIR)/make/src/classes)) +include SetupJavaCompilers.gmk # The exception handling of swing beaninfo which have the own tool directory ifeq (, $(BUILD_TOOLS_JDK)) @@ -101,6 +98,9 @@ TOOL_TZDB = $(JAVA_SMALL) -cp $(JDK_OUTPUTDIR)/btclasses \ TOOL_BLACKLISTED_CERTS = $(JAVA_SMALL) -cp $(JDK_OUTPUTDIR)/btclasses \ build.tools.blacklistedcertsconverter.BlacklistedCertsConverter +TOOL_MAKEJAVASECURITY = $(JAVA_SMALL) -cp $(JDK_OUTPUTDIR)/btclasses \ + build.tools.makejavasecurity.MakeJavaSecurity + # TODO: There are references to the jdwpgen.jar in jdk/make/netbeans/jdwpgen/build.xml # and nbproject/project.properties in the same dir. Needs to be looked at. @@ -134,10 +134,7 @@ TOOL_CHECKDEPS = $(JAVA_SMALL) -Xbootclasspath/p:$(INTERIM_LANGTOOLS_JAR) \ TOOL_GENMODULESXML = $(JAVA_SMALL) -Xbootclasspath/p:$(INTERIM_LANGTOOLS_JAR) \ -cp "$(JDK_OUTPUTDIR)/btclasses$(PATH_SEP)$(JDK_OUTPUTDIR)" \ - build.tools.module.GenerateModulesXml - -TOOL_ADDTORESTRICTEDPKGS = $(JAVA_SMALL) -cp $(JDK_OUTPUTDIR)/btclasses \ - build.tools.addtorestrictedpkgs.AddToRestrictedPkgs + build.tools.module.GenJdepsModulesXml ########################################################################################## diff --git a/jdk/make/copy/Copy-java.base.gmk b/jdk/make/copy/Copy-java.base.gmk index 36a2c9da66a..c624ff80874 100644 --- a/jdk/make/copy/Copy-java.base.gmk +++ b/jdk/make/copy/Copy-java.base.gmk @@ -32,17 +32,17 @@ $(eval $(call IncludeCustomExtension, jdk, copy/Copy-java.base.gmk)) # Copy exported header files to outputdir. # JAVA_BASE_HEADERS := \ - $(INCLUDEDIR)/jni.h \ - $(INCLUDEDIR)/jvmti.h \ - $(INCLUDEDIR)/jvmticmlr.h \ - $(INCLUDEDIR)/classfile_constants.h \ - $(OPENJDK_TARGET_OS_INCLUDE)/jni_md.h \ + $(INCLUDE_DST_DIR)/jni.h \ + $(INCLUDE_DST_DIR)/jvmti.h \ + $(INCLUDE_DST_DIR)/jvmticmlr.h \ + $(INCLUDE_DST_DIR)/classfile_constants.h \ + $(INCLUDE_DST_OS_DIR)/jni_md.h \ # -$(INCLUDEDIR)/%.h: $(JDK_TOPDIR)/src/java.base/share/native/include/%.h +$(INCLUDE_DST_DIR)/%.h: $(JDK_TOPDIR)/src/java.base/share/native/include/%.h $(call install-file) -$(OPENJDK_TARGET_OS_INCLUDE)/%.h: \ +$(INCLUDE_DST_OS_DIR)/%.h: \ $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_EXPORT_DIR)/native/include/%.h $(call install-file) @@ -50,17 +50,17 @@ $(OPENJDK_TARGET_OS_INCLUDE)/%.h: \ CALENDARS_SRC := $(JDK_TOPDIR)/src/java.base/share/conf -$(LIBDIR)/calendars.properties: $(CALENDARS_SRC)/calendars.properties +$(LIB_DST_DIR)/calendars.properties: $(CALENDARS_SRC)/calendars.properties $(call install-file) -BASE_CONF_FILES += $(LIBDIR)/calendars.properties +BASE_CONF_FILES += $(LIB_DST_DIR)/calendars.properties -$(LIBDIR)/hijrah-config-umalqura.properties: $(CALENDARS_SRC)/hijrah-config-umalqura.properties +$(LIB_DST_DIR)/hijrah-config-umalqura.properties: $(CALENDARS_SRC)/hijrah-config-umalqura.properties $(MKDIR) -p $(@D) $(RM) $@ $(CP) $< $@ -BASE_CONF_FILES += $(LIBDIR)/hijrah-config-umalqura.properties +BASE_CONF_FILES += $(LIB_DST_DIR)/hijrah-config-umalqura.properties ################################################################################ @@ -68,10 +68,10 @@ ifneq ($(findstring $(OPENJDK_TARGET_OS), windows aix),) TZMAPPINGS_SRC := $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/conf - $(LIBDIR)/tzmappings: $(TZMAPPINGS_SRC)/tzmappings + $(LIB_DST_DIR)/tzmappings: $(TZMAPPINGS_SRC)/tzmappings $(call install-file) - BASE_CONF_FILES += $(LIBDIR)/tzmappings + BASE_CONF_FILES += $(LIB_DST_DIR)/tzmappings endif diff --git a/jdk/make/copy/Copy-java.desktop.gmk b/jdk/make/copy/Copy-java.desktop.gmk index e724a862b28..2460ffe6a54 100644 --- a/jdk/make/copy/Copy-java.desktop.gmk +++ b/jdk/make/copy/Copy-java.desktop.gmk @@ -30,20 +30,20 @@ $(eval $(call IncludeCustomExtension, jdk, copy/Copy-java.desktop.gmk)) ################################################################################ JAVA_DESKTOP_HEADERS := \ - $(INCLUDEDIR)/jawt.h \ - $(OPENJDK_TARGET_OS_INCLUDE)/jawt_md.h \ + $(INCLUDE_DST_DIR)/jawt.h \ + $(INCLUDE_DST_OS_DIR)/jawt_md.h \ # -$(INCLUDEDIR)/%.h: $(JDK_TOPDIR)/src/java.desktop/share/native/include/%.h +$(INCLUDE_DST_DIR)/%.h: $(JDK_TOPDIR)/src/java.desktop/share/native/include/%.h $(call install-file) -$(OPENJDK_TARGET_OS_INCLUDE)/%.h: \ +$(INCLUDE_DST_OS_DIR)/%.h: \ $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_EXPORT_DIR)/native/include/%.h $(call install-file) ################################################################################ -ICCPROFILE_DEST_DIR := $(LIBDIR)/cmm +ICCPROFILE_DEST_DIR := $(LIB_DST_DIR)/cmm ifdef OPENJDK ICCPROFILE_SRC_DIR := $(JDK_TOPDIR)/src/java.desktop/share/conf/cmm/lcms @@ -102,20 +102,20 @@ DESKTOP_CONF_FILES += $(JDK_OUTPUTDIR)/lib/sound.properties ################################################################################ # -# Copy property files from sun/print to LIBDIR +# Copy property files from sun/print to LIB_DST_DIR # PSFONTPROPFILE_SRC_DIR := $(JDK_TOPDIR)/src/java.desktop/share/conf PSFONTPROPFILE_SRCS := $(wildcard $(PSFONTPROPFILE_SRC_DIR)/psfont*.properties*) -PSFONTPROPFILE_TARGET_FILES := $(subst $(PSFONTPROPFILE_SRC_DIR),$(LIBDIR),$(PSFONTPROPFILE_SRCS)) +PSFONTPROPFILE_TARGET_FILES := $(subst $(PSFONTPROPFILE_SRC_DIR),$(LIB_DST_DIR),$(PSFONTPROPFILE_SRCS)) -$(LIBDIR)/%: $(PSFONTPROPFILE_SRC_DIR)/% +$(LIB_DST_DIR)/%: $(PSFONTPROPFILE_SRC_DIR)/% $(call install-file) DESKTOP_CONF_FILES += $(PSFONTPROPFILE_TARGET_FILES) ################################################################################ # -# Copy cursor.properties and cursors gif files to LIBDIR +# Copy cursor.properties and cursors gif files to LIB_DST_DIR # ifneq ($(OPENJDK_TARGET_OS), macosx) OPENJDK_TARGET_OS_LIB_SRC := $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/conf @@ -123,7 +123,7 @@ else OPENJDK_TARGET_OS_LIB_SRC := $(JDK_TOPDIR)/src/java.desktop/macosx/conf endif -CURSORS_DEST_DIR := $(LIBDIR)/images/cursors +CURSORS_DEST_DIR := $(LIB_DST_DIR)/images/cursors CURSORS_OPENJDK_TARGET_OS_LIB_SRC := $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/conf/images/cursors $(CURSORS_DEST_DIR)/cursors.properties: $(CURSORS_OPENJDK_TARGET_OS_LIB_SRC)/cursors.properties diff --git a/jdk/make/copy/Copy-java.logging.gmk b/jdk/make/copy/Copy-java.logging.gmk index f2644df1a17..da77f247276 100644 --- a/jdk/make/copy/Copy-java.logging.gmk +++ b/jdk/make/copy/Copy-java.logging.gmk @@ -29,10 +29,10 @@ include CopyCommon.gmk LOGGING_LIB_SRC := $(JDK_TOPDIR)/src/java.logging/share/conf -$(LIBDIR)/logging.properties: $(LOGGING_LIB_SRC)/logging.properties +$(LIB_DST_DIR)/logging.properties: $(LOGGING_LIB_SRC)/logging.properties $(call install-file) -LOGGING_CONF_FILES := $(LIBDIR)/logging.properties +LOGGING_CONF_FILES := $(LIB_DST_DIR)/logging.properties ################################################################################ diff --git a/jdk/make/copy/Copy-java.management.gmk b/jdk/make/copy/Copy-java.management.gmk index 55657a963ba..2352c909cad 100644 --- a/jdk/make/copy/Copy-java.management.gmk +++ b/jdk/make/copy/Copy-java.management.gmk @@ -27,7 +27,7 @@ include CopyCommon.gmk ################################################################################ -MGMT_LIBDIR := $(LIBDIR)/management +MGMT_LIBDIR := $(LIB_DST_DIR)/management MGMT_LIB_SRC := $(JDK_TOPDIR)/src/java.management/share/conf MGMT_SRC_FILES := $(wildcard $(MGMT_LIB_SRC)/*) MGMT_TARGET_FILES := $(subst $(MGMT_LIB_SRC),$(MGMT_LIBDIR),$(MGMT_SRC_FILES)) diff --git a/jdk/make/copy/Copy-jdk.hprof.agent.gmk b/jdk/make/copy/Copy-jdk.hprof.agent.gmk index ccec153a5b7..069e915514f 100644 --- a/jdk/make/copy/Copy-jdk.hprof.agent.gmk +++ b/jdk/make/copy/Copy-jdk.hprof.agent.gmk @@ -27,12 +27,12 @@ include CopyCommon.gmk ################################################################################ -HPROF_SRC := $(JDK_TOPDIR)/src/demo/share/jvmti/hprof/jvm.hprof.txt +HPROF_SRC := $(JDK_TOPDIR)/src/jdk.hprof.agent/share/native/libhprof/jvm.hprof.txt -$(LIBDIR)/jvm.hprof.txt: $(HPROF_SRC) +$(LIB_DST_DIR)/jvm.hprof.txt: $(HPROF_SRC) $(call install-file) -HPROF_CONF_FILES := $(LIBDIR)/jvm.hprof.txt +HPROF_CONF_FILES := $(LIB_DST_DIR)/jvm.hprof.txt ################################################################################ diff --git a/jdk/make/copy/Copy-jdk.jdwp.agent.gmk b/jdk/make/copy/Copy-jdk.jdwp.agent.gmk index c02ae7bd9be..dd7ccf01c44 100644 --- a/jdk/make/copy/Copy-jdk.jdwp.agent.gmk +++ b/jdk/make/copy/Copy-jdk.jdwp.agent.gmk @@ -28,9 +28,9 @@ include CopyCommon.gmk ################################################################################ -JDK_DEBUG_AGENT_HEADERS := $(INCLUDEDIR)/jdwpTransport.h +JDK_DEBUG_AGENT_HEADERS := $(INCLUDE_DST_DIR)/jdwpTransport.h -$(INCLUDEDIR)/%.h: $(JDK_TOPDIR)/src/jdk.jdwp.agent/share/native/include/%.h +$(INCLUDE_DST_DIR)/%.h: $(JDK_TOPDIR)/src/jdk.jdwp.agent/share/native/include/%.h $(call install-file) ################################################################################ diff --git a/jdk/make/copy/CopyCommon.gmk b/jdk/make/copy/CopyCommon.gmk index 3baefab75c8..f9c951287fc 100644 --- a/jdk/make/copy/CopyCommon.gmk +++ b/jdk/make/copy/CopyCommon.gmk @@ -28,13 +28,13 @@ default: all include $(SPEC) include MakeBase.gmk -INCLUDEDIR = $(JDK_OUTPUTDIR)/include -LIBDIR := $(JDK_OUTPUTDIR)/lib +INCLUDE_DST_DIR := $(JDK_OUTPUTDIR)/include +LIB_DST_DIR := $(JDK_OUTPUTDIR)/lib -OPENJDK_TARGET_OS_INCLUDE = $(INCLUDEDIR)/$(OPENJDK_TARGET_OS) +INCLUDE_DST_OS_DIR := $(INCLUDE_DST_DIR)/$(OPENJDK_TARGET_OS) ifeq ($(OPENJDK_TARGET_OS), windows) - OPENJDK_TARGET_OS_INCLUDE = $(INCLUDEDIR)/win32 + INCLUDE_DST_OS_DIR := $(INCLUDE_DST_DIR)/win32 else ifeq ($(OPENJDK_TARGET_OS), macosx) - OPENJDK_TARGET_OS_INCLUDE = $(INCLUDEDIR)/darwin + INCLUDE_DST_OS_DIR := $(INCLUDE_DST_DIR)/darwin endif diff --git a/jdk/make/bundle/JDK-Info.plist b/jdk/make/data/bundle/JDK-Info.plist similarity index 100% rename from jdk/make/bundle/JDK-Info.plist rename to jdk/make/data/bundle/JDK-Info.plist diff --git a/jdk/make/bundle/JRE-Info.plist b/jdk/make/data/bundle/JRE-Info.plist similarity index 100% rename from jdk/make/bundle/JRE-Info.plist rename to jdk/make/data/bundle/JRE-Info.plist diff --git a/jdk/make/data/fontconfig/aix.fontconfig.properties b/jdk/make/data/fontconfig/aix.fontconfig.properties index 29e7c7d9510..f203f759894 100644 --- a/jdk/make/data/fontconfig/aix.fontconfig.properties +++ b/jdk/make/data/fontconfig/aix.fontconfig.properties @@ -24,9 +24,14 @@ # questions. # -# Minimal version for AIX using the standard Latin Type1 Fonts from the -# package X11.fnt.iso_T1. These fonts are installed by default into -# "/usr/lpp/X11/lib/X11/fonts/Type1" and sym-linked to "/usr/lib/X11/fonts/Type1" +# +# Portions Copyright (c) 2014 IBM Corporation +# + +# This file references the standard Latin Type1 fonts from the AIX package +# X11.fnt.iso_T1 and the Unicode TrueType fonts from X11.fnt.ucs.ttf. They +# are located by default under "/usr/lpp/X11/lib/X11/fonts/{Type1,TrueType}" +# and sym-linked to "/usr/lib/X11/fonts/". # Version @@ -34,44 +39,381 @@ version=1 # Component Font Mappings -dialog.plain.latin-1=-*-helvetica-medium-r-normal--*-%d-100-100-p-*-iso10646-1 -dialog.bold.latin-1=-*-helvetica-bold-r-normal--*-%d-100-100-p-*-iso10646-1 -dialog.italic.latin-1=-*-helvetica-medium-o-normal--*-%d-100-100-p-*-iso10646-1 -dialog.bolditalic.latin-1=-*-helvetica-bold-o-normal--*-%d-100-100-p-*-iso10646-1 +allfonts.iso10646-extB=-monotype-sansmonowtextb-medium-r-normal--*-%d-75-75-m-*-unicode-2 -dialoginput.plain.latin-1=-*-courier-medium-r-normal--*-%d-100-100-m-*-iso10646-1 -dialoginput.bold.latin-1=-*-courier-bold-r-normal--*-%d-100-100-m-*-iso10646-1 -dialoginput.italic.latin-1=-*-courier-medium-o-normal--*-%d-100-100-m-*-iso10646-1 -dialoginput.bolditalic.latin-1=-*-courier-bold-o-normal--*-%d-100-100-m-*-iso10646-1 -sansserif.plain.latin-1=-*-helvetica-medium-r-normal--*-%d-100-100-p-*-iso10646-1 -sansserif.bold.latin-1=-*-helvetica-bold-r-normal--*-%d-100-100-p-*-iso10646-1 -sansserif.italic.latin-1=-*-helvetica-medium-o-normal--*-%d-100-100-p-*-iso10646-1 -sansserif.bolditalic.latin-1=-*-helvetica-bold-o-normal--*-%d-100-100-p-*-iso10646-1 +dialog.plain.latin-1=-*-helvetica-medium-r-normal--*-%d-100-100-p-*-iso8859-1 +dialog.plain.thai=-ibm-thaihelvetica-medium-r-normal--*-%d-75-75-p-*-ucs2.thai-0 +dialog.plain.ukranian-ibm1124=-*-*-medium-r-normal--*-%d-75-75-p-*-ucs2.i18n-0 +dialog.plain.japanese-x0208=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0 +dialog.plain.japanese-x0201=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0 +dialog.plain.japanese-udc=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp +dialog.plain.japanese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0 +dialog.plain.korean=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0 +dialog.plain.korean-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0 +dialog.plain.chinese=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0 +dialog.plain.chinese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0 +dialog.plain.taiwanese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0 -serif.plain.latin-1=-*-times new roman-medium-r-normal--*-%d-100-100-p-*-iso10646-1 -serif.bold.latin-1=-*-times new roman-bold-r-normal--*-%d-100-100-p-*-iso10646-1 -serif.italic.latin-1=-*-times new roman-medium-i-normal--*-%d-100-100-p-*-iso10646-1 -serif.bolditalic.latin-1=-*-times new roman-bold-i-normal--*-%d-100-100-p-*-iso10646-1 +dialog.bold.latin-1=-*-helvetica-bold-r-normal--*-%d-100-100-p-*-iso8859-1 +dialog.bold.thai=-ibm-thaihelvetica-medium-r-normal--*-%d-75-75-p-*-ucs2.thai-0 +dialog.bold.ukranian-ibm1124=-*-*-bold-r-normal--*-%d-75-75-p-*-ucs2.i18n-0 +dialog.bold.japanese-x0208=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0 +dialog.bold.japanese-x0201=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0 +dialog.bold.japanese-udc=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp +dialog.bold.japanese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0 +dialog.bold.korean=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0 +dialog.bold.korean-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0 +dialog.bold.chinese=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0 +dialog.bold.chinese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0 +dialog.bold.taiwanese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0 -monospaced.plain.latin-1=-*-courier-medium-r-normal--*-%d-100-100-m-*-iso10646-1 -monospaced.bold.latin-1=-*-courier-bold-r-normal--*-%d-100-100-m-*-iso10646-1 -monospaced.italic.latin-1=-*-courier-medium-o-normal--*-%d-100-100-m-*-iso10646-1 -monospaced.bolditalic.latin-1=-*-courier-bold-o-normal--*-%d-100-100-m-*-iso10646-1 +dialog.italic.latin-1=-*-helvetica-medium-o-normal--*-%d-100-100-p-*-iso8859-1 +dialog.italic.thai=-ibm-thaihelvetica-medium-r-normal--*-%d-75-75-p-*-ucs2.thai-0 +dialog.italic.ukranian-ibm1124=-*-*-medium-i-normal--*-%d-75-75-p-*-ucs2.i18n-0 +dialog.italic.japanese-x0208=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0 +dialog.italic.japanese-x0201=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0 +dialog.italic.japanese-udc=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp +dialog.italic.japanese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0 +dialog.italic.korean=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0 +dialog.italic.korean-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0 +dialog.italic.chinese=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0 +dialog.italic.chinese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0 +dialog.italic.taiwanese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0 + +dialog.bolditalic.latin-1=-*-helvetica-bold-o-normal--*-%d-100-100-p-*-iso8859-1 +dialog.bolditalic.thai=-ibm-thaihelvetica-medium-r-normal--*-%d-75-75-p-*-ucs2.thai-0 +dialog.bolditalic.ukranian-ibm1124=-*-*-medium-r-normal--*-%d-75-75-p-*-ucs2.i18n-0 +dialog.bolditalic.japanese-x0208=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0 +dialog.bolditalic.japanese-x0201=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0 +dialog.bolditalic.japanese-udc=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp +dialog.bolditalic.japanese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0 +dialog.bolditalic.korean=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0 +dialog.bolditalic.korean-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0 +dialog.bolditalic.chinese=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0 +dialog.bolditalic.chinese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0 +dialog.bolditalic.taiwanese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0 + +dialoginput.plain.latin-1=-*-courier-medium-r-normal--*-%d-100-100-m-*-iso8859-1 +dialoginput.plain.thai=-ibm-thaicourier-medium-r-normal--*-%d-75-75-m-*-ucs2.thai-0 +dialoginput.plain.ukranian-ibm1124=-*-*-medium-r-normal--*-%d-75-75-m-*-ucs2.i18n-0 +dialoginput.plain.japanese-x0208=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0 +dialoginput.plain.japanese-x0201=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0 +dialoginput.plain.japanese-udc=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp +dialoginput.plain.japanese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0 +dialoginput.plain.korean=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0 +dialoginput.plain.korean-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0 +dialoginput.plain.chinese=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0 +dialoginput.plain.chinese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0 +dialoginput.plain.taiwanese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0 + +dialoginput.bold.latin-1=-*-courier-bold-r-normal--*-%d-100-100-m-*-iso8859-1 +dialoginput.bold.thai=-ibm-thaicourier-medium-r-normal--*-%d-75-75-m-*-ucs2.thai-0 +dialoginput.bold.ukranian-ibm1124=-*-*-bold-r-normal--*-%d-75-75-m-*-ucs2.i18n-0 +dialoginput.bold.japanese-x0208=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0 +dialoginput.bold.japanese-x0201=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0 +dialoginput.bold.japanese-udc=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp +dialoginput.bold.japanese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0 +dialoginput.bold.korean=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0 +dialoginput.bold.korean-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0 +dialoginput.bold.chinese=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0 +dialoginput.bold.chinese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0 +dialoginput.bold.taiwanese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0 + +dialoginput.italic.latin-1=-*-courier-medium-o-normal--*-%d-100-100-m-*-iso8859-1 +dialoginput.italic.thai=-ibm-thaicourier-medium-r-normal--*-%d-75-75-m-*-ucs2.thai-0 +dialoginput.italic.ukranian-ibm1124=-*-*-medium-i-normal--*-%d-75-75-m-*-ucs2.i18n-0 +dialoginput.italic.japanese-x0208=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0 +dialoginput.italic.japanese-x0201=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0 +dialoginput.italic.japanese-udc=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp +dialoginput.italic.japanese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0 +dialoginput.italic.korean=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0 +dialoginput.italic.korean-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0 +dialoginput.italic.chinese=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0 +dialoginput.italic.chinese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0 +dialoginput.italic.taiwanese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0 + +dialoginput.bolditalic.latin-1=-*-courier-bold-o-normal--*-%d-100-100-m-*-iso8859-1 +dialoginput.bolditalic.thai=-ibm-thaicourier-medium-r-normal--*-%d-75-75-m-*-ucs2.thai-0 +dialoginput.bolditalic.ukranian-ibm1124=-*-*-medium-r-normal--*-%d-75-75-m-*-ucs2.i18n-0 +dialoginput.bolditalic.japanese-x0208=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0 +dialoginput.bolditalic.japanese-x0201=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0 +dialoginput.bolditalic.japanese-udc=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp +dialoginput.bolditalic.japanese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0 +dialoginput.bolditalic.korean=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0 +dialoginput.bolditalic.korean-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0 +dialoginput.bolditalic.chinese=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0 +dialoginput.bolditalic.chinese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0 +dialoginput.bolditalic.taiwanese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0 + +sansserif.plain.latin-1=-*-helvetica-medium-r-normal--*-%d-100-100-p-*-iso8859-1 +sansserif.plain.thai=-ibm-thaihelvetica-medium-r-normal--*-%d-75-75-p-*-ucs2.thai-0 +sansserif.plain.ukranian-ibm1124=-*-*-medium-r-normal--*-%d-75-75-p-*-ucs2.i18n-0 +sansserif.plain.japanese-x0208=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0 +sansserif.plain.japanese-x0201=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0 +sansserif.plain.japanese-udc=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp +sansserif.plain.japanese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0 +sansserif.plain.korean=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0 +sansserif.plain.korean-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0 +sansserif.plain.chinese=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0 +sansserif.plain.chinese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0 +sansserif.plain.taiwanese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0 + +sansserif.bold.latin-1=-*-helvetica-bold-r-normal--*-%d-100-100-p-*-iso8859-1 +sansserif.bold.thai=-ibm-thaihelvetica-medium-r-normal--*-%d-75-75-p-*-ucs2.thai-0 +sansserif.bold.ukranian-ibm1124=-*-*-bold-r-normal--*-%d-75-75-p-*-ucs2.i18n-0 +sansserif.bold.japanese-x0208=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0 +sansserif.bold.japanese-x0201=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0 +sansserif.bold.japanese-udc=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp +sansserif.bold.japanese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0 +sansserif.bold.korean=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0 +sansserif.bold.korean-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0 +sansserif.bold.chinese=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0 +sansserif.bold.chinese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0 +sansserif.bold.taiwanese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0 + +sansserif.italic.latin-1=-*-helvetica-medium-o-normal--*-%d-100-100-p-*-iso8859-1 +sansserif.italic.thai=-ibm-thaihelvetica-medium-r-normal--*-%d-75-75-p-*-ucs2.thai-0 +sansserif.italic.ukranian-ibm1124=-*-*-medium-i-normal--*-%d-75-75-p-*-ucs2.i18n-0 +sansserif.italic.japanese-x0208=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0 +sansserif.italic.japanese-x0201=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0 +sansserif.italic.japanese-udc=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp +sansserif.italic.japanese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0 +sansserif.italic.korean=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0 +sansserif.italic.korean-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0 +sansserif.italic.chinese=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0 +sansserif.italic.chinese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0 +sansserif.italic.taiwanese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0 + +sansserif.bolditalic.latin-1=-*-helvetica-bold-o-normal--*-%d-100-100-p-*-iso8859-1 +sansserif.bolditalic.thai=-ibm-thaihelvetica-medium-r-normal--*-%d-75-75-p-*-ucs2.thai-0 +sansserif.bolditalic.ukranian-ibm1124=-*-*-medium-r-normal--*-%d-75-75-p-*-ucs2.i18n-0 +sansserif.bolditalic.japanese-x0208=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0 +sansserif.bolditalic.japanese-x0201=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0 +sansserif.bolditalic.japanese-udc=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp +sansserif.bolditalic.japanese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0 +sansserif.bolditalic.korean=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0 +sansserif.bolditalic.korean-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0 +sansserif.bolditalic.chinese=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0 +sansserif.bolditalic.chinese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0 +sansserif.bolditalic.taiwanese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0 + +serif.plain.latin-1=-*-times new roman-medium-r-normal--*-%d-100-100-p-*-iso8859-1 +serif.plain.thai=-ibm-thaitimes-medium-r-normal--*-%d-75-75-p-*-ucs2.thai-0 +serif.plain.ukranian-ibm1124=-*-*-medium-r-normal--*-%d-75-75-p-*-ucs2.i18n-0 +serif.plain.japanese-x0208=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0 +serif.plain.japanese-x0201=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0 +serif.plain.japanese-udc=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp +serif.plain.japanese-iso10646=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0 +serif.plain.korean=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0 +serif.plain.korean-iso10646=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0 +serif.plain.chinese=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0 +serif.plain.chinese-iso10646=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0 +serif.plain.taiwanese-iso10646=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0 + +serif.bold.latin-1=-*-times new roman-bold-r-normal--*-%d-100-100-p-*-iso8859-1 +serif.bold.thai=-ibm-thaitimes-medium-r-normal--*-%d-75-75-p-*-ucs2.thai-0 +serif.bold.ukranian-ibm1124=-*-*-bold-r-normal--*-%d-75-75-p-*-ucs2.i18n-0 +serif.bold.japanese-x0208=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0 +serif.bold.japanese-x0201=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0 +serif.bold.japanese-udc=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp +serif.bold.japanese-iso10646=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0 +serif.bold.korean=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0 +serif.bold.korean-iso10646=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0 +serif.bold.chinese=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0 +serif.bold.chinese-iso10646=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0 +serif.bold.taiwanese-iso10646=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0 + + +serif.italic.latin-1=-*-times new roman-medium-i-normal--*-%d-100-100-p-*-iso8859-1 +serif.italic.thai=-ibm-thaitimes-medium-r-normal--*-%d-75-75-p-*-ucs2.thai-0 +serif.italic.ukranian-ibm1124=-*-*-medium-i-normal--*-%d-75-75-p-*-ucs2.i18n-0 +serif.italic.japanese-x0208=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0 +serif.italic.japanese-x0201=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0 +serif.italic.japanese-udc=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp +serif.italic.japanese-iso10646=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0 +serif.italic.korean=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0 +serif.italic.korean-iso10646=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0 +serif.italic.chinese=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0 +serif.italic.chinese-iso10646=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0 +serif.italic.taiwanese-iso10646=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0 + +serif.bolditalic.latin-1=-*-times new roman-bold-i-normal--*-%d-100-100-p-*-iso8859-1 +serif.bolditalic.thai=-ibm-thaitimes-medium-r-normal--*-%d-75-75-p-*-ucs2.thai-0 +serif.bolditalic.ukranian-ibm1124=-*-*-medium-r-normal--*-%d-75-75-p-*-ucs2.i18n-0 +serif.bolditalic.japanese-x0208=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0 +serif.bolditalic.japanese-x0201=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0 +serif.bolditalic.japanese-udc=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp +serif.bolditalic.japanese-iso10646=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0 +serif.bolditalic.korean=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0 +serif.bolditalic.korean-iso10646=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0 +serif.bolditalic.chinese=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0 +serif.bolditalic.chinese-iso10646=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0 +serif.bolditalic.taiwanese-iso10646=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0 + +monospaced.plain.latin-1=-*-courier-medium-r-normal--*-%d-100-100-m-*-iso8859-1 +monospaced.plain.thai=-ibm-thaicourier-medium-r-normal--*-%d-75-75-m-*-ucs2.thai-0 +monospaced.plain.ukranian-ibm1124=-*-*-medium-r-normal--*-%d-75-75-m-*-ucs2.i18n-0 +monospaced.plain.japanese-x0208=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0 +monospaced.plain.japanese-x0201=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0 +monospaced.plain.japanese-udc=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp +monospaced.plain.japanese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0 +monospaced.plain.korean=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0 +monospaced.plain.korean-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0 +monospaced.plain.chinese=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0 +monospaced.plain.chinese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0 +monospaced.plain.taiwanese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0 + +monospaced.bold.latin-1=-*-courier-bold-r-normal--*-%d-100-100-m-*-iso8859-1 +monospaced.bold.thai=-ibm-thaicourier-medium-r-normal--*-%d-75-75-m-*-ucs2.thai-0 +monospaced.bold.ukranian-ibm1124=-*-*-bold-r-normal--*-%d-75-75-m-*-ucs2.i18n-0 +monospaced.bold.japanese-x0208=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0 +monospaced.bold.japanese-x0201=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0 +monospaced.bold.japanese-udc=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp +monospaced.bold.japanese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0 +monospaced.bold.korean=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0 +monospaced.bold.korean-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0 +monospaced.bold.chinese=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0 +monospaced.bold.chinese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0 +monospaced.bold.taiwanese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0 + +monospaced.italic.latin-1=-*-courier-medium-o-normal--*-%d-100-100-m-*-iso8859-1 +monospaced.italic.thai=-ibm-thaicourier-medium-r-normal--*-%d-75-75-m-*-ucs2.thai-0 +monospaced.italic.ukranian-ibm1124=-*-*-medium-i-normal--*-%d-75-75-m-*-ucs2.i18n-0 +monospaced.italic.japanese-x0208=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0 +monospaced.italic.japanese-x0201=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0 +monospaced.italic.japanese-udc=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp +monospaced.italic.japanese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0 +monospaced.italic.korean=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0 +monospaced.italic.korean-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0 +monospaced.italic.chinese=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0 +monospaced.italic.chinese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0 +monospaced.italic.taiwanese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0 + +monospaced.bolditalic.latin-1=-*-courier-bold-o-normal--*-%d-100-100-m-*-iso8859-1 +monospaced.bolditalic.thai=-ibm-thaicourier-medium-r-normal--*-%d-75-75-m-*-ucs2.thai-0 +monospaced.bolditalic.ukranian-ibm1124=-*-*-medium-r-normal--*-%d-75-75-m-*-ucs2.i18n-0 +monospaced.bolditalic.japanese-x0208=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0 +monospaced.bolditalic.japanese-x0201=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0 +monospaced.bolditalic.japanese-udc=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp +monospaced.bolditalic.japanese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0 +monospaced.bolditalic.korean=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0 +monospaced.bolditalic.korean-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0 +monospaced.bolditalic.chinese=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0 +monospaced.bolditalic.chinese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0 +monospaced.bolditalic.taiwanese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0 # Search Sequences sequence.allfonts=latin-1 +sequence.allfonts.UTF-8=latin-1,japanese-iso10646 +# Uk_UA +sequence.allfonts.x-IBM1124=latin-1,ukranian-ibm1124 +# Japanese +sequence.allfonts.x-IBM943C=latin-1,japanese-x0201,japanese-x0208,japanese-udc +sequence.allfonts.x-IBM29626C=latin-1,japanese-x0201,japanese-x0208,japanese-udc +sequence.allfonts.UTF-8.ja=japanese-iso10646,latin-1,iso10646-extB +# Chinese +sequence.allfonts.x-EUC_CN=latin-1,chinese +sequence.allfonts.GB18030=latin-1,chinese-iso10646,iso10646-extB +sequence.allfonts.UTF-8.zh.CN=latin-1,chinese-iso10646,iso10646-extB +# Taiwanese +sequence.allfonts.x-IBM964=latin-1,taiwanese-iso10646 +sequence.allfonts.Big5=latin-1,taiwanese-iso10646 +sequence.allfonts.UTF-8.zh.TW=latin-1,taiwanese-iso10646 +# Korean +sequence.allfonts.x-IBM970=latin-1,korean +sequence.allfonts.UTF-8.ko=latin-1,korean-iso10646 +# Thai +sequence.allfonts.TIS-620=latin-1,thai +sequence.allfonts.UTF-8.th=latin-1,thai +# fallback +sequence.fallback=thai,chinese-iso10646,taiwanese-iso10646,japanese-iso10646,korean-iso10646,iso10646-extB + +# Exclusion Ranges +exclusion.japanese-iso10646=0000-00ff + +# Font File Names +filename.-*-courier-medium-r-normal--*-%d-100-100-m-*-iso8859-1=/usr/lpp/X11/lib/X11/fonts/Type1/cour.pfa +filename.-*-courier-bold-r-normal--*-%d-100-100-m-*-iso8859-1=/usr/lpp/X11/lib/X11/fonts/Type1/courb.pfa +filename.-*-courier-medium-o-normal--*-%d-100-100-m-*-iso8859-1=/usr/lpp/X11/lib/X11/fonts/Type1/couri.pfa +filename.-*-courier-bold-o-normal--*-%d-100-100-m-*-iso8859-1=/usr/lpp/X11/lib/X11/fonts/Type1/courbi.pfa +filename.-*-helvetica-medium-r-normal--*-%d-100-100-p-*-iso8859-1=/usr/lpp/X11/lib/X11/fonts/Type1/helv.pfa +filename.-*-helvetica-bold-r-normal--*-%d-100-100-p-*-iso8859-1=/usr/lpp/X11/lib/X11/fonts/Type1/helvb.pfa +filename.-*-helvetica-medium-o-normal--*-%d-100-100-p-*-iso8859-1=/usr/lpp/X11/lib/X11/fonts/Type1/helvi.pfa +filename.-*-helvetica-bold-o-normal--*-%d-100-100-p-*-iso8859-1=/usr/lpp/X11/lib/X11/fonts/Type1/helvbi.pfa +filename.-*-times_new_roman-medium-r-normal--*-%d-100-100-p-*-iso8859-1=/usr/lpp/X11/lib/X11/fonts/Type1/tnr.pfa +filename.-*-times_new_roman-bold-r-normal--*-%d-100-100-p-*-iso8859-1=/usr/lpp/X11/lib/X11/fonts/Type1/tnrb.pfa +filename.-*-times_new_roman-medium-i-normal--*-%d-100-100-p-*-iso8859-1=/usr/lpp/X11/lib/X11/fonts/Type1/tnri.pfa +filename.-*-times_new_roman-bold-i-normal--*-%d-100-100-p-*-iso8859-1=/usr/lpp/X11/lib/X11/fonts/Type1/tnrbi.pfa + + +filename.-monotype-sansmonowtextb-medium-r-normal--*-%d-75-75-m-*-unicode-2=/usr/lpp/X11/lib/X11/fonts/TrueType/MTSanXBA.ttf + +filename.-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_j.ttf +filename.-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_j.ttf +filename.-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_j.ttf +filename.-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_j.ttf +filename.-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_k.ttf +filename.-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_k.ttf +filename.-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_s.ttf +filename.-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_s.ttf +filename.-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_s.ttf +filename.-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_s.ttf +filename.-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_t.ttf + +filename.-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsansdj.ttf +filename.-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsansdj.ttf +filename.-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsansdj.ttf +filename.-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsansdj.ttf +filename.-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsansdk.ttf +filename.-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsansdk.ttf +filename.-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsansds.ttf +filename.-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsansds.ttf +filename.-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsansdt.ttf +filename.-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsans_j.ttf +filename.-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsans_j.ttf +filename.-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsans_j.ttf +filename.-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsans_j.ttf +filename.-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsans_k.ttf +filename.-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsans_k.ttf +filename.-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsans_s.ttf +filename.-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsans_s.ttf +filename.-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsans_t.ttf + +filename.-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-iso8859-15=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_j.ttf +filename.-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-iso8859-15=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsansdj.ttf + +filename.-ibm-thaicourier-medium-r-normal--*-%d-75-75-m-*-ucs2.thai-0=/usr/lpp/X11/lib/X11/fonts/TrueType/courth.ttf +filename.-ibm-thaihelvetica-medium-r-normal--*-%d-75-75-p-*-ucs2.thai-0=/usr/lpp/X11/lib/X11/fonts/TrueType/helvth.ttf +filename.-ibm-thaitimes-medium-r-normal--*-%d-75-75-p-*-ucs2.thai-0=/usr/lpp/X11/lib/X11/fonts/TrueType/timeth.ttf + +filename.-*-*-medium-r-normal--*-%d-*-*-p-*-ibm-1046=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_j.ttf +filename.-*-*-bold-r-normal--*-%d-*-*-p-*-ibm-1046=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_j.ttf +filename.-*-*-medium-i-normal--*-%d-*-*-p-*-ibm-1046=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_j.ttf +filename.-*-*-bold-i-normal--*-%d-*-*-p-*-ibm-1046=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_j.ttf +filename.-*-*-medium-r-normal--*-%d-*-*-m-*-ibm-1046=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsansdj.ttf +filename.-*-*-bold-r-normal--*-%d-*-*-m-*-ibm-1046=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsansdj.ttf +filename.-*-*-medium-i-normal--*-%d-*-*-m-*-ibm-1046=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsansdj.ttf +filename.-*-*-bold-i-normal--*-%d-*-*-m-*-ibm-1046=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsansdj.ttf + +filename.-*-*-medium-r-normal--*-%d-75-75-p-*-ucs2.i18n-0=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_j.ttf +filename.-*-*-bold-r-normal--*-%d-75-75-p-*-ucs2.i18n-0=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_j.ttf +filename.-*-*-medium-i-normal--*-%d-75-75-p-*-ucs2.i18n-0=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_j.ttf +filename.-*-*-medium-r-normal--*-%d-75-75-m-*-ucs2.i18n-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsansdj.ttf +filename.-*-*-bold-r-normal--*-%d-75-75-m-*-ucs2.i18n-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsansdj.ttf +filename.-*-*-medium-i-normal--*-%d-75-75-m-*-ucs2.i18n-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsansdj.ttf + +# AWT font path +awtfontpath.japanese-x0201=/usr/lpp/X11/lib/X11/fonts/TrueType +awtfontpath.japanese-x0208=/usr/lpp/X11/lib/X11/fonts/TrueType +awtfontpath.japanese-udc=/usr/lpp/X11/lib/X11/fonts/TrueType +awtfontpath.japanese-iso10646=/usr/lpp/X11/lib/X11/fonts/TrueType +awtfontpath.korean=/usr/lpp/X11/lib/X11/fonts/TrueType +awtfontpath.korean-iso10646=/usr/lpp/X11/lib/X11/fonts/TrueType +awtfontpath.chinese=/usr/lpp/X11/lib/X11/fonts/TrueType +awtfontpath.chinese-iso10646=/usr/lpp/X11/lib/X11/fonts/TrueType +awtfontpath.taiwanese-iso10646=/usr/lpp/X11/lib/X11/fonts/TrueType +awtfontpath.thai=/usr/lpp/X11/lib/X11/fonts/TrueType +awtfontpath.iso10646-extB=/usr/lpp/X11/lib/X11/fonts/TrueType -filename.-*-courier-medium-r-normal--*-%d-100-100-m-*-iso10646-1=/usr/lpp/X11/lib/X11/fonts/Type1/cour.pfa -filename.-*-courier-bold-r-normal--*-%d-100-100-m-*-iso10646-1=/usr/lpp/X11/lib/X11/fonts/Type1/courb.pfa -filename.-*-courier-medium-o-normal--*-%d-100-100-m-*-iso10646-1=/usr/lpp/X11/lib/X11/fonts/Type1/couri.pfa -filename.-*-courier-bold-o-normal--*-%d-100-100-m-*-iso10646-1=/usr/lpp/X11/lib/X11/fonts/Type1/courbi.pfa -filename.-*-helvetica-medium-r-normal--*-%d-100-100-p-*-iso10646-1=/usr/lpp/X11/lib/X11/fonts/Type1/helv.pfa -filename.-*-helvetica-bold-r-normal--*-%d-100-100-p-*-iso10646-1=/usr/lpp/X11/lib/X11/fonts/Type1/helvb.pfa -filename.-*-helvetica-medium-o-normal--*-%d-100-100-p-*-iso10646-1=/usr/lpp/X11/lib/X11/fonts/Type1/helvi.pfa -filename.-*-helvetica-bold-o-normal--*-%d-100-100-p-*-iso10646-1=/usr/lpp/X11/lib/X11/fonts/Type1/helvbi.pfa -filename.-*-times_new_roman-medium-r-normal--*-%d-100-100-p-*-iso10646-1=/usr/lpp/X11/lib/X11/fonts/Type1/tnr.pfa -filename.-*-times_new_roman-bold-r-normal--*-%d-100-100-p-*-iso10646-1=/usr/lpp/X11/lib/X11/fonts/Type1/tnrb.pfa -filename.-*-times_new_roman-medium-i-normal--*-%d-100-100-p-*-iso10646-1=/usr/lpp/X11/lib/X11/fonts/Type1/tnri.pfa -filename.-*-times_new_roman-bold-i-normal--*-%d-100-100-p-*-iso10646-1=/usr/lpp/X11/lib/X11/fonts/Type1/tnrbi.pfa diff --git a/jdk/make/gendata/Gendata-java.base.gmk b/jdk/make/gendata/Gendata-java.base.gmk index 71ee403d7a8..a7135abe563 100644 --- a/jdk/make/gendata/Gendata-java.base.gmk +++ b/jdk/make/gendata/Gendata-java.base.gmk @@ -62,25 +62,18 @@ GENDATA += $(GENDATA_CURDATA) ########################################################################################## -PROPS_SRC := $(JDK_TOPDIR)/src/java.base/share/conf/security/java.security-$(OPENJDK_TARGET_OS) -PROPS_DST := $(JDK_OUTPUTDIR)/lib/security/java.security +GENDATA_JAVA_SECURITY_SRC := $(JDK_TOPDIR)/src/java.base/share/conf/security/java.security +GENDATA_JAVA_SECURITY := $(JDK_OUTPUTDIR)/lib/security/java.security -# Optionally set this variable to a file to add extra restricted packages. -ifneq ($(RESTRICTED_PKGS_SRC), ) +# RESTRICTED_PKGS_SRC is optionally set in custom extension for this makefile - $(PROPS_DST): $(PROPS_SRC) $(RESTRICTED_PKGS_SRC) +$(GENDATA_JAVA_SECURITY): $(BUILD_TOOLS) $(GENDATA_JAVA_SECURITY_SRC) $(RESTRICTED_PKGS_SRC) + $(ECHO) "Generating java.security" $(MKDIR) -p $(@D) - $(TOOL_ADDTORESTRICTEDPKGS) $(PROPS_SRC) $@.tmp `$(CAT) $(RESTRICTED_PKGS_SRC) | $(TR) "\n" " "` - $(MV) $@.tmp $@ + $(TOOL_MAKEJAVASECURITY) $(GENDATA_JAVA_SECURITY_SRC) $@ $(OPENJDK_TARGET_OS) \ + $(RESTRICTED_PKGS_SRC) || exit 1 -else - - $(PROPS_DST): $(PROPS_SRC) - $(call install-file) - -endif - -GENDATA += $(PROPS_DST) +GENDATA += $(GENDATA_JAVA_SECURITY) ########################################################################################## diff --git a/jdk/test/sun/tools/jps/jps-help.sh b/jdk/make/gendata/Gendata-jdk.dev.gmk similarity index 52% rename from jdk/test/sun/tools/jps/jps-help.sh rename to jdk/make/gendata/Gendata-jdk.dev.gmk index c6c1cbdd7d4..3c24cf4b703 100644 --- a/jdk/test/sun/tools/jps/jps-help.sh +++ b/jdk/make/gendata/Gendata-jdk.dev.gmk @@ -1,10 +1,12 @@ # -# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. +# 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. +# 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 @@ -21,37 +23,24 @@ # questions. # -# @test -# @bug 4990825 -# @run shell jps-help.sh -# @summary Test that output of 'jps -?' matches the usage.out file +include GendataCommon.gmk -. ${TESTSRC-.}/../../jvmstat/testlibrary/utils.sh +$(eval $(call IncludeCustomExtension, jdk, gendata/Gendata-jdk.dev.gmk)) -setup +GENDATA := $(JDK_OUTPUTDIR)/modules/jdk.dev/com/sun/tools/jdeps/resources/jdeps-modules.xml +METADATA_FILES += $(TOPDIR)/modules.xml -JPS="${TESTJAVA}/bin/jps" +# +# Generate modules.xml for jdeps to use +# It augments $(TOPDIR)/modules.xml to include module membership +# +$(GENDATA): $(BUILD_TOOLS_JDK) $(METADATA_FILES) + $(MKDIR) -p $(@D) + $(RM) $@ + $(TOOL_GENMODULESXML) -o $@ -mp $(JDK_OUTPUTDIR)/modules $(METADATA_FILES) -rm -f jps.out 2>/dev/null -${JPS} -J-XX:+UsePerfData -? > jps.out 2>&1 +jdk.dev: $(GENDATA) -diff -w jps.out ${TESTSRC}/usage.out -if [ $? != 0 ] -then - echo "Output of jps -? differ from expected output. Failed." - rm -f jps.out 2>/dev/null - exit 1 -fi +all: $(GENDATA) -rm -f jps.out 2>/dev/null -${JPS} -J-XX:+UsePerfData -help > jps.out 2>&1 - -diff -w jps.out ${TESTSRC}/usage.out -if [ $? != 0 ] -then - echo "Output of jps -help differ from expected output. Failed." - rm -f jps.out 2>/dev/null - exit 1 -fi - -exit 0 +.PHONY: all jdk.dev diff --git a/jdk/make/gendata/GendataCommon.gmk b/jdk/make/gendata/GendataCommon.gmk index c199a377378..e5e0336b325 100644 --- a/jdk/make/gendata/GendataCommon.gmk +++ b/jdk/make/gendata/GendataCommon.gmk @@ -28,9 +28,7 @@ default: all include $(SPEC) include MakeBase.gmk include JavaCompilation.gmk - -# Setup the java compilers for the JDK build. -include SetupJava.gmk +include SetupJavaCompilers.gmk # We need the tools. include Tools.gmk diff --git a/jdk/make/gensrc/GensrcCommon.gmk b/jdk/make/gensrc/GensrcCommon.gmk index 3c271c81d77..09819e19d57 100644 --- a/jdk/make/gensrc/GensrcCommon.gmk +++ b/jdk/make/gensrc/GensrcCommon.gmk @@ -30,9 +30,7 @@ include MakeBase.gmk include JavaCompilation.gmk include NativeCompilation.gmk include TextFileProcessing.gmk - -# Setup the java compilers for the JDK build. -include SetupJava.gmk +include SetupJavaCompilers.gmk # We need the tools. include Tools.gmk diff --git a/jdk/make/gensrc/GensrcLocaleDataMetaInfo.gmk b/jdk/make/gensrc/GensrcLocaleDataMetaInfo.gmk index b3f0335d7e0..f4a3575218e 100644 --- a/jdk/make/gensrc/GensrcLocaleDataMetaInfo.gmk +++ b/jdk/make/gensrc/GensrcLocaleDataMetaInfo.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 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 @@ -28,13 +28,15 @@ # into LocaleDataMetaInfo.java # First go look for all locale files -LOCALE_FILES := $(shell $(FIND) $(JDK_TOPDIR)/src/*/share/classes \ +LOCALE_FILES := $(shell $(FIND) $(JDK_TOPDIR)/src/java.base/share/classes \ + $(JDK_TOPDIR)/src/jdk.localedata/share/classes \ -name "FormatData_*.java" -o -name "FormatData_*.properties" -o \ -name "CollationData_*.java" -o -name "CollationData_*.properties" -o \ -name "TimeZoneNames_*.java" -o -name "TimeZoneNames_*.properties" -o \ -name "LocaleNames_*.java" -o -name "LocaleNames_*.properties" -o \ -name "CurrencyNames_*.java" -o -name "CurrencyNames_*.properties" -o \ - -name "CalendarData_*.java" -o -name "CalendarData_*.properties") + -name "CalendarData_*.java" -o -name "CalendarData_*.properties" -o \ + -name "BreakIteratorInfo_*.java" -o -name "BreakIteratorRules_*.java") # Then translate the locale files into for example: FormatData_sv LOCALE_RESOURCES := $(sort $(subst .properties,,$(subst .java,,$(notdir $(LOCALE_FILES))))) @@ -86,6 +88,12 @@ $(eval $(call CaptureLocale,FormatData)) #sun.text.resources.CollationData $(eval $(call CaptureLocale,CollationData)) +#sun.text.resources.BreakIteratorInfo +$(eval $(call CaptureLocale,BreakIteratorInfo)) + +#sun.text.resources.BreakIteratorRules +$(eval $(call CaptureLocale,BreakIteratorRules)) + #sun.util.resources.TimeZoneNames $(eval $(call CaptureLocale,TimeZoneNames)) diff --git a/jdk/make/gensrc/GensrcProperties.gmk b/jdk/make/gensrc/GensrcProperties.gmk index c387d52ffe2..a33015b150c 100644 --- a/jdk/make/gensrc/GensrcProperties.gmk +++ b/jdk/make/gensrc/GensrcProperties.gmk @@ -23,9 +23,6 @@ # questions. # -# Prepare the find cache. -$(eval $(call FillCacheFind, $(wildcard $(JDK_TOPDIR)/src/*/*/classes))) - # All .properties files to be compiled are appended to this variable. ALL_COMPILED_PROPSOURCES := # All generated .java files from compilation are appended to this variable. @@ -76,7 +73,6 @@ COMPILE_PROP_SRC_FILES := \ $(JDK_TOPDIR)/src/java.management/share/classes/sun/management/resources \ $(JDK_TOPDIR)/src/java.desktop/share/classes/sun/print/resources \ $(JDK_TOPDIR)/src/jdk.dev/share/classes/sun/tools/jar/resources \ - $(JDK_TOPDIR)/src/jdk.dev/share/classes/jdk/jigsaw/tools/jlink/resources \ $(JDK_TOPDIR)/src/java.logging/share/classes/sun/util/logging/resources)) \ # diff --git a/jdk/make/gensrc/GensrcProviders.gmk b/jdk/make/gensrc/GensrcProviders.gmk index 985f032169e..dca14083054 100644 --- a/jdk/make/gensrc/GensrcProviders.gmk +++ b/jdk/make/gensrc/GensrcProviders.gmk @@ -32,15 +32,6 @@ endef ################################################################################ -# Filter com.sun.tools.attach.spi.AttachProvider -$(JDK_OUTPUTDIR)/gensrc/jdk.attach/META-INF/services/com.sun.tools.attach.spi.AttachProvider: \ - $(JDK_TOPDIR)/src/jdk.attach/share/classes/META-INF/services/com.sun.tools.attach.spi.AttachProvider - $(process-provider) - -GENSRC_JDK_ATTACH += $(JDK_OUTPUTDIR)/gensrc/jdk.attach/META-INF/services/com.sun.tools.attach.spi.AttachProvider - -################################################################################ - # Filter com.sun.jdi.connect.Connector $(JDK_OUTPUTDIR)/gensrc/jdk.jdi/META-INF/services/com.sun.jdi.connect.Connector: \ $(JDK_TOPDIR)/src/jdk.jdi/share/classes/META-INF/services/com.sun.jdi.connect.Connector diff --git a/jdk/make/gensrc/GensrcSwing.gmk b/jdk/make/gensrc/GensrcSwing.gmk index 12e2445bb32..c7571269c98 100644 --- a/jdk/make/gensrc/GensrcSwing.gmk +++ b/jdk/make/gensrc/GensrcSwing.gmk @@ -78,11 +78,8 @@ $(JDK_OUTPUTDIR)/gensrc_no_srczip/_the.generated_beaninfo: $(BEANS_SRC) \ $(MKDIR) -p $(JDK_OUTPUTDIR)/gensrc_no_srczip/java.desktop/javax/swing $(JAVA) -Djava.awt.headless=true $(NEW_JAVADOC) \ -sourcepath "$(subst $(SPACE),$(PATH_SEP),\ - $(if $(SHUFFLED),$(wildcard $(JDK_TOPDIR)/src/*/*/classes) \ - $(JDK_OUTPUTDIR)/gensrc/java.base, \ - $(JDK_TOPDIR)/src/share/classes \ - $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/classes \ - $(JDK_OUTPUTDIR)/gensrc))" \ + $(wildcard $(JDK_TOPDIR)/src/*/*/classes) \ + $(JDK_OUTPUTDIR)/gensrc/java.base)" \ -doclet build.tools.swingbeaninfo.GenDocletBeanInfo \ -x $(SWINGBEAN_DEBUG_FLAG) -d $(JDK_OUTPUTDIR)/gensrc_no_srczip/java.desktop/javax/swing \ -t $(DOCLET_DATA_DIR)/SwingBeanInfo.template -docletpath $(JDK_OUTPUTDIR)/btclasses \ diff --git a/jdk/make/lib/Awt2dLibraries.gmk b/jdk/make/lib/Awt2dLibraries.gmk index 774a2675836..e5161a35552 100644 --- a/jdk/make/lib/Awt2dLibraries.gmk +++ b/jdk/make/lib/Awt2dLibraries.gmk @@ -23,12 +23,9 @@ # questions. # -# Hook to include the corresponding custom file, if present. -$(eval $(call IncludeCustomExtension, jdk, lib/Awt2dLibraries.gmk)) - WIN_AWT_LIB := $(JDK_OUTPUTDIR)/objs/libawt/awt.lib -########################################################################################## +################################################################################ BUILD_LIBMLIB_SRC := $(JDK_TOPDIR)/src/java.desktop/share/native/libmlib_image \ $(JDK_TOPDIR)/src/java.desktop/share/native/common/sun/awt/medialib @@ -76,7 +73,7 @@ $(BUILD_LIBMLIB_IMAGE): $(BUILD_LIBJAVA) DESKTOP_LIBRARIES += $(BUILD_LIBMLIB_IMAGE) -########################################################################################## +################################################################################ ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH), solaris-sparc) @@ -144,7 +141,7 @@ ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH), solaris-sparc) endif -########################################################################################## +################################################################################ LIBAWT_DIRS := $(JDK_TOPDIR)/src/java.desktop/share/native/libawt \ $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/libawt \ @@ -152,13 +149,17 @@ LIBAWT_DIRS := $(JDK_TOPDIR)/src/java.desktop/share/native/libawt \ $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/common/sun/awt \ # +ifeq ($(OPENJDK_TARGET_OS), aix) + LIBAWT_DIRS += $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS)/native/libawt +endif + ifeq ($(OPENJDK_TARGET_OS), windows) LIBAWT_DIRS += $(JDK_TOPDIR)/src/java.desktop/share/native/common/sun/awt/utility else LIBAWT_EXFILES := sun/java2d/ShaderList.c endif -ifneq ($(filter $(OPENJDK_TARGET_OS), solaris linux macosx), ) +ifneq ($(filter $(OPENJDK_TARGET_OS), solaris linux macosx aix), ) LIBAWT_EXFILES += awt_Font.c CUPSfuncs.c fontpath.c X11Color.c endif @@ -168,14 +169,11 @@ endif LIBAWT_CFLAGS += -I$(JDK_OUTPUTDIR)/gensrc_headers/java.desktop \ $(addprefix -I, $(shell find $(LIBAWT_DIRS) -type d)) \ - -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/common/sun/awt \ $(LIBJAVA_HEADER_FLAGS) \ $(addprefix -I, $(BUILD_LIBMLIB_IMAGE_SRC)) \ # -LIBAWT_CFLAGS += -D__MEDIALIB_OLD_NAMES -D__USE_J2D_NAMES \ - $(X_CFLAGS) \ - $(foreach dir, $(LIBAWT_DIRS), -I$(dir)) +LIBAWT_CFLAGS += -D__MEDIALIB_OLD_NAMES -D__USE_J2D_NAMES $(X_CFLAGS) ifeq ($(OPENJDK_TARGET_OS), macosx) endif @@ -296,7 +294,7 @@ endif DESKTOP_LIBRARIES += $(BUILD_LIBAWT) -########################################################################################## +################################################################################ ifeq ($(findstring $(OPENJDK_TARGET_OS),windows macosx),) ifndef BUILD_HEADLESS_ONLY @@ -388,7 +386,7 @@ ifeq ($(findstring $(OPENJDK_TARGET_OS),windows macosx),) endif endif -########################################################################################## +################################################################################ LIBLCMS_SRC := $(JDK_TOPDIR)/src/java.desktop/share/native/liblcms LIBLCMS_CPPFLAGS += -I$(JDK_OUTPUTDIR)/gensrc_headers/java.desktop \ @@ -441,7 +439,7 @@ DESKTOP_LIBRARIES += $(BUILD_LIBLCMS) $(BUILD_LIBLCMS): $(BUILD_LIBAWT) -########################################################################################## +################################################################################ ifdef OPENJDK BUILD_LIBJAVAJPEG_MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjpeg/mapfile-vers @@ -515,7 +513,7 @@ $(BUILD_LIBJAVAJPEG): $(BUILD_LIBJAVA) DESKTOP_LIBRARIES += $(BUILD_LIBJAVAJPEG) -########################################################################################## +################################################################################ LIBFONTMANAGER_SRC := $(JDK_TOPDIR)/src/java.desktop/share/native/libfontmanager \ $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/libfontmanager @@ -607,54 +605,7 @@ endif DESKTOP_LIBRARIES += $(BUILD_LIBFONTMANAGER) -########################################################################################## - -ifndef OPENJDK - - LIBT2K_SRC := $(JDK_TOPDIR)/src/closed/java.desktop/share/native/libt2k - LIBT2K_CFLAGS := $(addprefix -I, $(LIBT2K_SRC)) \ - -I$(JDK_TOPDIR)/src/closed/java.desktop/share/native/libt2k/t2k \ - -I$(JDK_TOPDIR)/src/java.desktop/share/native/libfontmanager \ - -I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/sun/java2d \ - -I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/sun/java2d/loops \ - -I$(JDK_TOPDIR)/src/java.desktop/share/native/common/sun/font \ - -I$(JDK_TOPDIR)/src/java.base/share/native/libjava \ - -I$(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_API_DIR)/native/libjava \ - -I$(JDK_OUTPUTDIR)/gensrc_headers/java.desktop \ - # - - $(eval $(call SetupNativeCompilation,BUILD_LIBT2K, \ - LIBRARY := t2k, \ - OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \ - SRC := $(LIBT2K_SRC), \ - EXCLUDE_FILES := t2k/orion.c, \ - LANG := C++, \ - OPTIMIZATION := HIGH, \ - CFLAGS := $(CFLAGS_JDKLIB) $(LIBT2K_CFLAGS), \ - CXXFLAGS := $(CXXFLAGS_JDKLIB) $(LIBT2K_CFLAGS), \ - CFLAGS_windows = -DCC_NOEX, \ - CXXFLAGS_windows = -DCC_NOEX, \ - MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libt2k/mapfile-vers, \ - LDFLAGS := $(LDFLAGS_JDKLIB) $(LDFLAGS_CXX_JDK) \ - $(call SET_SHARED_LIBRARY_ORIGIN), \ - LDFLAGS_windows := user32.lib $(JDK_OUTPUTDIR)/objs/libfontmanager/fontmanager.lib, \ - LDFLAGS_SUFFIX_posix := $(LIBM) $(LIBCXX) -lfontmanager -ljava -ljvm -lc, \ - LDFLAGS_SUFFIX_solaris := -lawt -lawt_xawt, \ - VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \ - RC_FLAGS := $(RC_FLAGS) \ - -D "JDK_FNAME=t2k.dll" \ - -D "JDK_INTERNAL_NAME=t2k" \ - -D "JDK_FTYPE=0x2L", \ - OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libt2k, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) - - # t2k is linked against fontmanager - $(BUILD_LIBT2K): $(BUILD_LIBFONTMANAGER) - - DESKTOP_LIBRARIES += $(BUILD_LIBT2K) -endif - -########################################################################################## +################################################################################ ifeq ($(OPENJDK_TARGET_OS), windows) LIBJAWT_SRC := $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/libjawt @@ -768,99 +719,7 @@ endif # OPENJDK_TARGET_OS DESKTOP_LIBRARIES += $(BUILD_LIBJAWT) -########################################################################################## - -ifndef OPENJDK - - LIBKCMS_SRC := $(JDK_TOPDIR)/src/closed/java.desktop/share/native/libkcms \ - $(JDK_TOPDIR)/src/closed/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/libkcms \ - # - LIBKCMS_CFLAGS += $(addprefix -I, $(LIBKCMS_SRC)) \ - -I$(JDK_TOPDIR)/src/java.base/share/native/libjava \ - -I$(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_API_DIR)/native/libjava \ - -I$(JDK_OUTPUTDIR)/gensrc_headers/java.desktop \ - # - LIBKCMS_VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/closed/java.desktop/windows/native/libkcms/cmm.rc - - LIBKCMS_CFLAGS += $(CFLAGS_JDKLIB) - - ifeq ($(OPENJDK_TARGET_OS), solaris) - # This particular library uses a feature called PIC_CODE_SMALL (on solaris) - # implement it like this...since it's only used here - LIBKCMS_CFLAGS := $(patsubst -KPIC, -Kpic, $(LIBKCMS_CFLAGS)) - else ifeq ($(OPENJDK_TARGET_CPU_ARCH), ppc) - LIBKCMS_CFLAGS := $(patsubst -fPIC, -fpic, $(LIBKCMS_CFLAGS)) - endif - - $(eval $(call SetupNativeCompilation,BUILD_LIBKCMS, \ - LIBRARY := kcms, \ - OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \ - SRC := $(LIBKCMS_SRC), \ - LANG := C, \ - EXCLUDE_FILES := $(BUILD_LIBKCMS_EXCLUDE_FILES), \ - OPTIMIZATION := LOW, \ - CFLAGS := $(LIBKCMS_CFLAGS) \ - -DJAVACMM -DFUT_CALC_EX -DNO_FUT_GCONST, \ - CFLAGS_linux := -Wno-missing-field-initializers, \ - MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libkcms/mapfile-vers, \ - LDFLAGS := $(LDFLAGS_JDKLIB) \ - $(call SET_SHARED_LIBRARY_ORIGIN), \ - LDFLAGS_SUFFIX_linux := -lc -lpthread, \ - LDFLAGS_SUFFIX_solaris := -lc, \ - LDFLAGS_SUFFIX_windows := $(WIN_JAVA_LIB) advapi32.lib user32.lib version.lib, \ - LDFLAGS_SUFFIX_posix := -lm -ljava -ljvm, \ - VERSIONINFO_RESOURCE := $(LIBKCMS_VERSIONINFO_RESOURCE), \ - RC_FLAGS := $(RC_FLAGS) \ - -D "JDK_FNAME=kcms.dll" \ - -D "JDK_INTERNAL_NAME=kcms" \ - -D "JDK_FTYPE=0x2L", \ - OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libkcms, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) - - $(BUILD_LIBKCMS): $(BUILD_LIBJAVA) - - DESKTOP_LIBRARIES += $(BUILD_LIBKCMS) - -endif - -########################################################################################## - -ifndef OPENJDK - ifeq ($(OPENJDK_TARGET_OS), solaris) - ifneq ($(OPENJDK_TARGET_CPU), x86_64) - - ifeq ($(shell if test "$(OS_VERSION_MAJOR)" -eq 5 -a "$(OS_VERSION_MINOR)" -le 10; then $(ECHO) ok; fi), ok) - - SUNWJDGA_MAPFILE := - ifeq ($(OPENJDK_TARGET_CPU_ARCH), sparc) - SUNWJDGA_MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjdga/mapfile-vers - endif - - $(eval $(call SetupNativeCompilation,BUILD_LIBSUNWJDGA, \ - LIBRARY := sunwjdga, \ - OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \ - SRC := $(JDK_TOPDIR)/src/java.desktop/unix/native/libsunwjdga, \ - LANG := C, \ - OPTIMIZATION := LOW, \ - CFLAGS := $(CFLAGS_JDKLIB) \ - -I$(JDK_TOPDIR)/src/share/javavm/export \ - -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/javavm/export \ - $(X_CFLAGS), \ - MAPFILE := $(SUNWJDGA_MAPFILE), \ - LDFLAGS := $(LDFLAGS_JDKLIB) \ - $(call SET_SHARED_LIBRARY_ORIGIN), \ - LDFLAGS_SUFFIX := $(X_LIBS) -ldga -lX11 $(LIBDL) -lc, \ - OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libsunwjdga, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) - - DESKTOP_LIBRARIES += $(BUILD_LIBSUNWJDGA) - - endif - endif - endif -endif - -########################################################################################## +################################################################################ ifeq ($(BUILD_HEADLESS), true) # Mac and Windows only use the native AWT lib, do not build libawt_headless @@ -932,7 +791,7 @@ ifeq ($(BUILD_HEADLESS), true) endif endif -########################################################################################## +################################################################################ ifndef BUILD_HEADLESS_ONLY @@ -973,7 +832,6 @@ ifndef BUILD_HEADLESS_ONLY # ifeq ($(OPENJDK_TARGET_OS), macosx) - LIBSPLASHSCREEN_CFLAGS += -F/System/Library/Frameworks/JavaVM.framework/Frameworks LIBSPLASHSCREEN_CFLAGS += -DWITH_MACOSX LIBSPLASHSCREEN_CFLAGS += -I$(JDK_TOPDIR)/src/java.desktop/macosx/native/libosxapp @@ -1042,47 +900,7 @@ ifndef BUILD_HEADLESS_ONLY endif -########################################################################################## - -ifndef OPENJDK - - LIBDCPR_SRC_DIRS := $(JDK_TOPDIR)/src/closed/java.desktop/share/native/libdcpr - LIBDCPR_CFLAGS := $(addprefix -I, $(shell $(FIND) $(LIBDCPR_SRC_DIRS) -type d)) \ - -I$(JDK_TOPDIR)/src/java.desktop/share/native/libawt/sun/java2d/pipe \ - -I$(JDK_TOPDIR)/src/java.base/share/native/libjava \ - -I$(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_API_DIR)/native/libjava \ - -I$(JDK_OUTPUTDIR)/gensrc_headers/java.desktop \ - # - - $(eval $(call SetupNativeCompilation,BUILD_LIBDCPR, \ - LIBRARY := dcpr, \ - OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \ - SRC := $(LIBDCPR_SRC_DIRS), \ - LANG := C, \ - OPTIMIZATION := LOW, \ - CFLAGS := $(CFLAGS_JDKLIB) \ - $(LIBDCPR_CFLAGS), \ - MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libdcpr/mapfile-vers, \ - LDFLAGS := $(LDFLAGS_JDKLIB) \ - $(call SET_SHARED_LIBRARY_ORIGIN), \ - LDFLAGS_SUFFIX := $(LIBM) $(LDFLAGS_JDKLIB_SUFFIX), \ - LDFLAGS_SUFFIX_windows := $(WIN_JAVA_LIB), \ - LDFLAGS_SUFFIX_posix := -lm, \ - VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \ - RC_FLAGS := $(RC_FLAGS) \ - -D "JDK_FNAME=dcpr.dll" \ - -D "JDK_INTERNAL_NAME=dcpr" \ - -D "JDK_FTYPE=0x2L", \ - OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libdcpr, \ - DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) - - $(BUILD_LIBDCPR): $(BUILD_LIBJAVA) - - DESKTOP_LIBRARIES += $(BUILD_LIBDCPR) - -endif - -########################################################################################## +################################################################################ ifeq ($(OPENJDK_TARGET_OS), macosx) @@ -1159,7 +977,7 @@ ifeq ($(OPENJDK_TARGET_OS), macosx) endif -########################################################################################## +################################################################################ ifeq ($(OPENJDK_TARGET_OS), macosx) @@ -1200,3 +1018,8 @@ ifeq ($(OPENJDK_TARGET_OS), macosx) #$(BUILD_LIBOSXUI): $(BUILD_LIBJAVA) endif + +################################################################################ + +# Hook to include the corresponding custom file, if present. +$(eval $(call IncludeCustomExtension, jdk, lib/Awt2dLibraries.gmk)) diff --git a/jdk/make/lib/CoreLibraries.gmk b/jdk/make/lib/CoreLibraries.gmk index 99a0c46f114..852879f09ee 100644 --- a/jdk/make/lib/CoreLibraries.gmk +++ b/jdk/make/lib/CoreLibraries.gmk @@ -26,6 +26,8 @@ WIN_VERIFY_LIB := $(JDK_OUTPUTDIR)/objs/libverify/verify.lib ########################################################################################## +# libfdlibm is statically linked with libjava below and not delivered into the +# product on its own. BUILD_LIBFDLIBM_OPTIMIZATION := HIGH diff --git a/jdk/make/lib/Lib-java.base.gmk b/jdk/make/lib/Lib-java.base.gmk index cf7f663d6fa..301e31c2df8 100644 --- a/jdk/make/lib/Lib-java.base.gmk +++ b/jdk/make/lib/Lib-java.base.gmk @@ -25,6 +25,10 @@ include LibCommon.gmk +# Prepare the find cache. +$(eval $(call FillCacheFind, $(wildcard $(JDK_TOPDIR)/src/java.base/*/native \ + $(JDK_TOPDIR)/src/*/java.base/*/native))) + include CoreLibraries.gmk include NetworkingLibraries.gmk include NioLibraries.gmk diff --git a/jdk/make/lib/Lib-java.desktop.gmk b/jdk/make/lib/Lib-java.desktop.gmk index bdd919cfeb7..e8661508e93 100644 --- a/jdk/make/lib/Lib-java.desktop.gmk +++ b/jdk/make/lib/Lib-java.desktop.gmk @@ -25,6 +25,10 @@ include LibCommon.gmk +# Prepare the find cache. +$(eval $(call FillCacheFind, $(wildcard $(JDK_TOPDIR)/src/java.desktop/*/native \ + $(JDK_TOPDIR)/src/*/java.desktop/*/native))) + include PlatformLibraries.gmk include Awt2dLibraries.gmk include SoundLibraries.gmk diff --git a/jdk/make/lib/Lib-jdk.attach.gmk b/jdk/make/lib/Lib-jdk.attach.gmk index 65b7b1397d7..2b58e173efb 100644 --- a/jdk/make/lib/Lib-jdk.attach.gmk +++ b/jdk/make/lib/Lib-jdk.attach.gmk @@ -27,33 +27,11 @@ include LibCommon.gmk ################################################################################ -ifeq ($(OPENJDK_TARGET_OS), aix) - LIBATTACH_OS_API_DIR := aix -else - LIBATTACH_OS_API_DIR := $(OPENJDK_TARGET_OS_API_DIR) -endif - -LIBATTACH_SRC := $(JDK_TOPDIR)/src/jdk.attach/$(LIBATTACH_OS_API_DIR)/native/libattach - -LIBATTACH_EXCLUDE_FILES := -ifneq ($(OPENJDK_TARGET_OS), solaris) - LIBATTACH_EXCLUDE_FILES += SolarisVirtualMachine.c -endif -ifneq ($(OPENJDK_TARGET_OS), linux) - LIBATTACH_EXCLUDE_FILES += LinuxVirtualMachine.c -endif -ifneq ($(OPENJDK_TARGET_OS), macosx) - LIBATTACH_EXCLUDE_FILES += BsdVirtualMachine.c -endif -ifneq ($(OPENJDK_TARGET_OS),aix) - LIBATTACH_EXCLUDE_FILES += AixVirtualMachine.c -endif $(eval $(call SetupNativeCompilation,BUILD_LIBATTACH, \ LIBRARY := attach, \ OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \ - SRC := $(LIBATTACH_SRC), \ - EXCLUDE_FILES := $(LIBATTACH_EXCLUDE_FILES), \ + SRC := $(JDK_TOPDIR)/src/jdk.attach/$(OPENJDK_TARGET_OS)/native/libattach, \ LANG := C, \ OPTIMIZATION := LOW, \ CFLAGS := $(CFLAGS_JDKLIB) $(CFLAGS_WARNINGS_ARE_ERRORS) \ diff --git a/jdk/make/lib/Lib-jdk.hprof.agent.gmk b/jdk/make/lib/Lib-jdk.hprof.agent.gmk index 7b7ef69b2e0..a58687da251 100644 --- a/jdk/make/lib/Lib-jdk.hprof.agent.gmk +++ b/jdk/make/lib/Lib-jdk.hprof.agent.gmk @@ -27,11 +27,11 @@ include LibCommon.gmk ################################################################################ -BUILD_LIBHPROF_SRC := $(JDK_TOPDIR)/src/demo/share/jvmti/hprof \ - $(JDK_TOPDIR)/src/demo/$(OPENJDK_TARGET_OS_API_DIR)/jvmti/hprof +BUILD_LIBHPROF_SRC := $(call FindSrcDirsForLib, jdk.hprof.agent, hprof) + BUILD_LIBHPROF_CFLAGS := $(addprefix -I, $(BUILD_LIBHPROF_SRC)) \ -I$(JDK_TOPDIR)/src/demo/share/jvmti/java_crw_demo - + BUILD_LIBHPROF_LDFLAGS := LIBHPROF_OPTIMIZATION := HIGHEST diff --git a/jdk/make/lib/LibCommon.gmk b/jdk/make/lib/LibCommon.gmk index 7fadd1c781f..885ba11c780 100644 --- a/jdk/make/lib/LibCommon.gmk +++ b/jdk/make/lib/LibCommon.gmk @@ -29,9 +29,6 @@ include $(SPEC) include MakeBase.gmk include NativeCompilation.gmk -# Prepare the find cache. -$(eval $(call FillCacheFind, $(wildcard $(JDK_TOPDIR)/src/*/*/native))) - # Build tools include Tools.gmk diff --git a/jdk/make/lib/NetworkingLibraries.gmk b/jdk/make/lib/NetworkingLibraries.gmk index e61f80be925..a0825b06ce2 100644 --- a/jdk/make/lib/NetworkingLibraries.gmk +++ b/jdk/make/lib/NetworkingLibraries.gmk @@ -44,7 +44,7 @@ ifneq ($(OPENJDK_TARGET_OS), macosx) endif ifeq ($(OPENJDK_TARGET_OS), aix) - LIBNET_SRC_DIRS += $(JDK_TOPDIR)/src/aix/native/java/net/ + LIBNET_SRC_DIRS += $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/native/libnet/java/net/ endif $(eval $(call SetupNativeCompilation,BUILD_LIBNET, \ diff --git a/jdk/make/lib/NioLibraries.gmk b/jdk/make/lib/NioLibraries.gmk index 259517c2aad..722115fdee5 100644 --- a/jdk/make/lib/NioLibraries.gmk +++ b/jdk/make/lib/NioLibraries.gmk @@ -56,17 +56,8 @@ endif ifeq ($(OPENJDK_TARGET_OS), aix) BUILD_LIBNIO_MAPFILE:=$(JDK_TOPDIR)/make/mapfiles/libnio/mapfile-$(OPENJDK_TARGET_OS) - BUILD_LIBNIO_FILES += \ - AixPollPort.c \ - InheritedChannel.c \ - AixNativeThread.c \ - PollArrayWrapper.c \ - UnixAsynchronousServerSocketChannelImpl.c \ - UnixAsynchronousSocketChannelImpl.c \ - GnomeFileTypeDetector.c \ - UnixCopyFile.c \ - AixNativeDispatcher.c \ - UnixNativeDispatcher.c + BUILD_LIBNIO_EXFILES += \ + NativeThread.c endif $(eval $(call SetupNativeCompilation,BUILD_LIBNIO, \ diff --git a/jdk/make/mapfiles/libattach/mapfile-aix b/jdk/make/mapfiles/libattach/mapfile-aix index 4c02da01fce..10ca49534ba 100644 --- a/jdk/make/mapfiles/libattach/mapfile-aix +++ b/jdk/make/mapfiles/libattach/mapfile-aix @@ -27,13 +27,13 @@ SUNWprivate_1.1 { global: - Java_sun_tools_attach_AixVirtualMachine_socket - Java_sun_tools_attach_AixVirtualMachine_connect - Java_sun_tools_attach_AixVirtualMachine_sendQuitTo - Java_sun_tools_attach_AixVirtualMachine_checkPermissions - Java_sun_tools_attach_AixVirtualMachine_close - Java_sun_tools_attach_AixVirtualMachine_read - Java_sun_tools_attach_AixVirtualMachine_write + Java_sun_tools_attach_VirtualMachineImpl_socket + Java_sun_tools_attach_VirtualMachineImpl_connect + Java_sun_tools_attach_VirtualMachineImpl_sendQuitTo + Java_sun_tools_attach_VirtualMachineImpl_checkPermissions + Java_sun_tools_attach_VirtualMachineImpl_close + Java_sun_tools_attach_VirtualMachineImpl_read + Java_sun_tools_attach_VirtualMachineImpl_write local: *; }; diff --git a/jdk/make/mapfiles/libattach/mapfile-linux b/jdk/make/mapfiles/libattach/mapfile-linux index fbfdedfdad9..b569ae5e637 100644 --- a/jdk/make/mapfiles/libattach/mapfile-linux +++ b/jdk/make/mapfiles/libattach/mapfile-linux @@ -27,17 +27,17 @@ SUNWprivate_1.1 { global: - Java_sun_tools_attach_LinuxVirtualMachine_checkPermissions; - Java_sun_tools_attach_LinuxVirtualMachine_close; - Java_sun_tools_attach_LinuxVirtualMachine_connect; - Java_sun_tools_attach_LinuxVirtualMachine_getLinuxThreadsManager; - Java_sun_tools_attach_LinuxVirtualMachine_isLinuxThreads; - Java_sun_tools_attach_LinuxVirtualMachine_open; - Java_sun_tools_attach_LinuxVirtualMachine_sendQuitTo; - Java_sun_tools_attach_LinuxVirtualMachine_sendQuitToChildrenOf; - Java_sun_tools_attach_LinuxVirtualMachine_socket; - Java_sun_tools_attach_LinuxVirtualMachine_read; - Java_sun_tools_attach_LinuxVirtualMachine_write; + Java_sun_tools_attach_VirtualMachineImpl_checkPermissions; + Java_sun_tools_attach_VirtualMachineImpl_close; + Java_sun_tools_attach_VirtualMachineImpl_connect; + Java_sun_tools_attach_VirtualMachineImpl_getLinuxThreadsManager; + Java_sun_tools_attach_VirtualMachineImpl_isLinuxThreads; + Java_sun_tools_attach_VirtualMachineImpl_open; + Java_sun_tools_attach_VirtualMachineImpl_sendQuitTo; + Java_sun_tools_attach_VirtualMachineImpl_sendQuitToChildrenOf; + Java_sun_tools_attach_VirtualMachineImpl_socket; + Java_sun_tools_attach_VirtualMachineImpl_read; + Java_sun_tools_attach_VirtualMachineImpl_write; local: *; }; diff --git a/jdk/make/mapfiles/libattach/mapfile-solaris b/jdk/make/mapfiles/libattach/mapfile-solaris index 6e61f754b99..df71490fdb8 100644 --- a/jdk/make/mapfiles/libattach/mapfile-solaris +++ b/jdk/make/mapfiles/libattach/mapfile-solaris @@ -27,12 +27,12 @@ SUNWprivate_1.1 { global: - Java_sun_tools_attach_SolarisVirtualMachine_checkPermissions; - Java_sun_tools_attach_SolarisVirtualMachine_enqueue; - Java_sun_tools_attach_SolarisVirtualMachine_open; - Java_sun_tools_attach_SolarisVirtualMachine_close; - Java_sun_tools_attach_SolarisVirtualMachine_read; - Java_sun_tools_attach_SolarisVirtualMachine_sigquit; + Java_sun_tools_attach_VirtualMachineImpl_checkPermissions; + Java_sun_tools_attach_VirtualMachineImpl_enqueue; + Java_sun_tools_attach_VirtualMachineImpl_open; + Java_sun_tools_attach_VirtualMachineImpl_close; + Java_sun_tools_attach_VirtualMachineImpl_read; + Java_sun_tools_attach_VirtualMachineImpl_sigquit; local: *; }; diff --git a/jdk/make/mapfiles/libjava/mapfile-vers b/jdk/make/mapfiles/libjava/mapfile-vers index ca99cc5c03b..3b1d894ff71 100644 --- a/jdk/make/mapfiles/libjava/mapfile-vers +++ b/jdk/make/mapfiles/libjava/mapfile-vers @@ -78,13 +78,13 @@ SUNWprivate_1.1 { Java_java_io_FileInputStream_available; Java_java_io_FileInputStream_close0; Java_java_io_FileInputStream_initIDs; - Java_java_io_FileInputStream_open; + Java_java_io_FileInputStream_open0; Java_java_io_FileInputStream_read0; Java_java_io_FileInputStream_readBytes; Java_java_io_FileInputStream_skip; Java_java_io_FileOutputStream_close0; Java_java_io_FileOutputStream_initIDs; - Java_java_io_FileOutputStream_open; + Java_java_io_FileOutputStream_open0; Java_java_io_FileOutputStream_write; Java_java_io_FileOutputStream_writeBytes; Java_java_io_ObjectInputStream_bytesToDoubles; @@ -97,7 +97,7 @@ SUNWprivate_1.1 { Java_java_io_RandomAccessFile_getFilePointer; Java_java_io_RandomAccessFile_initIDs; Java_java_io_RandomAccessFile_length; - Java_java_io_RandomAccessFile_open; + Java_java_io_RandomAccessFile_open0; Java_java_io_RandomAccessFile_read0; Java_java_io_RandomAccessFile_readBytes; Java_java_io_RandomAccessFile_seek0; diff --git a/jdk/make/mapfiles/libjava/reorder-sparc b/jdk/make/mapfiles/libjava/reorder-sparc index 4a5cbf45018..d10037652d1 100644 --- a/jdk/make/mapfiles/libjava/reorder-sparc +++ b/jdk/make/mapfiles/libjava/reorder-sparc @@ -44,7 +44,7 @@ text: .text%Java_java_io_UnixFileSystem_initIDs; text: .text%Java_java_io_UnixFileSystem_canonicalize; text: .text%JNU_GetStringPlatformChars; text: .text%JNU_ReleaseStringPlatformChars; -text: .text%Java_java_io_FileInputStream_open; +text: .text%Java_java_io_FileInputStream_open0; text: .text%fileOpen; text: .text%Java_java_io_FileInputStream_readBytes; text: .text%readBytes; diff --git a/jdk/make/mapfiles/libjava/reorder-sparcv9 b/jdk/make/mapfiles/libjava/reorder-sparcv9 index 81cbfcb2410..2609711c21f 100644 --- a/jdk/make/mapfiles/libjava/reorder-sparcv9 +++ b/jdk/make/mapfiles/libjava/reorder-sparcv9 @@ -47,7 +47,7 @@ text: .text%Java_java_io_UnixFileSystem_initIDs; text: .text%Java_java_io_UnixFileSystem_canonicalize; text: .text%JNU_GetStringPlatformChars; text: .text%JNU_ReleaseStringPlatformChars; -text: .text%Java_java_io_FileInputStream_open; +text: .text%Java_java_io_FileInputStream_open0; text: .text%fileOpen; text: .text%Java_java_io_FileInputStream_readBytes; text: .text%readBytes; diff --git a/jdk/make/mapfiles/libjava/reorder-x86 b/jdk/make/mapfiles/libjava/reorder-x86 index 1c971b80eda..b8ea2d43dae 100644 --- a/jdk/make/mapfiles/libjava/reorder-x86 +++ b/jdk/make/mapfiles/libjava/reorder-x86 @@ -57,7 +57,7 @@ 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_io_FileInputStream_open; +text: .text%Java_java_io_FileInputStream_open0; text: .text%fileOpen; text: .text%Java_java_io_UnixFileSystem_getLength; text: .text%Java_java_io_FileInputStream_readBytes; @@ -90,7 +90,7 @@ text: .text%JNU_NotifyAll; text: .text%JNU_CallMethodByName; text: .text%JNU_CallMethodByNameV; text: .text%Java_java_util_logging_FileHandler_lockFile; -text: .text%Java_java_io_FileOutputStream_open; +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; diff --git a/jdk/make/mapfiles/libnio/mapfile-linux b/jdk/make/mapfiles/libnio/mapfile-linux index 16f72e43cfa..53555c4763f 100644 --- a/jdk/make/mapfiles/libnio/mapfile-linux +++ b/jdk/make/mapfiles/libnio/mapfile-linux @@ -79,6 +79,7 @@ SUNWprivate_1.1 { Java_sun_nio_ch_InheritedChannel_close0; Java_sun_nio_ch_InheritedChannel_dup; Java_sun_nio_ch_InheritedChannel_dup2; + Java_sun_nio_ch_InheritedChannel_initIDs; Java_sun_nio_ch_InheritedChannel_open0; Java_sun_nio_ch_InheritedChannel_peerAddress0; Java_sun_nio_ch_InheritedChannel_peerPort0; diff --git a/jdk/make/mapfiles/libnio/mapfile-macosx b/jdk/make/mapfiles/libnio/mapfile-macosx index 4dd0dc513e4..d4b6dc5a219 100644 --- a/jdk/make/mapfiles/libnio/mapfile-macosx +++ b/jdk/make/mapfiles/libnio/mapfile-macosx @@ -62,6 +62,7 @@ SUNWprivate_1.1 { Java_sun_nio_ch_InheritedChannel_close0; Java_sun_nio_ch_InheritedChannel_dup; Java_sun_nio_ch_InheritedChannel_dup2; + Java_sun_nio_ch_InheritedChannel_initIDs; Java_sun_nio_ch_InheritedChannel_open0; Java_sun_nio_ch_InheritedChannel_peerAddress0; Java_sun_nio_ch_InheritedChannel_peerPort0; diff --git a/jdk/make/mapfiles/libnio/mapfile-solaris b/jdk/make/mapfiles/libnio/mapfile-solaris index 3933cef7ada..cdbb851bcad 100644 --- a/jdk/make/mapfiles/libnio/mapfile-solaris +++ b/jdk/make/mapfiles/libnio/mapfile-solaris @@ -67,6 +67,7 @@ SUNWprivate_1.1 { Java_sun_nio_ch_InheritedChannel_close0; Java_sun_nio_ch_InheritedChannel_dup; Java_sun_nio_ch_InheritedChannel_dup2; + Java_sun_nio_ch_InheritedChannel_initIDs; Java_sun_nio_ch_InheritedChannel_open0; Java_sun_nio_ch_InheritedChannel_peerAddress0; Java_sun_nio_ch_InheritedChannel_peerPort0; diff --git a/jdk/make/profile-rtjar-includes.txt b/jdk/make/profile-rtjar-includes.txt index 1e954ad625c..8ab7336fb17 100644 --- a/jdk/make/profile-rtjar-includes.txt +++ b/jdk/make/profile-rtjar-includes.txt @@ -201,6 +201,7 @@ FULL_JRE_RTJAR_INCLUDE_PACKAGES := \ sun/audio \ sun/awt \ sun/corba \ + sun/datatransfer \ sun/dc \ sun/font \ sun/java2d \ diff --git a/jdk/make/src/classes/build/tools/addtorestrictedpkgs/AddToRestrictedPkgs.java b/jdk/make/src/classes/build/tools/addtorestrictedpkgs/AddToRestrictedPkgs.java deleted file mode 100644 index ee9deb4b75f..00000000000 --- a/jdk/make/src/classes/build/tools/addtorestrictedpkgs/AddToRestrictedPkgs.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package build.tools.addtorestrictedpkgs; - -import java.io.*; - -/** - * Adds additional packages to the package.access and package.definition - * security properties. - */ -public class AddToRestrictedPkgs { - - private static final String PKG_ACC = "package.access"; - private static final String PKG_DEF = "package.definition"; - private static final int PKG_ACC_INDENT = 15; - private static final int PKG_DEF_INDENT = 19; - - public static void main(String[] args) throws Exception { - - if (args.length < 3) { - System.err.println("Usage: java AddToRestrictedPkgs " + - "[input java.security file name] " + - "[output java.security file name] " + - "[packages ...]"); - System.exit(1); - } - - try (FileReader fr = new FileReader(args[0]); - BufferedReader br = new BufferedReader(fr); - FileWriter fw = new FileWriter(args[1]); - BufferedWriter bw = new BufferedWriter(fw)) - { - // parse the file line-by-line, looking for pkg access properties - String line = br.readLine(); - while (line != null) { - if (line.startsWith(PKG_ACC)) { - writePackages(br, bw, line, PKG_ACC_INDENT, args); - } else if (line.startsWith(PKG_DEF)) { - writePackages(br, bw, line, PKG_DEF_INDENT, args); - } else { - writeLine(bw, line); - } - line = br.readLine(); - } - bw.flush(); - } - } - - private static void writePackages(BufferedReader br, BufferedWriter bw, - String line, int numSpaces, - String[] args) throws IOException { - // parse property until EOL, not including line breaks - while (line.endsWith("\\")) { - writeLine(bw, line); - line = br.readLine(); - } - // append comma and line-break to last package - writeLine(bw, line + ",\\"); - // add new packages, one per line - for (int i = 2; i < args.length - 1; i++) { - indent(bw, numSpaces); - writeLine(bw, args[i] + ",\\"); - } - indent(bw, numSpaces); - writeLine(bw, args[args.length - 1]); - } - - private static void writeLine(BufferedWriter bw, String line) - throws IOException - { - bw.write(line); - bw.newLine(); - } - - private static void indent(BufferedWriter bw, int numSpaces) - throws IOException - { - for (int i = 0; i < numSpaces; i++) { - bw.append(' '); - } - } -} diff --git a/jdk/make/src/classes/build/tools/makejavasecurity/MakeJavaSecurity.java b/jdk/make/src/classes/build/tools/makejavasecurity/MakeJavaSecurity.java new file mode 100644 index 00000000000..d5c6e14c7b1 --- /dev/null +++ b/jdk/make/src/classes/build/tools/makejavasecurity/MakeJavaSecurity.java @@ -0,0 +1,168 @@ +/* + * 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 build.tools.makejavasecurity; + +import java.io.*; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.*; + +/** + * Builds the java.security file, including + * + * 1. Adds additional packages to the package.access and + * package.definition security properties. + * 2. Filter out platform-unrelated parts + * + * In order to easily maintain platform-related entries, every item + * (including the last line) in package.access and package.definition + * MUST end with ',\'. A blank line MUST exist after the last line. + */ +public class MakeJavaSecurity { + + private static final String PKG_ACC = "package.access"; + private static final String PKG_DEF = "package.definition"; + private static final int PKG_ACC_INDENT = 15; + private static final int PKG_DEF_INDENT = 19; + + public static void main(String[] args) throws Exception { + + if (args.length < 3) { + System.err.println("Usage: java MakeJavaSecurity " + + "[input java.security file name] " + + "[output java.security file name] " + + "[openjdk target os] " + + "[more restricted packages file name?]"); + System.exit(1); + } + + // more restricted packages + List extraLines; + if (args.length == 4) { + extraLines = Files.readAllLines(Paths.get(args[3])); + } else { + extraLines = Collections.emptyList(); + } + + List lines = new ArrayList<>(); + + // read raw java.security and add more restricted packages + try (FileReader fr = new FileReader(args[0]); + BufferedReader br = new BufferedReader(fr)) { + // looking for pkg access properties + String line = br.readLine(); + while (line != null) { + if (line.startsWith(PKG_ACC)) { + addPackages(br, lines, line, PKG_ACC_INDENT, extraLines); + } else if (line.startsWith(PKG_DEF)) { + addPackages(br, lines, line, PKG_DEF_INDENT, extraLines); + } else { + lines.add(line); + } + line = br.readLine(); + } + } + + // Filter out platform-unrelated ones. We only support + // #ifdef, #ifndef, and #endif. + int mode = 0; // 0: out of block, 1: in match, 2: in non-match + Iterator iter = lines.iterator(); + while (iter.hasNext()) { + String line = iter.next(); + if (line.startsWith("#endif")) { + mode = 0; + iter.remove(); + } else if (line.startsWith("#ifdef ")) { + mode = line.endsWith(args[2])?1:2; + iter.remove(); + } else if (line.startsWith("#ifndef ")) { + mode = line.endsWith(args[2])?2:1; + iter.remove(); + } else { + if (mode == 2) iter.remove(); + } + } + + // Update .tbd to .1, .2, etc. + Map count = new HashMap<>(); + for (int i=0; i= 0) { + String prefix = line.substring(0, index); + int n = count.getOrDefault(prefix, 1); + count.put(prefix, n+1); + lines.set(i, prefix + "." + n + line.substring(index+4)); + } + } + + // Clean up the last line of PKG_ACC and PKG_DEF blocks. + // Not really necessary since a blank line follows. + boolean inBlock = false; + for (int i=0; i lines, + String line, int numSpaces, + List args) throws IOException { + // parse property until EOL, not including line breaks + boolean first = true; + while (!line.isEmpty()) { + if (!line.startsWith("#")) { + if (!line.endsWith(",\\") || + (!first && line.contains("="))) { + throw new IOException("Invalid line: " + line); + } + } + lines.add(line); + line = br.readLine(); + first = false; + } + // add new packages, one per line + for (String arg: args) { + if (arg.startsWith("#")) { + lines.add(arg); + } else { + lines.add(String.format("%"+numSpaces+"s", "") + arg + ",\\"); + } + } + lines.add(line); + } +} diff --git a/jdk/make/src/classes/build/tools/module/GenerateModulesXml.java b/jdk/make/src/classes/build/tools/module/GenJdepsModulesXml.java similarity index 90% rename from jdk/make/src/classes/build/tools/module/GenerateModulesXml.java rename to jdk/make/src/classes/build/tools/module/GenJdepsModulesXml.java index c2fdf4ae9d1..43ba458f326 100644 --- a/jdk/make/src/classes/build/tools/module/GenerateModulesXml.java +++ b/jdk/make/src/classes/build/tools/module/GenJdepsModulesXml.java @@ -25,6 +25,7 @@ package build.tools.module; +import java.io.BufferedInputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -49,47 +50,56 @@ import javax.xml.stream.events.Attribute; import javax.xml.stream.events.XMLEvent; /** - * This tool is used to generate com/sun/tools/jdeps/resources/modules.xml - * for jdeps to analyze dependencies and enforce module boundaries. + * GenJdepsModulesXml augments the input modules.xml file(s) + * to include the module membership from the given path to + * the JDK exploded image. The output file is used by jdeps + * to analyze dependencies and enforce module boundaries. * - * $ java build.tools.module.GenerateModulesXml \ - * com/sun/tools/jdeps/resources/modules.xml $OUTPUTDIR/modules + * The input modules.xml file defines the modular structure of + * the JDK as described in JEP 200: The Modular JDK + * (http://openjdk.java.net/jeps/200). * - * This will generate modules.xml as jdeps resources that extend - * the metadata to include module membership (jdeps needs the - * membership information to determine which module a type belongs to.) + * $ java build.tools.module.GenJdepsModulesXml \ + * -o com/sun/tools/jdeps/resources/modules.xml \ + * -mp $OUTPUTDIR/modules \ + * top/modules.xml */ -public final class GenerateModulesXml { +public final class GenJdepsModulesXml { private final static String USAGE = - "Usage: GenerateModulesXml build/modules"; + "Usage: GenJdepsModulesXml -o -mp build/modules path-to-modules-xml"; public static void main(String[] args) throws Exception { - if (args.length < 2) { + Path outfile = null; + Path modulepath = null; + int i = 0; + while (i < args.length) { + String arg = args[i]; + if (arg.equals("-o")) { + outfile = Paths.get(args[i+1]); + i = i+2; + } else if (arg.equals("-mp")) { + modulepath = Paths.get(args[i+1]); + i = i+2; + if (!Files.isDirectory(modulepath)) { + System.err.println(modulepath + " is not a directory"); + System.exit(1); + } + } else { + break; + } + } + if (outfile == null || modulepath == null || i >= args.length) { System.err.println(USAGE); System.exit(-1); } - Path outfile = Paths.get(args[0]); - Path modulepath = Paths.get(args[1]); - - if (!Files.isDirectory(modulepath)) { - System.err.println(modulepath + " is not a directory"); - System.exit(1); - } - GenerateModulesXml gentool = - new GenerateModulesXml(modulepath); - Set modules; - try (InputStream in = GenerateModulesXml.class.getResourceAsStream("modules.xml")) { - modules = gentool.load(in); - } - - InputStream in = GenerateModulesXml.class.getResourceAsStream("closed/modules.xml"); - if (in != null) { - try { + GenJdepsModulesXml gentool = new GenJdepsModulesXml(modulepath); + Set modules = new HashSet<>(); + for (; i < args.length; i++) { + Path p = Paths.get(args[i]); + try (InputStream in = new BufferedInputStream(Files.newInputStream(p))) { Set mods = gentool.load(in); modules.addAll(mods); - } finally { - in.close(); } } @@ -98,7 +108,7 @@ public final class GenerateModulesXml { } final Path modulepath; - public GenerateModulesXml(Path modulepath) { + public GenJdepsModulesXml(Path modulepath) { this.modulepath = modulepath; } @@ -275,7 +285,7 @@ public final class GenerateModulesXml { m.exports().keySet().stream() .filter(pn -> m.exports().get(pn).isEmpty()) .sorted() - .forEach(pn -> GenerateModulesXml.this.writeExportElement(xtw, pn, depth+1)); + .forEach(pn -> writeExportElement(xtw, pn, depth+1)); m.exports().entrySet().stream() .filter(e -> !e.getValue().isEmpty()) .sorted(Map.Entry.comparingByKey()) diff --git a/jdk/src/demo/share/jfc/Font2DTest/resources/TextResources.properties b/jdk/src/demo/share/jfc/Font2DTest/resources/TextResources.properties deleted file mode 100644 index 1bbea03ee06..00000000000 --- a/jdk/src/demo/share/jfc/Font2DTest/resources/TextResources.properties +++ /dev/null @@ -1 +0,0 @@ -string=This is Java 2D! (Default) diff --git a/jdk/src/demo/share/jfc/Font2DTest/resources/TextResources_de.properties b/jdk/src/demo/share/jfc/Font2DTest/resources/TextResources_de.properties deleted file mode 100644 index d38794cd911..00000000000 --- a/jdk/src/demo/share/jfc/Font2DTest/resources/TextResources_de.properties +++ /dev/null @@ -1 +0,0 @@ -string=This is Java 2D! (German) \u00f6 \u00df \u00dc diff --git a/jdk/src/demo/share/jfc/Font2DTest/resources/TextResources_en.properties b/jdk/src/demo/share/jfc/Font2DTest/resources/TextResources_en.properties deleted file mode 100644 index efff7d0b1bb..00000000000 --- a/jdk/src/demo/share/jfc/Font2DTest/resources/TextResources_en.properties +++ /dev/null @@ -1 +0,0 @@ -string=This is Java 2D! (English) A B C diff --git a/jdk/src/demo/share/jfc/Font2DTest/resources/TextResources_en_GB.properties b/jdk/src/demo/share/jfc/Font2DTest/resources/TextResources_en_GB.properties deleted file mode 100644 index be4261d5195..00000000000 --- a/jdk/src/demo/share/jfc/Font2DTest/resources/TextResources_en_GB.properties +++ /dev/null @@ -1 +0,0 @@ -string=This is Java 2D! (English in Great Britain) \u0075 \u006b Z diff --git a/jdk/src/demo/share/jfc/Font2DTest/resources/TextResources_ja.properties b/jdk/src/demo/share/jfc/Font2DTest/resources/TextResources_ja.properties deleted file mode 100644 index f5cb9d735a0..00000000000 --- a/jdk/src/demo/share/jfc/Font2DTest/resources/TextResources_ja.properties +++ /dev/null @@ -1 +0,0 @@ -string=Java 2D\u3067\u3059\u3002(\u30C7\u30D5\u30A9\u30EB\u30C8) diff --git a/jdk/src/demo/share/jfc/Font2DTest/resources/TextResources_ko.properties b/jdk/src/demo/share/jfc/Font2DTest/resources/TextResources_ko.properties deleted file mode 100644 index 819d2c3cc60..00000000000 --- a/jdk/src/demo/share/jfc/Font2DTest/resources/TextResources_ko.properties +++ /dev/null @@ -1 +0,0 @@ -string=This is Java 2D! (Korean) diff --git a/jdk/src/demo/share/jfc/Font2DTest/resources/TextResources_zh_CN.properties b/jdk/src/demo/share/jfc/Font2DTest/resources/TextResources_zh_CN.properties deleted file mode 100644 index 7f7fa0d51d1..00000000000 --- a/jdk/src/demo/share/jfc/Font2DTest/resources/TextResources_zh_CN.properties +++ /dev/null @@ -1 +0,0 @@ -string=\u8FD9\u662F Java 2D! (\u9ED8\u8BA4\u503C) diff --git a/jdk/src/demo/share/jfc/Font2DTest/resources/resource.data b/jdk/src/demo/share/jfc/Font2DTest/resources/resource.data deleted file mode 100644 index f18b78e4cde..00000000000 --- a/jdk/src/demo/share/jfc/Font2DTest/resources/resource.data +++ /dev/null @@ -1,5 +0,0 @@ -en US -en GB -ko KO -ab KO -de DE diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/README b/jdk/src/demo/share/jpda/com/sun/tools/example/README deleted file mode 100644 index 13e1540f14c..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/README +++ /dev/null @@ -1,3 +0,0 @@ -Please refer to the documentation in: - - doc/index.html diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/AccessWatchpointSpec.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/AccessWatchpointSpec.java deleted file mode 100644 index 0d9fe21a7d3..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/AccessWatchpointSpec.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import com.sun.jdi.*; - -public class AccessWatchpointSpec extends WatchpointSpec { - - AccessWatchpointSpec(EventRequestSpecList specs, - ReferenceTypeSpec refSpec, String fieldId) { - super(specs, refSpec, fieldId); - } - - /** - * The 'refType' is known to match. - */ - @Override - void resolve(ReferenceType refType) throws InvalidTypeException, - NoSuchFieldException { - if (!(refType instanceof ClassType)) { - throw new InvalidTypeException(); - } - Field field = refType.fieldByName(fieldId); - if (field == null) { - throw new NoSuchFieldException(fieldId); - } - setRequest(refType.virtualMachine().eventRequestManager() - .createAccessWatchpointRequest(field)); - } - - @Override - public boolean equals(Object obj) { - return (obj instanceof AccessWatchpointSpec) && super.equals(obj); - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/AmbiguousMethodException.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/AmbiguousMethodException.java deleted file mode 100644 index 97d54dd32c8..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/AmbiguousMethodException.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -public class AmbiguousMethodException extends Exception -{ - - private static final long serialVersionUID = 7793370943251707514L; - - public AmbiguousMethodException() - { - super(); - } - - public AmbiguousMethodException(String s) - { - super(s); - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/BreakpointSpec.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/BreakpointSpec.java deleted file mode 100644 index 50059c1ff49..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/BreakpointSpec.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -public abstract class BreakpointSpec extends EventRequestSpec { - - BreakpointSpec(EventRequestSpecList specs, ReferenceTypeSpec refSpec) { - super(specs, refSpec); - } - - @Override - void notifySet(SpecListener listener, SpecEvent evt) { - listener.breakpointSet(evt); - } - - @Override - void notifyDeferred(SpecListener listener, SpecEvent evt) { - listener.breakpointDeferred(evt); - } - - @Override - void notifyResolved(SpecListener listener, SpecEvent evt) { - listener.breakpointResolved(evt); - } - - @Override - void notifyDeleted(SpecListener listener, SpecEvent evt) { - listener.breakpointDeleted(evt); - } - - @Override - void notifyError(SpecListener listener, SpecErrorEvent evt) { - listener.breakpointError(evt); - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ChildSession.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ChildSession.java deleted file mode 100644 index b6042a6e845..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ChildSession.java +++ /dev/null @@ -1,309 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import com.sun.jdi.*; -import com.sun.jdi.connect.LaunchingConnector; -import com.sun.jdi.connect.Connector; -import com.sun.jdi.connect.VMStartException; -import com.sun.jdi.connect.IllegalConnectorArgumentsException; -import java.io.*; -import java.util.Map; -import javax.swing.SwingUtilities; - - -class ChildSession extends Session { - - private Process process; - - private PrintWriter in; - private BufferedReader out; - private BufferedReader err; - - private InputListener input; - private OutputListener output; - private OutputListener error; - - public ChildSession(ExecutionManager runtime, - String userVMArgs, String cmdLine, - InputListener input, - OutputListener output, - OutputListener error, - OutputListener diagnostics) { - this(runtime, getVM(diagnostics, userVMArgs, cmdLine), - input, output, error, diagnostics); - } - - public ChildSession(ExecutionManager runtime, - LaunchingConnector connector, - Map arguments, - InputListener input, - OutputListener output, - OutputListener error, - OutputListener diagnostics) { - this(runtime, generalGetVM(diagnostics, connector, arguments), - input, output, error, diagnostics); - } - - private ChildSession(ExecutionManager runtime, - VirtualMachine vm, - InputListener input, - OutputListener output, - OutputListener error, - OutputListener diagnostics) { - super(vm, runtime, diagnostics); - this.input = input; - this.output = output; - this.error = error; - } - - @Override - public boolean attach() { - - if (!connectToVMProcess()) { - diagnostics.putString("Could not launch VM"); - return false; - } - - /* - * Create a Thread that will retrieve and display any output. - * Needs to be high priority, else debugger may exit before - * it can be displayed. - */ - - //### Rename InputWriter and OutputReader classes - //### Thread priorities cribbed from ttydebug. Think about them. - - OutputReader outputReader = - new OutputReader("output reader", "output", - out, output, diagnostics); - outputReader.setPriority(Thread.MAX_PRIORITY-1); - outputReader.start(); - - OutputReader errorReader = - new OutputReader("error reader", "error", - err, error, diagnostics); - errorReader.setPriority(Thread.MAX_PRIORITY-1); - errorReader.start(); - - InputWriter inputWriter = - new InputWriter("input writer", in, input); - inputWriter.setPriority(Thread.MAX_PRIORITY-1); - inputWriter.start(); - - if (!super.attach()) { - if (process != null) { - process.destroy(); - process = null; - } - return false; - } - - //### debug - //System.out.println("IO after attach: "+ inputWriter + " " + outputReader + " "+ errorReader); - - return true; - } - - @Override - public void detach() { - - //### debug - //System.out.println("IO before detach: "+ inputWriter + " " + outputReader + " "+ errorReader); - - super.detach(); - - /* - inputWriter.quit(); - outputReader.quit(); - errorReader.quit(); - */ - - if (process != null) { - process.destroy(); - process = null; - } - - } - - /** - * Launch child java interpreter, return host:port - */ - - static private void dumpStream(OutputListener diagnostics, - InputStream stream) throws IOException { - BufferedReader in = - new BufferedReader(new InputStreamReader(stream)); - String line; - while ((line = in.readLine()) != null) { - diagnostics.putString(line); - } - } - - static private void dumpFailedLaunchInfo(OutputListener diagnostics, - Process process) { - try { - dumpStream(diagnostics, process.getErrorStream()); - dumpStream(diagnostics, process.getInputStream()); - } catch (IOException e) { - diagnostics.putString("Unable to display process output: " + - e.getMessage()); - } - } - - static private VirtualMachine getVM(OutputListener diagnostics, - String userVMArgs, - String cmdLine) { - VirtualMachineManager manager = Bootstrap.virtualMachineManager(); - LaunchingConnector connector = manager.defaultConnector(); - Map arguments = connector.defaultArguments(); - arguments.get("options").setValue(userVMArgs); - arguments.get("main").setValue(cmdLine); - return generalGetVM(diagnostics, connector, arguments); - } - - static private VirtualMachine generalGetVM(OutputListener diagnostics, - LaunchingConnector connector, - Map arguments) { - VirtualMachine vm = null; - try { - diagnostics.putString("Starting child."); - vm = connector.launch(arguments); - } catch (IOException ioe) { - diagnostics.putString("Unable to start child: " + ioe.getMessage()); - } catch (IllegalConnectorArgumentsException icae) { - diagnostics.putString("Unable to start child: " + icae.getMessage()); - } catch (VMStartException vmse) { - diagnostics.putString("Unable to start child: " + vmse.getMessage() + '\n'); - dumpFailedLaunchInfo(diagnostics, vmse.process()); - } - return vm; - } - - private boolean connectToVMProcess() { - if (vm == null) { - return false; - } - process = vm.process(); - in = new PrintWriter(new OutputStreamWriter(process.getOutputStream())); - //### Note small buffer sizes! - out = new BufferedReader(new InputStreamReader(process.getInputStream()), 1); - err = new BufferedReader(new InputStreamReader(process.getErrorStream()), 1); - return true; - } - - /** - * Threads to handle application input/output. - */ - - private static class OutputReader extends Thread { - - private String streamName; - private BufferedReader stream; - private OutputListener output; - private OutputListener diagnostics; - private boolean running = true; - private char[] buffer = new char[512]; - - OutputReader(String threadName, - String streamName, - BufferedReader stream, - OutputListener output, - OutputListener diagnostics) { - super(threadName); - this.streamName = streamName; - this.stream = stream; - this.output = output; - this.diagnostics = diagnostics; - } - - @Override - public void run() { - try { - int count; - while (running && (count = stream.read(buffer, 0, 512)) != -1) { - if (count > 0) { - // Run in Swing event dispatcher thread. - final String chars = new String(buffer, 0, count); - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - output.putString(chars); - } - }); - } - //### Should we sleep briefly here? - } - } catch (IOException e) { - // Run in Swing event dispatcher thread. - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - diagnostics.putString("IO error reading " + - streamName + - " stream of child java interpreter"); - } - }); - } - } - } - - private static class InputWriter extends Thread { - - private PrintWriter stream; - private InputListener input; - private boolean running = true; - - InputWriter(String threadName, - PrintWriter stream, - InputListener input) { - super(threadName); - this.stream = stream; - this.input = input; - } - - @Override - public void run() { - String line; - while (running) { - line = input.getLine(); - stream.println(line); - // Should not be needed for println above! - stream.flush(); - } - } - } - -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/EventRequestSpec.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/EventRequestSpec.java deleted file mode 100644 index 0ea58fb3ebd..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/EventRequestSpec.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import com.sun.jdi.*; -import com.sun.jdi.request.EventRequest; - -abstract public class EventRequestSpec { - - static final int STATUS_UNRESOLVED = 1; - static final int STATUS_RESOLVED = 2; - static final int STATUS_ERROR = 3; - - static final Object specPropertyKey = "spec"; - - final EventRequestSpecList specs; - final ReferenceTypeSpec refSpec; - EventRequest request = null; - - int status = STATUS_UNRESOLVED; - - EventRequestSpec(EventRequestSpecList specs, ReferenceTypeSpec refSpec) { - this.specs = specs; - this.refSpec = refSpec; - } - - void setRequest(EventRequest request) { - this.request = request; - request.putProperty(specPropertyKey, this); - request.enable(); - } - - /** - * The 'refType' is known to match. - */ - abstract void resolve(ReferenceType refType) throws Exception; - - abstract void notifySet(SpecListener listener, SpecEvent evt); - abstract void notifyDeferred(SpecListener listener, SpecEvent evt); - abstract void notifyResolved(SpecListener listener, SpecEvent evt); - abstract void notifyDeleted(SpecListener listener, SpecEvent evt); - abstract void notifyError(SpecListener listener, SpecErrorEvent evt); - - /** - * The 'refType' is known to match. - */ - void resolveNotify(ReferenceType refType) { - try { - resolve(refType); - status = STATUS_RESOLVED; - specs.notifyResolved(this); - } catch(Exception exc) { - status = STATUS_ERROR; - specs.notifyError(this, exc); - } - } - - /** - * See if 'refType' matches and resolve. - */ - void attemptResolve(ReferenceType refType) { - if (!isResolved() && refSpec.matches(refType)) { - resolveNotify(refType); - } - } - - void attemptImmediateResolve(VirtualMachine vm) { - // try to resolve immediately - for (ReferenceType refType : vm.allClasses()) { - if (refSpec.matches(refType)) { - try { - resolve(refType); - status = STATUS_RESOLVED; - specs.notifySet(this); - } catch(Exception exc) { - status = STATUS_ERROR; - specs.notifyError(this, exc); - } - return; - } - } - specs.notifyDeferred(this); - } - - public EventRequest getEventRequest() { - return request; - } - - /** - * @return true if this spec has been resolved. - */ - public boolean isResolved() { - return status == STATUS_RESOLVED; - } - - /** - * @return true if this spec has not yet been resolved. - */ - public boolean isUnresolved() { - return status == STATUS_UNRESOLVED; - } - - /** - * @return true if this spec is unresolvable due to error. - */ - public boolean isErroneous() { - return status == STATUS_ERROR; - } - - public String getStatusString() { - switch (status) { - case STATUS_RESOLVED: - return "resolved"; - case STATUS_UNRESOLVED: - return "deferred"; - case STATUS_ERROR: - return "erroneous"; - } - return "unknown"; - } - - boolean isJavaIdentifier(String s) { - return Utils.isJavaIdentifier(s); - } - - public String errorMessageFor(Exception e) { - if (e instanceof IllegalArgumentException) { - return ("Invalid command syntax"); - } else if (e instanceof RuntimeException) { - // A runtime exception that we were not expecting - throw (RuntimeException)e; - } else { - return ("Internal error; unable to set" + this); - } - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/EventRequestSpecList.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/EventRequestSpecList.java deleted file mode 100644 index 17c001483c7..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/EventRequestSpecList.java +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import com.sun.jdi.*; -import com.sun.jdi.request.*; - -import java.util.*; - -class EventRequestSpecList { - - // all specs - private List eventRequestSpecs = Collections.synchronizedList( - new ArrayList()); - - final ExecutionManager runtime; - - EventRequestSpecList(ExecutionManager runtime) { - this.runtime = runtime; - } - - /** - * Resolve all deferred eventRequests waiting for 'refType'. - */ - void resolve(ReferenceType refType) { - synchronized(eventRequestSpecs) { - for (EventRequestSpec spec : eventRequestSpecs) { - spec.attemptResolve(refType); - } - } - } - - void install(EventRequestSpec ers, VirtualMachine vm) { - synchronized (eventRequestSpecs) { - eventRequestSpecs.add(ers); - } - if (vm != null) { - ers.attemptImmediateResolve(vm); - } - } - - BreakpointSpec - createClassLineBreakpoint(String classPattern, int line) { - ReferenceTypeSpec refSpec = - new PatternReferenceTypeSpec(classPattern); - return new LineBreakpointSpec(this, refSpec, line); - } - - BreakpointSpec - createSourceLineBreakpoint(String sourceName, int line) { - ReferenceTypeSpec refSpec = - new SourceNameReferenceTypeSpec(sourceName, line); - return new LineBreakpointSpec(this, refSpec, line); - } - - BreakpointSpec - createMethodBreakpoint(String classPattern, - String methodId, List methodArgs) { - ReferenceTypeSpec refSpec = - new PatternReferenceTypeSpec(classPattern); - return new MethodBreakpointSpec(this, refSpec, - methodId, methodArgs); - } - - ExceptionSpec - createExceptionIntercept(String classPattern, - boolean notifyCaught, - boolean notifyUncaught) { - ReferenceTypeSpec refSpec = - new PatternReferenceTypeSpec(classPattern); - return new ExceptionSpec(this, refSpec, - notifyCaught, notifyUncaught); - } - - AccessWatchpointSpec - createAccessWatchpoint(String classPattern, String fieldId) { - ReferenceTypeSpec refSpec = - new PatternReferenceTypeSpec(classPattern); - return new AccessWatchpointSpec(this, refSpec, fieldId); - } - - ModificationWatchpointSpec - createModificationWatchpoint(String classPattern, String fieldId) { - ReferenceTypeSpec refSpec = - new PatternReferenceTypeSpec(classPattern); - return new ModificationWatchpointSpec(this, refSpec, fieldId); - } - - void delete(EventRequestSpec ers) { - EventRequest request = ers.getEventRequest(); - synchronized (eventRequestSpecs) { - eventRequestSpecs.remove(ers); - } - if (request != null) { - request.virtualMachine().eventRequestManager() - .deleteEventRequest(request); - } - notifyDeleted(ers); - //### notify delete - here? - } - - List eventRequestSpecs() { - // We need to make a copy to avoid synchronization problems - synchronized (eventRequestSpecs) { - return new ArrayList(eventRequestSpecs); - } - } - - // -------- notify routines -------------------- - - @SuppressWarnings("unchecked") - private Vector specListeners() { - return (Vector)runtime.specListeners.clone(); - } - - void notifySet(EventRequestSpec spec) { - Vector l = specListeners(); - SpecEvent evt = new SpecEvent(spec); - for (int i = 0; i < l.size(); i++) { - spec.notifySet(l.elementAt(i), evt); - } - } - - void notifyDeferred(EventRequestSpec spec) { - Vector l = specListeners(); - SpecEvent evt = new SpecEvent(spec); - for (int i = 0; i < l.size(); i++) { - spec.notifyDeferred(l.elementAt(i), evt); - } - } - - void notifyDeleted(EventRequestSpec spec) { - Vector l = specListeners(); - SpecEvent evt = new SpecEvent(spec); - for (int i = 0; i < l.size(); i++) { - spec.notifyDeleted(l.elementAt(i), evt); - } - } - - void notifyResolved(EventRequestSpec spec) { - Vector l = specListeners(); - SpecEvent evt = new SpecEvent(spec); - for (int i = 0; i < l.size(); i++) { - spec.notifyResolved(l.elementAt(i), evt); - } - } - - void notifyError(EventRequestSpec spec, Exception exc) { - Vector l = specListeners(); - SpecErrorEvent evt = new SpecErrorEvent(spec, exc); - for (int i = 0; i < l.size(); i++) { - spec.notifyError(l.elementAt(i), evt); - } - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ExceptionSpec.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ExceptionSpec.java deleted file mode 100644 index df87688152c..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ExceptionSpec.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import com.sun.jdi.ReferenceType; - -public class ExceptionSpec extends EventRequestSpec { - - boolean notifyCaught; - boolean notifyUncaught; - - ExceptionSpec(EventRequestSpecList specs, ReferenceTypeSpec refSpec, - boolean notifyCaught, boolean notifyUncaught) - { - super(specs, refSpec); - this.notifyCaught = notifyCaught; - this.notifyUncaught = notifyUncaught; - } - - @Override - void notifySet(SpecListener listener, SpecEvent evt) { - listener.exceptionInterceptSet(evt); - } - - @Override - void notifyDeferred(SpecListener listener, SpecEvent evt) { - listener.exceptionInterceptDeferred(evt); - } - - @Override - void notifyResolved(SpecListener listener, SpecEvent evt) { - listener.exceptionInterceptResolved(evt); - } - - @Override - void notifyDeleted(SpecListener listener, SpecEvent evt) { - listener.exceptionInterceptDeleted(evt); - } - - @Override - void notifyError(SpecListener listener, SpecErrorEvent evt) { - listener.exceptionInterceptError(evt); - } - - /** - * The 'refType' is known to match. - */ - @Override - void resolve(ReferenceType refType) { - setRequest(refType.virtualMachine().eventRequestManager() - .createExceptionRequest(refType, - notifyCaught, notifyUncaught)); - } - - @Override - public int hashCode() { - return refSpec.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof ExceptionSpec) { - ExceptionSpec es = (ExceptionSpec)obj; - - return refSpec.equals(es.refSpec); - } else { - return false; - } - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("exception catch "); - sb.append(refSpec.toString()); - return sb.toString(); - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ExecutionManager.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ExecutionManager.java deleted file mode 100644 index b5bc053a3c3..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ExecutionManager.java +++ /dev/null @@ -1,824 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import com.sun.jdi.*; -import com.sun.jdi.request.*; -import com.sun.jdi.connect.*; -import com.sun.tools.example.debug.expr.ExpressionParser; -import com.sun.tools.example.debug.expr.ParseException; - -import java.io.*; -import java.util.*; - -import com.sun.tools.example.debug.event.*; - -import javax.swing.SwingUtilities; - -/** - * Move this towards being only state and functionality - * that spans across Sessions (and thus VMs). - */ -public class ExecutionManager { - - private Session session; - - /** - * Get/set JDI trace mode. - */ - int traceMode = VirtualMachine.TRACE_NONE; - - ////////////////// Listener registration ////////////////// - - // Session Listeners - - ArrayList sessionListeners = new ArrayList(); - - public void addSessionListener(SessionListener listener) { - sessionListeners.add(listener); - } - - public void removeSessionListener(SessionListener listener) { - sessionListeners.remove(listener); - } - - // Spec Listeners - - ArrayList specListeners = new ArrayList(); - - public void addSpecListener(SpecListener cl) { - specListeners.add(cl); - } - - public void removeSpecListener(SpecListener cl) { - specListeners.remove(cl); - } - - // JDI Listeners - - ArrayList jdiListeners = new ArrayList(); - - /** - * Adds a JDIListener - */ - public void addJDIListener(JDIListener jl) { - jdiListeners.add(jl); - } - - /** - * Adds a JDIListener - at the specified position - */ - public void addJDIListener(int index, JDIListener jl) { - jdiListeners.add(index, jl); - } - - /** - * Removes a JDIListener - */ - public void removeJDIListener(JDIListener jl) { - jdiListeners.remove(jl); - } - - // App Echo Listeners - - private ArrayList appEchoListeners = new ArrayList(); - - public void addApplicationEchoListener(OutputListener l) { - appEchoListeners.add(l); - } - - public void removeApplicationEchoListener(OutputListener l) { - appEchoListeners.remove(l); - } - - // App Output Listeners - - private ArrayList appOutputListeners = new ArrayList(); - - public void addApplicationOutputListener(OutputListener l) { - appOutputListeners.add(l); - } - - public void removeApplicationOutputListener(OutputListener l) { - appOutputListeners.remove(l); - } - - // App Error Listeners - - private ArrayList appErrorListeners = new ArrayList(); - - public void addApplicationErrorListener(OutputListener l) { - appErrorListeners.add(l); - } - - public void removeApplicationErrorListener(OutputListener l) { - appErrorListeners.remove(l); - } - - // Diagnostic Listeners - - private ArrayList diagnosticsListeners = new ArrayList(); - - public void addDiagnosticsListener(OutputListener l) { - diagnosticsListeners.add(l); - } - - public void removeDiagnosticsListener(OutputListener l) { - diagnosticsListeners.remove(l); - } - - /////////// End Listener Registration ////////////// - - //### We probably don't want this public - public VirtualMachine vm() { - return session == null ? null : session.vm; - } - - void ensureActiveSession() throws NoSessionException { - if (session == null) { - throw new NoSessionException(); - } - } - - public EventRequestManager eventRequestManager() { - return vm() == null ? null : vm().eventRequestManager(); - } - - /** - * Get JDI trace mode. - */ - public int getTraceMode(int mode) { - return traceMode; - } - - /** - * Set JDI trace mode. - */ - public void setTraceMode(int mode) { - traceMode = mode; - if (session != null) { - session.setTraceMode(mode); - } - } - - /** - * Determine if VM is interrupted, i.e, present and not running. - */ - public boolean isInterrupted() /* should: throws NoSessionException */ { -// ensureActiveSession(); - return session.interrupted; - } - - /** - * Return a list of ReferenceType objects for all - * currently loaded classes and interfaces. - * Array types are not returned. - */ - public List allClasses() throws NoSessionException { - ensureActiveSession(); - return vm().allClasses(); - } - - /** - * Return a ReferenceType object for the currently - * loaded class or interface whose fully-qualified - * class name is specified, else return null if there - * is none. - * - * In general, we must return a list of types, because - * multiple class loaders could have loaded a class - * with the same fully-qualified name. - */ - public List findClassesByName(String name) throws NoSessionException { - ensureActiveSession(); - return vm().classesByName(name); - } - - /** - * Return a list of ReferenceType objects for all - * currently loaded classes and interfaces whose name - * matches the given pattern. The pattern syntax is - * open to some future revision, but currently consists - * of a fully-qualified class name in which the first - * component may optionally be a "*" character, designating - * an arbitrary prefix. - */ - public List findClassesMatchingPattern(String pattern) - throws NoSessionException { - ensureActiveSession(); - List result = new ArrayList(); //### Is default size OK? - if (pattern.startsWith("*.")) { - // Wildcard matches any leading package name. - pattern = pattern.substring(1); - for (ReferenceType type : vm().allClasses()) { - if (type.name().endsWith(pattern)) { - result.add(type); - } - } - return result; - } else { - // It's a class name. - return vm().classesByName(pattern); - } - } - - /* - * Return a list of ThreadReference objects corresponding - * to the threads that are currently active in the VM. - * A thread is removed from the list just before the - * thread terminates. - */ - - public List allThreads() throws NoSessionException { - ensureActiveSession(); - return vm().allThreads(); - } - - /* - * Return a list of ThreadGroupReference objects corresponding - * to the top-level threadgroups that are currently active in the VM. - * Note that a thread group may be empty, or contain no threads as - * descendents. - */ - - public List topLevelThreadGroups() throws NoSessionException { - ensureActiveSession(); - return vm().topLevelThreadGroups(); - } - - /* - * Return the system threadgroup. - */ - - public ThreadGroupReference systemThreadGroup() - throws NoSessionException { - ensureActiveSession(); - return vm().topLevelThreadGroups().get(0); - } - - /* - * Evaluate an expression. - */ - - public Value evaluate(final StackFrame f, String expr) - throws ParseException, - InvocationException, - InvalidTypeException, - ClassNotLoadedException, - NoSessionException, - IncompatibleThreadStateException { - ExpressionParser.GetFrame frameGetter = null; - ensureActiveSession(); - if (f != null) { - frameGetter = new ExpressionParser.GetFrame() { - @Override - public StackFrame get() /* throws IncompatibleThreadStateException */ { - return f; - } - }; - } - return ExpressionParser.evaluate(expr, vm(), frameGetter); - } - - - /* - * Start a new VM. - */ - - public void run(boolean suspended, - String vmArgs, - String className, - String args) throws VMLaunchFailureException { - - endSession(); - - //### Set a breakpoint on 'main' method. - //### Would be cleaner if we could just bring up VM already suspended. - if (suspended) { - //### Set breakpoint at 'main(java.lang.String[])'. - List argList = new ArrayList(1); - argList.add("java.lang.String[]"); - createMethodBreakpoint(className, "main", argList); - } - - String cmdLine = className + " " + args; - - startSession(new ChildSession(this, vmArgs, cmdLine, - appInput, appOutput, appError, - diagnostics)); - } - - /* - * Attach to an existing VM. - */ - public void attach(String portName) throws VMLaunchFailureException { - endSession(); - - //### Changes made here for connectors have broken the - //### the 'Session' abstraction. The 'Session.attach()' - //### method is intended to encapsulate all of the various - //### ways in which session start-up can fail. (maddox 12/18/98) - - /* - * Now that attaches and launches both go through Connectors, - * it may be worth creating a new subclass of Session for - * attach sessions. - */ - VirtualMachineManager mgr = Bootstrap.virtualMachineManager(); - AttachingConnector connector = mgr.attachingConnectors().get(0); - Map arguments = connector.defaultArguments(); - arguments.get("port").setValue(portName); - - Session newSession = internalAttach(connector, arguments); - if (newSession != null) { - startSession(newSession); - } - } - - private Session internalAttach(AttachingConnector connector, - Map arguments) { - try { - VirtualMachine vm = connector.attach(arguments); - return new Session(vm, this, diagnostics); - } catch (IOException ioe) { - diagnostics.putString("\n Unable to attach to target VM: " + - ioe.getMessage()); - } catch (IllegalConnectorArgumentsException icae) { - diagnostics.putString("\n Invalid connector arguments: " + - icae.getMessage()); - } - return null; - } - - private Session internalListen(ListeningConnector connector, - Map arguments) { - try { - VirtualMachine vm = connector.accept(arguments); - return new Session(vm, this, diagnostics); - } catch (IOException ioe) { - diagnostics.putString( - "\n Unable to accept connection to target VM: " + - ioe.getMessage()); - } catch (IllegalConnectorArgumentsException icae) { - diagnostics.putString("\n Invalid connector arguments: " + - icae.getMessage()); - } - return null; - } - - /* - * Connect via user specified arguments - * @return true on success - */ - public boolean explictStart(Connector connector, Map arguments) - throws VMLaunchFailureException { - Session newSession = null; - - endSession(); - - if (connector instanceof LaunchingConnector) { - // we were launched, use ChildSession - newSession = new ChildSession(this, (LaunchingConnector)connector, - arguments, - appInput, appOutput, appError, - diagnostics); - } else if (connector instanceof AttachingConnector) { - newSession = internalAttach((AttachingConnector)connector, - arguments); - } else if (connector instanceof ListeningConnector) { - newSession = internalListen((ListeningConnector)connector, - arguments); - } else { - diagnostics.putString("\n Unknown connector: " + connector); - } - if (newSession != null) { - startSession(newSession); - } - return newSession != null; - } - - /* - * Detach from VM. If VM was started by debugger, terminate it. - */ - public void detach() throws NoSessionException { - ensureActiveSession(); - endSession(); - } - - private void startSession(Session s) throws VMLaunchFailureException { - if (!s.attach()) { - throw new VMLaunchFailureException(); - } - session = s; - EventRequestManager em = vm().eventRequestManager(); - ClassPrepareRequest classPrepareRequest = em.createClassPrepareRequest(); - //### We must allow the deferred breakpoints to be resolved before - //### we continue executing the class. We could optimize if there - //### were no deferred breakpoints outstanding for a particular class. - //### Can we do this with JDI? - classPrepareRequest.setSuspendPolicy(EventRequest.SUSPEND_ALL); - classPrepareRequest.enable(); - ClassUnloadRequest classUnloadRequest = em.createClassUnloadRequest(); - classUnloadRequest.setSuspendPolicy(EventRequest.SUSPEND_NONE); - classUnloadRequest.enable(); - ThreadStartRequest threadStartRequest = em.createThreadStartRequest(); - threadStartRequest.setSuspendPolicy(EventRequest.SUSPEND_NONE); - threadStartRequest.enable(); - ThreadDeathRequest threadDeathRequest = em.createThreadDeathRequest(); - threadDeathRequest.setSuspendPolicy(EventRequest.SUSPEND_NONE); - threadDeathRequest.enable(); - ExceptionRequest exceptionRequest = - em.createExceptionRequest(null, false, true); - exceptionRequest.setSuspendPolicy(EventRequest.SUSPEND_ALL); - exceptionRequest.enable(); - validateThreadInfo(); - session.interrupted = true; - notifySessionStart(); - } - - void endSession() { - if (session != null) { - session.detach(); - session = null; - invalidateThreadInfo(); - notifySessionDeath(); - } - } - - /* - * Suspend all VM activity. - */ - - public void interrupt() throws NoSessionException { - ensureActiveSession(); - vm().suspend(); - //### Is it guaranteed that the interrupt has happened? - validateThreadInfo(); - session.interrupted = true; - notifyInterrupted(); - } - - /* - * Resume interrupted VM. - */ - - public void go() throws NoSessionException, VMNotInterruptedException { - ensureActiveSession(); - invalidateThreadInfo(); - session.interrupted = false; - notifyContinued(); - vm().resume(); - } - - /* - * Stepping. - */ - void clearPreviousStep(ThreadReference thread) { - /* - * A previous step may not have completed on this thread; - * if so, it gets removed here. - */ - EventRequestManager mgr = vm().eventRequestManager(); - for (StepRequest request : mgr.stepRequests()) { - if (request.thread().equals(thread)) { - mgr.deleteEventRequest(request); - break; - } - } - } - - private void generalStep(ThreadReference thread, int size, int depth) - throws NoSessionException { - ensureActiveSession(); - invalidateThreadInfo(); - session.interrupted = false; - notifyContinued(); - - clearPreviousStep(thread); - EventRequestManager reqMgr = vm().eventRequestManager(); - StepRequest request = reqMgr.createStepRequest(thread, - size, depth); - // We want just the next step event and no others - request.addCountFilter(1); - request.enable(); - vm().resume(); - } - - public void stepIntoInstruction(ThreadReference thread) - throws NoSessionException { - generalStep(thread, StepRequest.STEP_MIN, StepRequest.STEP_INTO); - } - - public void stepOverInstruction(ThreadReference thread) - throws NoSessionException { - generalStep(thread, StepRequest.STEP_MIN, StepRequest.STEP_OVER); - } - - public void stepIntoLine(ThreadReference thread) - throws NoSessionException, - AbsentInformationException { - generalStep(thread, StepRequest.STEP_LINE, StepRequest.STEP_INTO); - } - - public void stepOverLine(ThreadReference thread) - throws NoSessionException, - AbsentInformationException { - generalStep(thread, StepRequest.STEP_LINE, StepRequest.STEP_OVER); - } - - public void stepOut(ThreadReference thread) - throws NoSessionException { - generalStep(thread, StepRequest.STEP_MIN, StepRequest.STEP_OUT); - } - - /* - * Thread control. - */ - - public void suspendThread(ThreadReference thread) throws NoSessionException { - ensureActiveSession(); - thread.suspend(); - } - - public void resumeThread(ThreadReference thread) throws NoSessionException { - ensureActiveSession(); - thread.resume(); - } - - public void stopThread(ThreadReference thread) throws NoSessionException { - ensureActiveSession(); - //### Need an exception now. Which one to use? - //thread.stop(); - } - - /* - * ThreadInfo objects -- Allow query of thread status and stack. - */ - - private List threadInfoList = new LinkedList(); - //### Should be weak! (in the value, not the key) - private HashMap threadInfoMap = new HashMap(); - - public ThreadInfo threadInfo(ThreadReference thread) { - if (session == null || thread == null) { - return null; - } - ThreadInfo info = threadInfoMap.get(thread); - if (info == null) { - //### Should not hardcode initial frame count and prefetch here! - //info = new ThreadInfo(thread, 10, 10); - info = new ThreadInfo(thread); - if (session.interrupted) { - info.validate(); - } - threadInfoList.add(info); - threadInfoMap.put(thread, info); - } - return info; - } - - void validateThreadInfo() { - session.interrupted = true; - for (ThreadInfo threadInfo : threadInfoList) { - threadInfo.validate(); - } - } - - private void invalidateThreadInfo() { - if (session != null) { - session.interrupted = false; - for (ThreadInfo threadInfo : threadInfoList) { - threadInfo.invalidate(); - } - } - } - - void removeThreadInfo(ThreadReference thread) { - ThreadInfo info = threadInfoMap.get(thread); - if (info != null) { - info.invalidate(); - threadInfoMap.remove(thread); - threadInfoList.remove(info); - } - } - - /* - * Listen for Session control events. - */ - - private void notifyInterrupted() { - ArrayList l = new ArrayList(sessionListeners); - EventObject evt = new EventObject(this); - for (int i = 0; i < l.size(); i++) { - l.get(i).sessionInterrupt(evt); - } - } - - private void notifyContinued() { - ArrayList l = new ArrayList(sessionListeners); - EventObject evt = new EventObject(this); - for (int i = 0; i < l.size(); i++) { - l.get(i).sessionContinue(evt); - } - } - - private void notifySessionStart() { - ArrayList l = new ArrayList(sessionListeners); - EventObject evt = new EventObject(this); - for (int i = 0; i < l.size(); i++) { - l.get(i).sessionStart(evt); - } - } - - private void notifySessionDeath() { -/*** noop for now - ArrayList l = new ArrayList(sessionListeners); - EventObject evt = new EventObject(this); - for (int i = 0; i < l.size(); i++) { - ((SessionListener)l.get(i)).sessionDeath(evt); - } -****/ - } - - /* - * Listen for input and output requests from the application - * being debugged. These are generated only when the debuggee - * is spawned as a child of the debugger. - */ - - private Object inputLock = new Object(); - private LinkedList inputBuffer = new LinkedList(); - - private void resetInputBuffer() { - synchronized (inputLock) { - inputBuffer = new LinkedList(); - } - } - - public void sendLineToApplication(String line) { - synchronized (inputLock) { - inputBuffer.addFirst(line); - inputLock.notifyAll(); - } - } - - private InputListener appInput = new InputListener() { - @Override - public String getLine() { - // Don't allow reader to be interrupted -- catch and retry. - String line = null; - while (line == null) { - synchronized (inputLock) { - try { - while (inputBuffer.size() < 1) { - inputLock.wait(); - } - line = inputBuffer.removeLast(); - } catch (InterruptedException e) {} - } - } - // We must not be holding inputLock here, as the listener - // that we call to echo a line might call us re-entrantly - // to provide another line of input. - // Run in Swing event dispatcher thread. - final String input = line; - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - echoInputLine(input); - } - }); - return line; - } - }; - - private static String newline = System.getProperty("line.separator"); - - private void echoInputLine(String line) { - ArrayList l = new ArrayList(appEchoListeners); - for (int i = 0; i < l.size(); i++) { - OutputListener ol = l.get(i); - ol.putString(line); - ol.putString(newline); - } - } - - private OutputListener appOutput = new OutputListener() { - @Override - public void putString(String string) { - ArrayList l = new ArrayList(appEchoListeners); - for (int i = 0; i < l.size(); i++) { - l.get(i).putString(string); - } - } - }; - - private OutputListener appError = new OutputListener() { - @Override - public void putString(String string) { - ArrayList l = new ArrayList(appEchoListeners); - for (int i = 0; i < l.size(); i++) { - l.get(i).putString(string); - } - } - }; - - private OutputListener diagnostics = new OutputListener() { - @Override - public void putString(String string) { - ArrayList l = new ArrayList(diagnosticsListeners); - for (int i = 0; i < l.size(); i++) { - l.get(i).putString(string); - } - } - }; - - ///////////// Spec Request Creation/Deletion/Query /////////// - - private EventRequestSpecList specList = new EventRequestSpecList(this); - - public BreakpointSpec - createSourceLineBreakpoint(String sourceName, int line) { - return specList.createSourceLineBreakpoint(sourceName, line); - } - - public BreakpointSpec - createClassLineBreakpoint(String classPattern, int line) { - return specList.createClassLineBreakpoint(classPattern, line); - } - - public BreakpointSpec - createMethodBreakpoint(String classPattern, - String methodId, List methodArgs) { - return specList.createMethodBreakpoint(classPattern, - methodId, methodArgs); - } - - public ExceptionSpec - createExceptionIntercept(String classPattern, - boolean notifyCaught, - boolean notifyUncaught) { - return specList.createExceptionIntercept(classPattern, - notifyCaught, - notifyUncaught); - } - - public AccessWatchpointSpec - createAccessWatchpoint(String classPattern, String fieldId) { - return specList.createAccessWatchpoint(classPattern, fieldId); - } - - public ModificationWatchpointSpec - createModificationWatchpoint(String classPattern, String fieldId) { - return specList.createModificationWatchpoint(classPattern, - fieldId); - } - - public void delete(EventRequestSpec spec) { - specList.delete(spec); - } - - void resolve(ReferenceType refType) { - specList.resolve(refType); - } - - public void install(EventRequestSpec spec) { - specList.install(spec, vm()); - } - - public List eventRequestSpecs() { - return specList.eventRequestSpecs(); - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/FrameIndexOutOfBoundsException.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/FrameIndexOutOfBoundsException.java deleted file mode 100644 index 57d4e2a6d9c..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/FrameIndexOutOfBoundsException.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -public class FrameIndexOutOfBoundsException extends IndexOutOfBoundsException { - - private static final long serialVersionUID = -4870148107027371437L; -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/JDIEventSource.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/JDIEventSource.java deleted file mode 100644 index 2d92094d0d5..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/JDIEventSource.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import com.sun.jdi.*; -import com.sun.jdi.event.*; - -import com.sun.tools.example.debug.event.*; - -import javax.swing.SwingUtilities; - -/** - */ -class JDIEventSource extends Thread { - - private /*final*/ EventQueue queue; - private /*final*/ Session session; - private /*final*/ ExecutionManager runtime; - private final JDIListener firstListener = new FirstListener(); - - private boolean wantInterrupt; //### Hack - - /** - * Create event source. - */ - JDIEventSource(Session session) { - super("JDI Event Set Dispatcher"); - this.session = session; - this.runtime = session.runtime; - this.queue = session.vm.eventQueue(); - } - - @Override - public void run() { - try { - runLoop(); - } catch (Exception exc) { - //### Do something different for InterruptedException??? - // just exit - } - session.running = false; - } - - private void runLoop() throws InterruptedException { - AbstractEventSet es; - do { - EventSet jdiEventSet = queue.remove(); - es = AbstractEventSet.toSpecificEventSet(jdiEventSet); - session.interrupted = es.suspendedAll(); - dispatchEventSet(es); - } while(!(es instanceof VMDisconnectEventSet)); - } - - //### Gross foul hackery! - private void dispatchEventSet(final AbstractEventSet es) { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - boolean interrupted = es.suspendedAll(); - es.notify(firstListener); - boolean wantInterrupt = JDIEventSource.this.wantInterrupt; - for (JDIListener jl : session.runtime.jdiListeners) { - es.notify(jl); - } - if (interrupted && !wantInterrupt) { - session.interrupted = false; - //### Catch here is a hack - try { - session.vm.resume(); - } catch (VMDisconnectedException ee) {} - } - if (es instanceof ThreadDeathEventSet) { - ThreadReference t = ((ThreadDeathEventSet)es).getThread(); - session.runtime.removeThreadInfo(t); - } - } - }); - } - - private void finalizeEventSet(AbstractEventSet es) { - if (session.interrupted && !wantInterrupt) { - session.interrupted = false; - //### Catch here is a hack - try { - session.vm.resume(); - } catch (VMDisconnectedException ee) {} - } - if (es instanceof ThreadDeathEventSet) { - ThreadReference t = ((ThreadDeathEventSet)es).getThread(); - session.runtime.removeThreadInfo(t); - } - } - - //### This is a Hack, deal with it - private class FirstListener implements JDIListener { - - @Override - public void accessWatchpoint(AccessWatchpointEventSet e) { - session.runtime.validateThreadInfo(); - wantInterrupt = true; - } - - @Override - public void classPrepare(ClassPrepareEventSet e) { - wantInterrupt = false; - runtime.resolve(e.getReferenceType()); - } - - @Override - public void classUnload(ClassUnloadEventSet e) { - wantInterrupt = false; - } - - @Override - public void exception(ExceptionEventSet e) { - wantInterrupt = true; - } - - @Override - public void locationTrigger(LocationTriggerEventSet e) { - session.runtime.validateThreadInfo(); - wantInterrupt = true; - } - - @Override - public void modificationWatchpoint(ModificationWatchpointEventSet e) { - session.runtime.validateThreadInfo(); - wantInterrupt = true; - } - - @Override - public void threadDeath(ThreadDeathEventSet e) { - wantInterrupt = false; - } - - @Override - public void threadStart(ThreadStartEventSet e) { - wantInterrupt = false; - } - - @Override - public void vmDeath(VMDeathEventSet e) { - //### Should have some way to notify user - //### that VM died before the session ended. - wantInterrupt = false; - } - - @Override - public void vmDisconnect(VMDisconnectEventSet e) { - //### Notify user? - wantInterrupt = false; - session.runtime.endSession(); - } - - @Override - public void vmStart(VMStartEventSet e) { - //### Do we need to do anything with it? - wantInterrupt = false; - } - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/LineBreakpointSpec.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/LineBreakpointSpec.java deleted file mode 100644 index f7d66ce2d52..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/LineBreakpointSpec.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import com.sun.jdi.*; -import java.util.List; - -public class LineBreakpointSpec extends BreakpointSpec { - int lineNumber; - - LineBreakpointSpec(EventRequestSpecList specs, - ReferenceTypeSpec refSpec, int lineNumber) { - super(specs, refSpec); - this.lineNumber = lineNumber; - } - - /** - * The 'refType' is known to match. - */ - @Override - void resolve(ReferenceType refType) throws InvalidTypeException, - LineNotFoundException { - if (!(refType instanceof ClassType)) { - throw new InvalidTypeException(); - } - Location location = location((ClassType)refType); - setRequest(refType.virtualMachine().eventRequestManager() - .createBreakpointRequest(location)); - } - - private Location location(ClassType clazz) throws - LineNotFoundException { - Location location = null; - try { - List locs = clazz.locationsOfLine(lineNumber()); - if (locs.size() == 0) { - throw new LineNotFoundException(); - } - // TODO handle multiple locations - location = locs.get(0); - if (location.method() == null) { - throw new LineNotFoundException(); - } - } catch (AbsentInformationException e) { - /* - * TO DO: throw something more specific, or allow - * AbsentInfo exception to pass through. - */ - throw new LineNotFoundException(); - } - return location; - } - - public int lineNumber() { - return lineNumber; - } - - @Override - public int hashCode() { - return refSpec.hashCode() + lineNumber; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof LineBreakpointSpec) { - LineBreakpointSpec breakpoint = (LineBreakpointSpec)obj; - - return refSpec.equals(breakpoint.refSpec) && - (lineNumber == breakpoint.lineNumber); - } else { - return false; - } - } - - @Override - public String errorMessageFor(Exception e) { - if (e instanceof LineNotFoundException) { - return ("No code at line " + lineNumber() + " in " + refSpec); - } else if (e instanceof InvalidTypeException) { - return ("Breakpoints can be located only in classes. " + - refSpec + " is an interface or array"); - } else { - return super.errorMessageFor( e); - } - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("breakpoint "); - sb.append(refSpec.toString()); - sb.append(':'); - sb.append(lineNumber); - sb.append(" ("); - sb.append(getStatusString()); - sb.append(')'); - return sb.toString(); - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/MalformedMemberNameException.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/MalformedMemberNameException.java deleted file mode 100644 index 1980893a361..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/MalformedMemberNameException.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -class MalformedMemberNameException extends Exception { - - private static final long serialVersionUID = -7726664097374844485L; - - public MalformedMemberNameException() { - super(); - } - - public MalformedMemberNameException(String s) { - super(s); - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/MethodBreakpointSpec.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/MethodBreakpointSpec.java deleted file mode 100644 index b414443faf7..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/MethodBreakpointSpec.java +++ /dev/null @@ -1,346 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import com.sun.jdi.*; -import java.util.ArrayList; -import java.util.List; - -public class MethodBreakpointSpec extends BreakpointSpec { - String methodId; - List methodArgs; - - MethodBreakpointSpec(EventRequestSpecList specs, - ReferenceTypeSpec refSpec, - String methodId, List methodArgs) { - super(specs, refSpec); - this.methodId = methodId; - this.methodArgs = methodArgs; - } - - /** - * The 'refType' is known to match. - */ - @Override - void resolve(ReferenceType refType) throws MalformedMemberNameException, - AmbiguousMethodException, - InvalidTypeException, - NoSuchMethodException, - NoSessionException { - if (!isValidMethodName(methodId)) { - throw new MalformedMemberNameException(methodId); - } - if (!(refType instanceof ClassType)) { - throw new InvalidTypeException(); - } - Location location = location((ClassType)refType); - setRequest(refType.virtualMachine().eventRequestManager() - .createBreakpointRequest(location)); - } - - private Location location(ClassType clazz) throws - AmbiguousMethodException, - NoSuchMethodException, - NoSessionException { - Method method = findMatchingMethod(clazz); - Location location = method.location(); - return location; - } - - public String methodName() { - return methodId; - } - - public List methodArgs() { - return methodArgs; - } - - @Override - public int hashCode() { - return refSpec.hashCode() + - ((methodId != null) ? methodId.hashCode() : 0) + - ((methodArgs != null) ? methodArgs.hashCode() : 0); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof MethodBreakpointSpec) { - MethodBreakpointSpec breakpoint = (MethodBreakpointSpec)obj; - - return methodId.equals(breakpoint.methodId) && - methodArgs.equals(breakpoint.methodArgs) && - refSpec.equals(breakpoint.refSpec); - } else { - return false; - } - } - - @Override - public String errorMessageFor(Exception e) { - if (e instanceof AmbiguousMethodException) { - return ("Method " + methodName() + " is overloaded; specify arguments"); - /* - * TO DO: list the methods here - */ - } else if (e instanceof NoSuchMethodException) { - return ("No method " + methodName() + " in " + refSpec); - } else if (e instanceof InvalidTypeException) { - return ("Breakpoints can be located only in classes. " + - refSpec + " is an interface or array"); - } else { - return super.errorMessageFor( e); - } - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("breakpoint "); - sb.append(refSpec.toString()); - sb.append('.'); - sb.append(methodId); - if (methodArgs != null) { - boolean first = true; - sb.append('('); - for (String name : methodArgs) { - if (!first) { - sb.append(','); - } - sb.append(name); - first = false; - } - sb.append(")"); - } - sb.append(" ("); - sb.append(getStatusString()); - sb.append(')'); - return sb.toString(); - } - - private boolean isValidMethodName(String s) { - return isJavaIdentifier(s) || - s.equals("") || - s.equals(""); - } - - /* - * Compare a method's argument types with a Vector of type names. - * Return true if each argument type has a name identical to the - * corresponding string in the vector (allowing for varargs) - * and if the number of arguments in the method matches the - * number of names passed - */ - private boolean compareArgTypes(Method method, List nameList) { - List argTypeNames = method.argumentTypeNames(); - - // If argument counts differ, we can stop here - if (argTypeNames.size() != nameList.size()) { - return false; - } - - // Compare each argument type's name - int nTypes = argTypeNames.size(); - for (int i = 0; i < nTypes; ++i) { - String comp1 = argTypeNames.get(i); - String comp2 = nameList.get(i); - if (! comp1.equals(comp2)) { - /* - * We have to handle varargs. EG, the - * method's last arg type is xxx[] - * while the nameList contains xxx... - * Note that the nameList can also contain - * xxx[] in which case we don't get here. - */ - if (i != nTypes - 1 || - !method.isVarArgs() || - !comp2.endsWith("...")) { - return false; - } - /* - * The last types differ, it is a varargs - * method and the nameList item is varargs. - * We just have to compare the type names, eg, - * make sure we don't have xxx[] for the method - * arg type and yyy... for the nameList item. - */ - int comp1Length = comp1.length(); - if (comp1Length + 1 != comp2.length()) { - // The type names are different lengths - return false; - } - // We know the two type names are the same length - if (!comp1.regionMatches(0, comp2, 0, comp1Length - 2)) { - return false; - } - // We do have xxx[] and xxx... as the last param type - return true; - } - } - - return true; - } - - private VirtualMachine vm() { - return request.virtualMachine(); - } - - /** - * Remove unneeded spaces and expand class names to fully - * qualified names, if necessary and possible. - */ - private String normalizeArgTypeName(String name) throws NoSessionException { - /* - * Separate the type name from any array modifiers, - * stripping whitespace after the name ends. - */ - int i = 0; - StringBuilder typePart = new StringBuilder(); - StringBuilder arrayPart = new StringBuilder(); - name = name.trim(); - int nameLength = name.length(); - /* - * For varargs, there can be spaces before the ... but not - * within the ... So, we will just ignore the ... - * while stripping blanks. - */ - boolean isVarArgs = name.endsWith("..."); - if (isVarArgs) { - nameLength -= 3; - } - - while (i < nameLength) { - char c = name.charAt(i); - if (Character.isWhitespace(c) || c == '[') { - break; // name is complete - } - typePart.append(c); - i++; - } - while (i < nameLength) { - char c = name.charAt(i); - if ( (c == '[') || (c == ']')) { - arrayPart.append(c); - } else if (!Character.isWhitespace(c)) { - throw new IllegalArgumentException( - "Invalid argument type name"); - - } - i++; - } - - name = typePart.toString(); - - /* - * When there's no sign of a package name already, - * try to expand the - * the name to a fully qualified class name - */ - if ((name.indexOf('.') == -1) || name.startsWith("*.")) { - try { - List refs = specs.runtime.findClassesMatchingPattern(name); - if (refs.size() > 0) { //### ambiguity??? - name = ((ReferenceType)(refs.get(0))).name(); - } - } catch (IllegalArgumentException e) { - // We'll try the name as is - } - } - name += arrayPart.toString(); - if (isVarArgs) { - name += "..."; - } - return name; - } - - /* - * Attempt an unambiguous match of the method name and - * argument specification to a method. If no arguments - * are specified, the method must not be overloaded. - * Otherwise, the argument types much match exactly - */ - private Method findMatchingMethod(ClassType clazz) - throws AmbiguousMethodException, - NoSuchMethodException, - NoSessionException { - - // Normalize the argument string once before looping below. - List argTypeNames = null; - if (methodArgs() != null) { - argTypeNames = new ArrayList(methodArgs().size()); - for (String name : methodArgs()) { - name = normalizeArgTypeName(name); - argTypeNames.add(name); - } - } - - // Check each method in the class for matches - Method firstMatch = null; // first method with matching name - Method exactMatch = null; // (only) method with same name & sig - int matchCount = 0; // > 1 implies overload - for (Method candidate : clazz.methods()) { - if (candidate.name().equals(methodName())) { - matchCount++; - - // Remember the first match in case it is the only one - if (matchCount == 1) { - firstMatch = candidate; - } - - // If argument types were specified, check against candidate - if ((argTypeNames != null) - && compareArgTypes(candidate, argTypeNames) == true) { - exactMatch = candidate; - break; - } - } - } - - // Determine method for breakpoint - Method method = null; - if (exactMatch != null) { - // Name and signature match - method = exactMatch; - } else if ((argTypeNames == null) && (matchCount > 0)) { - // At least one name matched and no arg types were specified - if (matchCount == 1) { - method = firstMatch; // Only one match; safe to use it - } else { - throw new AmbiguousMethodException(); - } - } else { - throw new NoSuchMethodException(methodName()); - } - return method; - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/MethodNotFoundException.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/MethodNotFoundException.java deleted file mode 100644 index 820c35cc61b..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/MethodNotFoundException.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -public class MethodNotFoundException extends Exception -{ - private static final long serialVersionUID = -2064968107599632609L; - - public MethodNotFoundException() - { - super(); - } - - public MethodNotFoundException(String s) - { - super(s); - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ModificationWatchpointSpec.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ModificationWatchpointSpec.java deleted file mode 100644 index b8f2b86e65a..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ModificationWatchpointSpec.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import com.sun.jdi.*; - -public class ModificationWatchpointSpec extends WatchpointSpec { - - ModificationWatchpointSpec(EventRequestSpecList specs, - ReferenceTypeSpec refSpec, String fieldId) { - super(specs, refSpec, fieldId); - } - - /** - * The 'refType' is known to match. - */ - @Override - void resolve(ReferenceType refType) throws InvalidTypeException, - NoSuchFieldException { - if (!(refType instanceof ClassType)) { - throw new InvalidTypeException(); - } - Field field = refType.fieldByName(fieldId); - if (field == null) { - throw new NoSuchFieldException(fieldId); - } - setRequest(refType.virtualMachine().eventRequestManager() - .createModificationWatchpointRequest(field)); - } - - @Override - public boolean equals(Object obj) { - return (obj instanceof ModificationWatchpointSpec) && - super.equals(obj); - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/NoSessionException.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/NoSessionException.java deleted file mode 100644 index 3e92e2eb167..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/NoSessionException.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -public class NoSessionException extends Exception { - - private static final long serialVersionUID = -7324357828115128603L; -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/OutputListener.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/OutputListener.java deleted file mode 100644 index 8bb6701595e..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/OutputListener.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -public interface OutputListener { - void putString(String str); - //void putLine(String line); -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ParseException.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ParseException.java deleted file mode 100644 index 3d407985635..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ParseException.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -// dummy placeholder for javaCC-generated code. - -public class ParseException extends Exception {} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/PatternReferenceTypeSpec.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/PatternReferenceTypeSpec.java deleted file mode 100644 index fa034aea3b4..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/PatternReferenceTypeSpec.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import com.sun.jdi.*; -import java.util.StringTokenizer; - -class PatternReferenceTypeSpec implements ReferenceTypeSpec { - final boolean isWild; - final String classId; - - PatternReferenceTypeSpec(String classId) -// throws ClassNotFoundException - { -// checkClassName(classId); - isWild = classId.startsWith("*."); - if (isWild) { - this.classId = classId.substring(1); - } else { - this.classId = classId; - } - } - - /** - * Does the specified ReferenceType match this spec. - */ - @Override - public boolean matches(ReferenceType refType) { - if (isWild) { - return refType.name().endsWith(classId); - } else { - return refType.name().equals(classId); - } - } - - @Override - public int hashCode() { - return classId.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof PatternReferenceTypeSpec) { - PatternReferenceTypeSpec spec = (PatternReferenceTypeSpec)obj; - - return classId.equals(spec.classId) && (isWild == spec.isWild); - } else { - return false; - } - } - - private void checkClassName(String className) throws ClassNotFoundException { - // Do stricter checking of class name validity on deferred - // because if the name is invalid, it will - // never match a future loaded class, and we'll be silent - // about it. - StringTokenizer tokenizer = new StringTokenizer(className, "."); - boolean first = true; - while (tokenizer.hasMoreTokens()) { - String token = tokenizer.nextToken(); - // Each dot-separated piece must be a valid identifier - // and the first token can also be "*". (Note that - // numeric class ids are not permitted. They must - // match a loaded class.) - if (!Utils.isJavaIdentifier(token) && !(first && token.equals("*"))) { - throw new ClassNotFoundException(); - } - first = false; - } - } - - @Override - public String toString() { - return isWild? "*" + classId : classId; - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/Session.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/Session.java deleted file mode 100644 index 883834a07a1..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/Session.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import com.sun.jdi.VirtualMachine; -import com.sun.jdi.VMDisconnectedException; - -/** - * Our repository of what we know about the state of one - * running VM. - */ -class Session { - - final VirtualMachine vm; - final ExecutionManager runtime; - final OutputListener diagnostics; - - boolean running = true; // Set false by JDIEventSource - boolean interrupted = false; // Set false by JDIEventSource - - private JDIEventSource eventSourceThread = null; - private int traceFlags; - private boolean dead = false; - - public Session(VirtualMachine vm, ExecutionManager runtime, - OutputListener diagnostics) { - this.vm = vm; - this.runtime = runtime; - this.diagnostics = diagnostics; - this.traceFlags = VirtualMachine.TRACE_NONE; - } - - /** - * Determine if VM is interrupted, i.e, present and not running. - */ - public boolean isInterrupted() { - return interrupted; - } - - public void setTraceMode(int traceFlags) { - this.traceFlags = traceFlags; - if (!dead) { - vm.setDebugTraceMode(traceFlags); - } - } - - public boolean attach() { - vm.setDebugTraceMode(traceFlags); - diagnostics.putString("Connected to VM"); - eventSourceThread = new JDIEventSource(this); - eventSourceThread.start(); - return true; - } - - public void detach() { - if (!dead) { - eventSourceThread.interrupt(); - eventSourceThread = null; - //### The VM may already be disconnected - //### if the debuggee did a System.exit(). - //### Exception handler here is a kludge, - //### Rather, there are many other places - //### where we need to handle this exception, - //### and initiate a detach due to an error - //### condition, e.g., connection failure. - try { - vm.dispose(); - } catch (VMDisconnectedException ee) {} - dead = true; - diagnostics.putString("Disconnected from VM"); - } - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SessionListener.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SessionListener.java deleted file mode 100644 index e13c4d70e72..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SessionListener.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import java.util.EventObject; -import java.util.EventListener; - -public interface SessionListener extends EventListener { - - void sessionStart(EventObject e); - - void sessionInterrupt(EventObject e); - void sessionContinue(EventObject e); -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SourceNameReferenceTypeSpec.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SourceNameReferenceTypeSpec.java deleted file mode 100644 index 36061bfc487..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SourceNameReferenceTypeSpec.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import com.sun.jdi.*; - -class SourceNameReferenceTypeSpec implements ReferenceTypeSpec { - final String sourceName; - final int linenumber; - - SourceNameReferenceTypeSpec(String sourceName, int linenumber) { - this.sourceName = sourceName; - this.linenumber = linenumber; - } - - /** - * Does the specified ReferenceType match this spec. - */ - @Override - public boolean matches(ReferenceType refType) { - try { - if (refType.sourceName().equals(sourceName)) { - try { - refType.locationsOfLine(linenumber); - // if we don't throw an exception then it was found - return true; - } catch(AbsentInformationException exc) { - } catch(ObjectCollectedException exc) { - } - } - } catch(AbsentInformationException exc) { - // for sourceName(), fall through - } - return false; - } - - @Override - public int hashCode() { - return sourceName.hashCode() + linenumber; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof SourceNameReferenceTypeSpec) { - SourceNameReferenceTypeSpec spec = (SourceNameReferenceTypeSpec)obj; - - return sourceName.equals(spec.sourceName) && - (linenumber == spec.linenumber); - } else { - return false; - } - } - - @Override - public String toString() { - return sourceName + "@" + linenumber; - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SpecErrorEvent.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SpecErrorEvent.java deleted file mode 100644 index baab1291d2d..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SpecErrorEvent.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -public class SpecErrorEvent extends SpecEvent { - - private static final long serialVersionUID = 8162634387866409578L; - private Exception reason; - - public SpecErrorEvent(EventRequestSpec eventRequestSpec, - Exception reason) { - super(eventRequestSpec); - this.reason = reason; - } - - public Exception getReason() { - return reason; - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SpecEvent.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SpecEvent.java deleted file mode 100644 index 7a321ef4aaa..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SpecEvent.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import java.util.EventObject; - -import com.sun.jdi.request.EventRequest; - -public class SpecEvent extends EventObject { - - private static final long serialVersionUID = 4820735456787276230L; - private EventRequestSpec eventRequestSpec; - - public SpecEvent(EventRequestSpec eventRequestSpec) { - super(eventRequestSpec.specs); - this.eventRequestSpec = eventRequestSpec; - } - - public EventRequestSpec getEventRequestSpec() { - return eventRequestSpec; - } - - public EventRequest getEventRequest() { - return eventRequestSpec.getEventRequest(); - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SpecListener.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SpecListener.java deleted file mode 100644 index 2e5df596ea4..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SpecListener.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import java.util.EventListener; - -public interface SpecListener extends EventListener { - - void breakpointSet(SpecEvent e); - void breakpointDeferred(SpecEvent e); - void breakpointDeleted(SpecEvent e); - void breakpointResolved(SpecEvent e); - void breakpointError(SpecErrorEvent e); - - void watchpointSet(SpecEvent e); - void watchpointDeferred(SpecEvent e); - void watchpointDeleted(SpecEvent e); - void watchpointResolved(SpecEvent e); - void watchpointError(SpecErrorEvent e); - - void exceptionInterceptSet(SpecEvent e); - void exceptionInterceptDeferred(SpecEvent e); - void exceptionInterceptDeleted(SpecEvent e); - void exceptionInterceptResolved(SpecEvent e); - void exceptionInterceptError(SpecErrorEvent e); -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ThreadGroupIterator.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ThreadGroupIterator.java deleted file mode 100644 index dd8b0cb3f7e..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ThreadGroupIterator.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import com.sun.jdi.ThreadGroupReference; -import java.util.List; -import java.util.Stack; -import java.util.ArrayList; -import java.util.Iterator; - -/** - * Descend the tree of thread groups. - * @author Robert G. Field - */ -public class ThreadGroupIterator implements Iterator { - private final Stack> stack - = new Stack>(); - - public ThreadGroupIterator(List tgl) { - push(tgl); - } - - public ThreadGroupIterator(ThreadGroupReference tg) { - List tgl = new ArrayList(); - tgl.add(tg); - push(tgl); - } - -/* - ThreadGroupIterator() { - this(Env.vm().topLevelThreadGroups()); - } -*/ - - private Iterator top() { - return stack.peek(); - } - - /** - * The invariant in this class is that the top iterator - * on the stack has more elements. If the stack is - * empty, there is no top. This method assures - * this invariant. - */ - private void push(List tgl) { - stack.push(tgl.iterator()); - while (!stack.isEmpty() && !top().hasNext()) { - stack.pop(); - } - } - - @Override - public boolean hasNext() { - return !stack.isEmpty(); - } - - @Override - public ThreadGroupReference next() { - return nextThreadGroup(); - } - - public ThreadGroupReference nextThreadGroup() { - ThreadGroupReference tg = top().next(); - push(tg.threadGroups()); - return tg; - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - -/* - static ThreadGroupReference find(String name) { - ThreadGroupIterator tgi = new ThreadGroupIterator(); - while (tgi.hasNext()) { - ThreadGroupReference tg = tgi.nextThreadGroup(); - if (tg.name().equals(name)) { - return tg; - } - } - return null; - } -*/ -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ThreadInfo.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ThreadInfo.java deleted file mode 100644 index 02626ac324f..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ThreadInfo.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import com.sun.jdi.*; - -//### Should handle target VM death or connection failure cleanly. - -public class ThreadInfo { - - private ThreadReference thread; - private int status; - - private int frameCount; - - Object userObject; // User-supplied annotation. - - private boolean interrupted = false; - - private void assureInterrupted() throws VMNotInterruptedException { - if (!interrupted) { - throw new VMNotInterruptedException(); - } - } - - ThreadInfo (ThreadReference thread) { - this.thread = thread; - this.frameCount = -1; - } - - public ThreadReference thread() { - return thread; - } - - public int getStatus() throws VMNotInterruptedException { - assureInterrupted(); - update(); - return status; - } - - public int getFrameCount() throws VMNotInterruptedException { - assureInterrupted(); - update(); - return frameCount; - } - - public StackFrame getFrame(int index) throws VMNotInterruptedException { - assureInterrupted(); - update(); - try { - return thread.frame(index); - } catch (IncompatibleThreadStateException e) { - // Should not happen - interrupted = false; - throw new VMNotInterruptedException(); - } - } - - public Object getUserObject() { - return userObject; - } - - public void setUserObject(Object obj) { - userObject = obj; - } - - // Refresh upon first access after cache is cleared. - - void update() throws VMNotInterruptedException { - if (frameCount == -1) { - try { - status = thread.status(); - frameCount = thread.frameCount(); - } catch (IncompatibleThreadStateException e) { - // Should not happen - interrupted = false; - throw new VMNotInterruptedException(); - } - } - } - - // Called from 'ExecutionManager'. - - void validate() { - interrupted = true; - } - - void invalidate() { - interrupted = false; - frameCount = -1; - status = ThreadReference.THREAD_STATUS_UNKNOWN; - } - -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ThreadIterator.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ThreadIterator.java deleted file mode 100644 index b82d88e6e1e..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ThreadIterator.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -import com.sun.jdi.ThreadGroupReference; -import com.sun.jdi.ThreadReference; -import java.util.List; -import java.util.Iterator; - -public class ThreadIterator implements Iterator { - Iterator it = null; - ThreadGroupIterator tgi; - - public ThreadIterator(ThreadGroupReference tg) { - tgi = new ThreadGroupIterator(tg); - } - - //### make this package access only? - public ThreadIterator(List tgl) { - tgi = new ThreadGroupIterator(tgl); - } - - @Override - public boolean hasNext() { - while (it == null || !it.hasNext()) { - if (!tgi.hasNext()) { - return false; // no more - } - it = tgi.nextThreadGroup().threads().iterator(); - } - return true; - } - - @Override - public ThreadReference next() { - return it.next(); - } - - public ThreadReference nextThread() { - return next(); - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/Utils.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/Utils.java deleted file mode 100644 index 34f1d724929..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/Utils.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; //### does it belong here? - -import com.sun.jdi.*; - -public class Utils { - - /** - * Return the thread status description. - */ - public static String getStatus(ThreadReference thr) { - int status = thr.status(); - String result; - switch (status) { - case ThreadReference.THREAD_STATUS_UNKNOWN: - result = "unknown status"; - break; - case ThreadReference.THREAD_STATUS_ZOMBIE: - result = "zombie"; - break; - case ThreadReference.THREAD_STATUS_RUNNING: - result = "running"; - break; - case ThreadReference.THREAD_STATUS_SLEEPING: - result = "sleeping"; - break; - case ThreadReference.THREAD_STATUS_MONITOR: - result = "waiting to acquire a monitor lock"; - break; - case ThreadReference.THREAD_STATUS_WAIT: - result = "waiting on a condition"; - break; - default: - result = ""; - } - if (thr.isSuspended()) { - result += " (suspended)"; - } - return result; - } - - /** - * Return a description of an object. - */ - public static String description(ObjectReference ref) { - ReferenceType clazz = ref.referenceType(); - long id = ref.uniqueID(); //### TODO use real id - if (clazz == null) { - return toHex(id); - } else { - return "(" + clazz.name() + ")" + toHex(id); - } - } - - /** - * Convert a long to a hexadecimal string. - */ - public static String toHex(long n) { - char s1[] = new char[16]; - char s2[] = new char[18]; - - // Store digits in reverse order. - int i = 0; - do { - long d = n & 0xf; - s1[i++] = (char)((d < 10) ? ('0' + d) : ('a' + d - 10)); - } while ((n >>>= 4) > 0); - - // Now reverse the array. - s2[0] = '0'; - s2[1] = 'x'; - int j = 2; - while (--i >= 0) { - s2[j++] = s1[i]; - } - return new String(s2, 0, j); - } - - /** - * Convert hexadecimal strings to longs. - */ - public static long fromHex(String hexStr) { - String str = hexStr.startsWith("0x") ? - hexStr.substring(2).toLowerCase() : hexStr.toLowerCase(); - if (hexStr.length() == 0) { - throw new NumberFormatException(); - } - - long ret = 0; - for (int i = 0; i < str.length(); i++) { - int c = str.charAt(i); - if (c >= '0' && c <= '9') { - ret = (ret * 16) + (c - '0'); - } else if (c >= 'a' && c <= 'f') { - ret = (ret * 16) + (c - 'a' + 10); - } else { - throw new NumberFormatException(); - } - } - return ret; - } - - - /* - * The next two methods are used by this class and by EventHandler - * to print consistent locations and error messages. - */ - public static String locationString(Location loc) { - return loc.declaringType().name() + - "." + loc.method().name() + "(), line=" + - loc.lineNumber(); - } - -//### UNUSED. -/************************ - private String typedName(Method method) { - // TO DO: Use method.signature() instead of method.arguments() so that - // we get sensible results for classes without debugging info - StringBuffer buf = new StringBuffer(); - buf.append(method.name()); - buf.append("("); - Iterator it = method.arguments().iterator(); - while (it.hasNext()) { - buf.append(((LocalVariable)it.next()).typeName()); - if (it.hasNext()) { - buf.append(","); - } - } - buf.append(")"); - return buf.toString(); - } -************************/ - - public static boolean isValidMethodName(String s) { - return isJavaIdentifier(s) || - s.equals("") || - s.equals(""); - } - - public static boolean isJavaIdentifier(String s) { - if (s.length() == 0) { - return false; - } - int cp = s.codePointAt(0); - if (! Character.isJavaIdentifierStart(cp)) { - return false; - } - for (int i = Character.charCount(cp); i < s.length(); i += Character.charCount(cp)) { - cp = s.codePointAt(i); - if (! Character.isJavaIdentifierPart(cp)) { - return false; - } - } - return true; - } - -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/VMLaunchFailureException.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/VMLaunchFailureException.java deleted file mode 100644 index c2429684d29..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/VMLaunchFailureException.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -public class VMLaunchFailureException extends Exception { - - private static final long serialVersionUID = -2439646729274310108L; -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/VMNotInterruptedException.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/VMNotInterruptedException.java deleted file mode 100644 index 489d88086cb..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/VMNotInterruptedException.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -public class VMNotInterruptedException extends Exception { - - private static final long serialVersionUID = 8111074582188765600L; -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/WatchpointSpec.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/WatchpointSpec.java deleted file mode 100644 index 367e38c7490..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/WatchpointSpec.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.bdi; - -public abstract class WatchpointSpec extends EventRequestSpec { - final String fieldId; - - WatchpointSpec(EventRequestSpecList specs, - ReferenceTypeSpec refSpec, String fieldId) { - super(specs, refSpec); - this.fieldId = fieldId; -// if (!isJavaIdentifier(fieldId)) { -// throw new MalformedMemberNameException(fieldId); -// } - } - - @Override - void notifySet(SpecListener listener, SpecEvent evt) { - listener.watchpointSet(evt); - } - - @Override - void notifyDeferred(SpecListener listener, SpecEvent evt) { - listener.watchpointDeferred(evt); - } - - @Override - void notifyResolved(SpecListener listener, SpecEvent evt) { - listener.watchpointResolved(evt); - } - - @Override - void notifyDeleted(SpecListener listener, SpecEvent evt) { - listener.watchpointDeleted(evt); - } - - @Override - void notifyError(SpecListener listener, SpecErrorEvent evt) { - listener.watchpointError(evt); - } - - @Override - public int hashCode() { - return refSpec.hashCode() + fieldId.hashCode() + - getClass().hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof WatchpointSpec) { - WatchpointSpec watchpoint = (WatchpointSpec)obj; - - return fieldId.equals(watchpoint.fieldId) && - refSpec.equals(watchpoint.refSpec) && - getClass().equals(watchpoint.getClass()); - } else { - return false; - } - } - - @Override - public String errorMessageFor(Exception e) { - if (e instanceof NoSuchFieldException) { - return ("No field " + fieldId + " in " + refSpec); - } else { - return super.errorMessageFor(e); - } - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/AbstractEventSet.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/AbstractEventSet.java deleted file mode 100644 index 0a82f15ee0a..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/AbstractEventSet.java +++ /dev/null @@ -1,272 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.event; - -import com.sun.jdi.*; -import com.sun.jdi.event.*; -import com.sun.jdi.request.*; - -import java.util.*; - -public abstract class AbstractEventSet extends EventObject implements EventSet { - - private static final long serialVersionUID = 2772717574222076977L; - private final EventSet jdiEventSet; - final Event oneEvent; - - /** - */ - AbstractEventSet(EventSet jdiEventSet) { - super(jdiEventSet.virtualMachine()); - this.jdiEventSet = jdiEventSet; - this.oneEvent = eventIterator().nextEvent(); - } - - public static AbstractEventSet toSpecificEventSet(EventSet jdiEventSet) { - Event evt = jdiEventSet.eventIterator().nextEvent(); - if (evt instanceof LocatableEvent) { - if (evt instanceof ExceptionEvent) { - return new ExceptionEventSet(jdiEventSet); - } else if (evt instanceof WatchpointEvent) { - if (evt instanceof AccessWatchpointEvent) { - return new AccessWatchpointEventSet(jdiEventSet); - } else { - return new ModificationWatchpointEventSet(jdiEventSet); - } - } else { - return new LocationTriggerEventSet(jdiEventSet); - } - } else if (evt instanceof ClassPrepareEvent) { - return new ClassPrepareEventSet(jdiEventSet); - } else if (evt instanceof ClassUnloadEvent) { - return new ClassUnloadEventSet(jdiEventSet); - } else if (evt instanceof ThreadDeathEvent) { - return new ThreadDeathEventSet(jdiEventSet); - } else if (evt instanceof ThreadStartEvent) { - return new ThreadStartEventSet(jdiEventSet); - } else if (evt instanceof VMDeathEvent) { - return new VMDeathEventSet(jdiEventSet); - } else if (evt instanceof VMDisconnectEvent) { - return new VMDisconnectEventSet(jdiEventSet); - } else if (evt instanceof VMStartEvent) { - return new VMStartEventSet(jdiEventSet); - } else { - throw new IllegalArgumentException("Unknown event " + evt); - } - } - - public abstract void notify(JDIListener listener); - - // Implement Mirror - - @Override - public VirtualMachine virtualMachine() { - return jdiEventSet.virtualMachine(); - } - - public VirtualMachine getVirtualMachine() { - return jdiEventSet.virtualMachine(); - } - - // Implement EventSet - - /** - * Returns the policy used to suspend threads in the target VM - * for this event set. This policy is selected from the suspend - * policies for each event's request. The one that suspends the - * most threads is chosen when the event occurs in the target VM - * and that policy is returned here. See - * com.sun.jdi.request.EventRequest for the possible policy values. - * - * @return the integer suspendPolicy - */ - public int getSuspendPolicy() { - return jdiEventSet.suspendPolicy(); - } - - @Override - public void resume() { - jdiEventSet.resume(); - } - - @Override - public int suspendPolicy() { - return jdiEventSet.suspendPolicy(); - } - - public boolean suspendedAll() { - return jdiEventSet.suspendPolicy() == EventRequest.SUSPEND_ALL; - } - - public boolean suspendedEventThread() { - return jdiEventSet.suspendPolicy() == EventRequest.SUSPEND_EVENT_THREAD; - } - - public boolean suspendedNone() { - return jdiEventSet.suspendPolicy() == EventRequest.SUSPEND_NONE; - } - - /** - * Return an iterator specific to {@link Event} objects. - */ - @Override - public EventIterator eventIterator() { - return jdiEventSet.eventIterator(); - } - - - // Implement java.util.Set (by pass through) - - /** - * Returns the number of elements in this set (its cardinality). If this - * set contains more than Integer.MAX_VALUE elements, returns - * Integer.MAX_VALUE. - * - * @return the number of elements in this set (its cardinality). - */ - @Override - public int size() { - return jdiEventSet.size(); - } - - /** - * Returns true if this set contains no elements. - * - * @return true if this set contains no elements. - */ - @Override - public boolean isEmpty() { - return jdiEventSet.isEmpty(); - } - - /** - * Returns true if this set contains the specified element. More - * formally, returns true if and only if this set contains an - * element e such that (o==null ? e==null : - * o.equals(e)). - * - * @return true if this set contains the specified element. - */ - @Override - public boolean contains(Object o) { - return jdiEventSet.contains(o); - } - - /** - * Returns an iterator over the elements in this set. The elements are - * returned in no particular order (unless this set is an instance of some - * class that provides a guarantee). - * - * @return an iterator over the elements in this set. - */ - @Override - public Iterator iterator() { - return jdiEventSet.iterator(); - } - - /** - * Returns an array containing all of the elements in this set. - * Obeys the general contract of the Collection.toArray method. - * - * @return an array containing all of the elements in this set. - */ - @Override - public Object[] toArray() { - return jdiEventSet.toArray(); - } - - /** - * Returns an array containing all of the elements in this set whose - * runtime type is that of the specified array. Obeys the general - * contract of the Collection.toArray(Object[]) method. - * - * @param a the array into which the elements of this set are to - * be stored, if it is big enough { - return jdiEventSet.XXX(); - } otherwise, a new array of the - * same runtime type is allocated for this purpose. - * @return an array containing the elements of this set. - * @throws ArrayStoreException the runtime type of a is not a supertype - * of the runtime type of every element in this set. - */ - @Override - public T[] toArray(T a[]) { - return jdiEventSet.toArray(a); - } - - // Bulk Operations - - /** - * Returns true if this set contains all of the elements of the - * specified collection. If the specified collection is also a set, this - * method returns true if it is a subset of this set. - * - * @param c collection to be checked for containment in this set. - * @return true if this set contains all of the elements of the - * specified collection. - */ - @Override - public boolean containsAll(Collection c) { - return jdiEventSet.containsAll(c); - } - - - // Make the rest of Set unmodifiable - - @Override - public boolean add(Event e){ - throw new UnsupportedOperationException(); - } - @Override - public boolean remove(Object o) { - throw new UnsupportedOperationException(); - } - @Override - public boolean addAll(Collection coll) { - throw new UnsupportedOperationException(); - } - @Override - public boolean removeAll(Collection coll) { - throw new UnsupportedOperationException(); - } - @Override - public boolean retainAll(Collection coll) { - throw new UnsupportedOperationException(); - } - @Override - public void clear() { - throw new UnsupportedOperationException(); - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/AccessWatchpointEventSet.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/AccessWatchpointEventSet.java deleted file mode 100644 index 10462e3bbb4..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/AccessWatchpointEventSet.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.event; - -import com.sun.jdi.event.*; - -public class AccessWatchpointEventSet extends WatchpointEventSet { - - private static final long serialVersionUID = -2620394219156607673L; - - AccessWatchpointEventSet(EventSet jdiEventSet) { - super(jdiEventSet); - } - - @Override - public void notify(JDIListener listener) { - listener.accessWatchpoint(this); - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ClassPrepareEventSet.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ClassPrepareEventSet.java deleted file mode 100644 index 9010415e362..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ClassPrepareEventSet.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.event; - -import com.sun.jdi.*; -import com.sun.jdi.event.*; - -public class ClassPrepareEventSet extends AbstractEventSet { - - private static final long serialVersionUID = 5958493423581010491L; - - ClassPrepareEventSet(EventSet jdiEventSet) { - super(jdiEventSet); - } - - /** - * Returns the thread in which this event has occurred. - * - * @return a {@link ThreadReference} which mirrors the event's thread in - * the target VM. - */ - public ThreadReference getThread() { - return ((ClassPrepareEvent)oneEvent).thread(); - } - - - /** - * Returns the reference type for which this event was generated. - * - * @return a {@link ReferenceType} which mirrors the class, interface, or - * array which has been linked. - */ - public ReferenceType getReferenceType() { - return ((ClassPrepareEvent)oneEvent).referenceType(); - } - - @Override - public void notify(JDIListener listener) { - listener.classPrepare(this); - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ClassUnloadEventSet.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ClassUnloadEventSet.java deleted file mode 100644 index ad57b70d059..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ClassUnloadEventSet.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.event; - -import com.sun.jdi.event.*; - -public class ClassUnloadEventSet extends AbstractEventSet { - - private static final long serialVersionUID = 8370341450345835866L; - - ClassUnloadEventSet(EventSet jdiEventSet) { - super(jdiEventSet); - } - - /** - * Returns the name of the class that has been unloaded. - */ - public String getClassName() { - return ((ClassUnloadEvent)oneEvent).className(); - } - - /** - * Returns the JNI-style signature of the class that has been unloaded. - */ - public String getClassSignature() { - return ((ClassUnloadEvent)oneEvent).classSignature(); - } - - @Override - public void notify(JDIListener listener) { - listener.classUnload(this); - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ExceptionEventSet.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ExceptionEventSet.java deleted file mode 100644 index d59cce74d49..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ExceptionEventSet.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.event; - -import com.sun.jdi.*; -import com.sun.jdi.event.*; - -public class ExceptionEventSet extends LocatableEventSet { - - private static final long serialVersionUID = 5328140167954640711L; - - ExceptionEventSet(EventSet jdiEventSet) { - super(jdiEventSet); - } - - /** - * Gets the thrown exception object. The exception object is - * an instance of java.lang.Throwable or a subclass in the - * target VM. - * - * @return an {@link ObjectReference} which mirrors the thrown object in - * the target VM. - */ - public ObjectReference getException() { - return ((ExceptionEvent)oneEvent).exception(); - } - - /** - * Gets the location where the exception will be caught. An exception - * is considered to be caught if, at the point of the throw, the - * current location is dynamically enclosed in a try statement that - * handles the exception. (See the JVM specification for details). - * If there is such a try statement, the catch location is the - * first code index of the appropriate catch clause. - *

- * If there are native methods in the call stack at the time of the - * exception, there are important restrictions to note about the - * returned catch location. In such cases, - * it is not possible to predict whether an exception will be handled - * by some native method on the call stack. - * Thus, it is possible that exceptions considered uncaught - * here will, in fact, be handled by a native method and not cause - * termination of the target VM. Also, it cannot be assumed that the - * catch location returned here will ever be reached by the throwing - * thread. If there is - * a native frame between the current location and the catch location, - * the exception might be handled and cleared in that native method - * instead. - * - * @return the {@link Location} where the exception will be caught or null if - * the exception is uncaught. - */ - public Location getCatchLocation() { - return ((ExceptionEvent)oneEvent).catchLocation(); - } - - @Override - public void notify(JDIListener listener) { - listener.exception(this); - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/JDIAdapter.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/JDIAdapter.java deleted file mode 100644 index 056cd0933b5..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/JDIAdapter.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.event; - -/** - * The adapter which receives JDI event sets. The methods in this - * class are empty; this class is provided as a convenience for - * easily creating listeners by extending this class and overriding - * only the methods of interest. - */ -public class JDIAdapter implements JDIListener { - - @Override - public void accessWatchpoint(AccessWatchpointEventSet e) { - } - - @Override - public void classPrepare(ClassPrepareEventSet e) { - } - - @Override - public void classUnload(ClassUnloadEventSet e) { - } - - @Override - public void exception(ExceptionEventSet e) { - } - - @Override - public void locationTrigger(LocationTriggerEventSet e) { - } - - @Override - public void modificationWatchpoint(ModificationWatchpointEventSet e) { - } - - @Override - public void threadDeath(ThreadDeathEventSet e) { - } - - @Override - public void threadStart(ThreadStartEventSet e) { - } - - @Override - public void vmDeath(VMDeathEventSet e) { - } - - @Override - public void vmDisconnect(VMDisconnectEventSet e) { - } - - @Override - public void vmStart(VMStartEventSet e) { - } - -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/JDIListener.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/JDIListener.java deleted file mode 100644 index 18a37261ee4..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/JDIListener.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.event; - -import java.util.EventListener; - -public interface JDIListener extends EventListener { - void accessWatchpoint(AccessWatchpointEventSet e); - void classPrepare(ClassPrepareEventSet e); - void classUnload(ClassUnloadEventSet e); - void exception(ExceptionEventSet e); - void locationTrigger(LocationTriggerEventSet e); - void modificationWatchpoint(ModificationWatchpointEventSet e); - void threadDeath(ThreadDeathEventSet e); - void threadStart(ThreadStartEventSet e); - void vmDeath(VMDeathEventSet e); - void vmDisconnect(VMDisconnectEventSet e); - void vmStart(VMStartEventSet e); -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/LocatableEventSet.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/LocatableEventSet.java deleted file mode 100644 index 6b4f607009c..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/LocatableEventSet.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.event; - -import com.sun.jdi.*; -import com.sun.jdi.event.*; - -/** - * Abstract event set for events with location and thread. - */ -public abstract class LocatableEventSet extends AbstractEventSet { - - private static final long serialVersionUID = 1027131209997915620L; - - LocatableEventSet(EventSet jdiEventSet) { - super(jdiEventSet); - } - - /** - * Returns the {@link Location} of this mirror. Depending on context - * and on available debug information, this location will have - * varying precision. - * - * @return the {@link Location} of this mirror. - */ - public Location getLocation() { - return ((LocatableEvent)oneEvent).location(); - } - - /** - * Returns the thread in which this event has occurred. - * - * @return a {@link ThreadReference} which mirrors the event's thread in - * the target VM. - */ - public ThreadReference getThread() { - return ((LocatableEvent)oneEvent).thread(); - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/LocationTriggerEventSet.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/LocationTriggerEventSet.java deleted file mode 100644 index 3d25a573883..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/LocationTriggerEventSet.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.event; - -import com.sun.jdi.event.*; - -public class LocationTriggerEventSet extends LocatableEventSet { - - private static final long serialVersionUID = -3674631710485872487L; - - LocationTriggerEventSet(EventSet jdiEventSet) { - super(jdiEventSet); - } - - @Override - public void notify(JDIListener listener) { - listener.locationTrigger(this); - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ModificationWatchpointEventSet.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ModificationWatchpointEventSet.java deleted file mode 100644 index 41749efa705..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ModificationWatchpointEventSet.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.event; - -import com.sun.jdi.*; -import com.sun.jdi.event.*; - -public class ModificationWatchpointEventSet extends WatchpointEventSet { - - private static final long serialVersionUID = -680889300856154719L; - - ModificationWatchpointEventSet(EventSet jdiEventSet) { - super(jdiEventSet); - } - - /** - * Value that will be assigned to the field when the instruction - * completes. - */ - public Value getValueToBe() { - return ((ModificationWatchpointEvent)oneEvent).valueToBe(); - } - - @Override - public void notify(JDIListener listener) { - listener.modificationWatchpoint(this); - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ThreadDeathEventSet.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ThreadDeathEventSet.java deleted file mode 100644 index 893ec73fa97..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ThreadDeathEventSet.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.event; - -import com.sun.jdi.*; -import com.sun.jdi.event.*; - -public class ThreadDeathEventSet extends AbstractEventSet { - - private static final long serialVersionUID = -8801604712308151331L; - - ThreadDeathEventSet(EventSet jdiEventSet) { - super(jdiEventSet); - } - - /** - * Returns the thread which is terminating. - * - * @return a {@link ThreadReference} which mirrors the event's thread in - * the target VM. - */ - public ThreadReference getThread() { - return ((ThreadDeathEvent)oneEvent).thread(); - } - - @Override - public void notify(JDIListener listener) { - listener.threadDeath(this); - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ThreadStartEventSet.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ThreadStartEventSet.java deleted file mode 100644 index 657e9633c9c..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ThreadStartEventSet.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.event; - -import com.sun.jdi.*; -import com.sun.jdi.event.*; - -public class ThreadStartEventSet extends AbstractEventSet { - - private static final long serialVersionUID = -3802096132294933502L; - - ThreadStartEventSet(EventSet jdiEventSet) { - super(jdiEventSet); - } - - /** - * Returns the thread which has started. - * - * @return a {@link ThreadReference} which mirrors the event's thread in - * the target VM. - */ - public ThreadReference getThread() { - return ((ThreadStartEvent)oneEvent).thread(); - } - - @Override - public void notify(JDIListener listener) { - listener.threadStart(this); - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/VMDeathEventSet.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/VMDeathEventSet.java deleted file mode 100644 index b6f7eb31843..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/VMDeathEventSet.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.event; - -import com.sun.jdi.event.*; - -public class VMDeathEventSet extends AbstractEventSet { - - private static final long serialVersionUID = 1163097303940092229L; - - VMDeathEventSet(EventSet jdiEventSet) { - super(jdiEventSet); - } - - @Override - public void notify(JDIListener listener) { - listener.vmDeath(this); - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/VMDisconnectEventSet.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/VMDisconnectEventSet.java deleted file mode 100644 index 5b7dc7953ac..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/VMDisconnectEventSet.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.event; - -import com.sun.jdi.event.*; - -public class VMDisconnectEventSet extends AbstractEventSet { - - private static final long serialVersionUID = 7968123152344675342L; - - VMDisconnectEventSet(EventSet jdiEventSet) { - super(jdiEventSet); - } - - @Override - public void notify(JDIListener listener) { - listener.vmDisconnect(this); - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/VMStartEventSet.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/VMStartEventSet.java deleted file mode 100644 index f9381239fc8..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/VMStartEventSet.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.event; - -import com.sun.jdi.*; -import com.sun.jdi.event.*; - -public class VMStartEventSet extends AbstractEventSet { - - private static final long serialVersionUID = -3384957227835478191L; - - VMStartEventSet(EventSet jdiEventSet) { - super(jdiEventSet); - } - - /** - * Returns the initial thread of the VM which has started. - * - * @return a {@link ThreadReference} which mirrors the event's - * thread in the target VM. - */ - public ThreadReference getThread() { - return ((VMStartEvent)oneEvent).thread(); - } - - @Override - public void notify(JDIListener listener) { - listener.vmStart(this); - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/WatchpointEventSet.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/WatchpointEventSet.java deleted file mode 100644 index 76be4acf1da..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/WatchpointEventSet.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.event; - -import com.sun.jdi.*; -import com.sun.jdi.event.*; - -public abstract class WatchpointEventSet extends LocatableEventSet { - - private static final long serialVersionUID = 5606285209703845409L; - - WatchpointEventSet(EventSet jdiEventSet) { - super(jdiEventSet); - } - - /** - * Returns the field that is about to be accessed/modified. - * - * @return a {@link Field} which mirrors the field - * in the target VM. - */ - public Field getField() { - return ((WatchpointEvent)oneEvent).field(); - } - - /** - * Returns the object whose field is about to be accessed/modified. - * Return null is the access is to a static field. - * - * @return a {@link ObjectReference} which mirrors the event's - * object in the target VM. - */ - public ObjectReference getObject() { - return ((WatchpointEvent)oneEvent).object(); - } - - /** - * Current value of the field. - */ - public Value getValueCurrent() { - return ((WatchpointEvent)oneEvent).valueCurrent(); - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/ApplicationTool.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/ApplicationTool.java deleted file mode 100644 index 717a5b9390e..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/ApplicationTool.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.gui; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.*; - -import com.sun.tools.example.debug.bdi.*; - -public class ApplicationTool extends JPanel { - - private static final long serialVersionUID = 310966063293205714L; - - private ExecutionManager runtime; - - private TypeScript script; - - private static final String PROMPT = "Input:"; - - public ApplicationTool(Environment env) { - - super(new BorderLayout()); - - this.runtime = env.getExecutionManager(); - - this.script = new TypeScript(PROMPT, false); // No implicit echo. - this.add(script); - - script.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - runtime.sendLineToApplication(script.readln()); - } - }); - - runtime.addApplicationEchoListener(new TypeScriptOutputListener(script)); - runtime.addApplicationOutputListener(new TypeScriptOutputListener(script)); - runtime.addApplicationErrorListener(new TypeScriptOutputListener(script)); - - //### should clean up on exit! - - } - - /****** - public void setFont(Font f) { - script.setFont(f); - } - ******/ - -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/ClassManager.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/ClassManager.java deleted file mode 100644 index 6e347376769..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/ClassManager.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.gui; - -public class ClassManager { - - // This class is provided primarily for symmetry with - // SourceManager. Currently, it does very little. - // If we add facilities in the future that require that - // class files be read outside of the VM, for example, to - // provide a disassembled view of a class for bytecode-level - // debugging, the required class file management will be done - // here. - - private SearchPath classPath; - - public ClassManager(Environment env) { - this.classPath = new SearchPath(""); - } - - public ClassManager(SearchPath classPath) { - this.classPath = classPath; - } - - /* - * Set path for access to class files. - */ - - public void setClassPath(SearchPath sp) { - classPath = sp; - } - - /* - * Get path for access to class files. - */ - - public SearchPath getClassPath() { - return classPath; - } - -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/ClassTreeTool.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/ClassTreeTool.java deleted file mode 100644 index 995c414854c..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/ClassTreeTool.java +++ /dev/null @@ -1,287 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.gui; - -import java.util.*; - -import javax.swing.*; -import javax.swing.tree.*; -import java.awt.*; -import java.awt.event.*; - -import com.sun.jdi.*; -import com.sun.tools.example.debug.event.*; -import com.sun.tools.example.debug.bdi.*; - -public class ClassTreeTool extends JPanel { - - private static final long serialVersionUID = 526178912591739259L; - - private Environment env; - - private ExecutionManager runtime; - private SourceManager sourceManager; - private ClassManager classManager; - - private JTree tree; - private DefaultTreeModel treeModel; - private ClassTreeNode root; -// private SearchPath sourcePath; - - private CommandInterpreter interpreter; - - private static String HEADING = "CLASSES"; - - public ClassTreeTool(Environment env) { - - super(new BorderLayout()); - - this.env = env; - this.runtime = env.getExecutionManager(); - this.sourceManager = env.getSourceManager(); - - this.interpreter = new CommandInterpreter(env); - - root = createClassTree(HEADING); - treeModel = new DefaultTreeModel(root); - - // Create a tree that allows one selection at a time. - - tree = new JTree(treeModel); - tree.setSelectionModel(new SingleLeafTreeSelectionModel()); - - /****** - // Listen for when the selection changes. - tree.addTreeSelectionListener(new TreeSelectionListener() { - public void valueChanged(TreeSelectionEvent e) { - ClassTreeNode node = (ClassTreeNode) - (e.getPath().getLastPathComponent()); - if (node != null) { - interpreter.executeCommand("view " + node.getReferenceTypeName()); - } - } - }); - ******/ - - MouseListener ml = new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - int selRow = tree.getRowForLocation(e.getX(), e.getY()); - TreePath selPath = tree.getPathForLocation(e.getX(), e.getY()); - if(selRow != -1) { - if(e.getClickCount() == 1) { - ClassTreeNode node = - (ClassTreeNode)selPath.getLastPathComponent(); - // If user clicks on leaf, select it, and issue 'view' command. - if (node.isLeaf()) { - tree.setSelectionPath(selPath); - interpreter.executeCommand("view " + node.getReferenceTypeName()); - } - } - } - } - }; - tree.addMouseListener(ml); - - JScrollPane treeView = new JScrollPane(tree); - add(treeView); - - // Create listener. - ClassTreeToolListener listener = new ClassTreeToolListener(); - runtime.addJDIListener(listener); - runtime.addSessionListener(listener); - - //### remove listeners on exit! - } - - private class ClassTreeToolListener extends JDIAdapter - implements JDIListener, SessionListener { - - // SessionListener - - @Override - public void sessionStart(EventObject e) { - // Get system classes and any others loaded before attaching. - try { - for (ReferenceType type : runtime.allClasses()) { - root.addClass(type); - } - } catch (VMDisconnectedException ee) { - // VM terminated unexpectedly. - } catch (NoSessionException ee) { - // Ignore. Should not happen. - } - } - - @Override - public void sessionInterrupt(EventObject e) {} - @Override - public void sessionContinue(EventObject e) {} - - // JDIListener - - @Override - public void classPrepare(ClassPrepareEventSet e) { - root.addClass(e.getReferenceType()); - } - - @Override - public void classUnload(ClassUnloadEventSet e) { - root.removeClass(e.getClassName()); - } - - @Override - public void vmDisconnect(VMDisconnectEventSet e) { - // Clear contents of this view. - root = createClassTree(HEADING); - treeModel = new DefaultTreeModel(root); - tree.setModel(treeModel); - } - } - - ClassTreeNode createClassTree(String label) { - return new ClassTreeNode(label, null); - } - - class ClassTreeNode extends DefaultMutableTreeNode { - - private String name; - private ReferenceType refTy; // null for package - - ClassTreeNode(String name, ReferenceType refTy) { - this.name = name; - this.refTy = refTy; - } - - @Override - public String toString() { - return name; - } - - public ReferenceType getReferenceType() { - return refTy; - } - - public String getReferenceTypeName() { - return refTy.name(); - } - - private boolean isPackage() { - return (refTy == null); - } - - @Override - public boolean isLeaf() { - return !isPackage(); - } - - public void addClass(ReferenceType refTy) { - addClass(refTy.name(), refTy); - } - - private void addClass(String className, ReferenceType refTy) { - if (className.equals("")) { - return; - } - int pos = className.indexOf('.'); - if (pos < 0) { - insertNode(className, refTy); - } else { - String head = className.substring(0, pos); - String tail = className.substring(pos + 1); - ClassTreeNode child = insertNode(head, null); - child.addClass(tail, refTy); - } - } - - private ClassTreeNode insertNode(String name, ReferenceType refTy) { - for (int i = 0; i < getChildCount(); i++) { - ClassTreeNode child = (ClassTreeNode)getChildAt(i); - int cmp = name.compareTo(child.toString()); - if (cmp == 0) { - // like-named node already exists - return child; - } else if (cmp < 0) { - // insert new node before the child - ClassTreeNode newChild = new ClassTreeNode(name, refTy); - treeModel.insertNodeInto(newChild, this, i); - return newChild; - } - } - // insert new node after last child - ClassTreeNode newChild = new ClassTreeNode(name, refTy); - treeModel.insertNodeInto(newChild, this, getChildCount()); - return newChild; - } - - public void removeClass(String className) { - if (className.equals("")) { - return; - } - int pos = className.indexOf('.'); - if (pos < 0) { - ClassTreeNode child = findNode(className); - if (!isPackage()) { - treeModel.removeNodeFromParent(child); - } - } else { - String head = className.substring(0, pos); - String tail = className.substring(pos + 1); - ClassTreeNode child = findNode(head); - child.removeClass(tail); - if (isPackage() && child.getChildCount() < 1) { - // Prune non-leaf nodes with no children. - treeModel.removeNodeFromParent(child); - } - } - } - - private ClassTreeNode findNode(String name) { - for (int i = 0; i < getChildCount(); i++) { - ClassTreeNode child = (ClassTreeNode)getChildAt(i); - int cmp = name.compareTo(child.toString()); - if (cmp == 0) { - return child; - } else if (cmp > 0) { - // not found, since children are sorted - return null; - } - } - return null; - } - - } - -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/CommandInterpreter.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/CommandInterpreter.java deleted file mode 100644 index fbff95b2703..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/CommandInterpreter.java +++ /dev/null @@ -1,1468 +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. - */ - -/* - * This source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.gui; - -import java.io.*; -import java.util.*; - -import com.sun.jdi.*; -import com.sun.tools.example.debug.bdi.*; - -public class CommandInterpreter { - - boolean echo; - - Environment env; - - private ContextManager context; - private ExecutionManager runtime; - private ClassManager classManager; - private SourceManager sourceManager; - - private OutputSink out; //### Hack! Should be local in each method used. - private String lastCommand = "help"; - - public CommandInterpreter(Environment env) { - this(env, true); - } - - public CommandInterpreter(Environment env, boolean echo) { - this.env = env; - this.echo = echo; - this.runtime = env.getExecutionManager(); - this.context = env.getContextManager(); - this.classManager = env.getClassManager(); - this.sourceManager = env.getSourceManager(); - } - - private ThreadReference[] threads = null; - - /* - * The numbering of threads is relative to the current set of threads, - * and may be affected by the creation and termination of new threads. - * Commands issued using such thread ids will only give reliable behavior - * relative to what was shown earlier in 'list' commands if the VM is interrupted. - * We need a better scheme. - */ - - private ThreadReference[] threads() throws NoSessionException { - if (threads == null) { - ThreadIterator ti = new ThreadIterator(getDefaultThreadGroup()); - List tlist = new ArrayList(); - while (ti.hasNext()) { - tlist.add(ti.nextThread()); - } - threads = tlist.toArray(new ThreadReference[tlist.size()]); - } - return threads; - } - - private ThreadReference findThread(String idToken) throws NoSessionException { - String id; - ThreadReference thread = null; - if (idToken.startsWith("t@")) { - id = idToken.substring(2); - } else { - id = idToken; - } - try { - ThreadReference[] threads = threads(); - long threadID = Long.parseLong(id, 16); - for (ThreadReference thread2 : threads) { - if (thread2.uniqueID() == threadID) { - thread = thread2; - break; - } - } - if (thread == null) { - //env.failure("No thread for id \"" + idToken + "\""); - env.failure("\"" + idToken + "\" is not a valid thread id."); - } - } catch (NumberFormatException e) { - env.error("Thread id \"" + idToken + "\" is ill-formed."); - thread = null; - } - return thread; - } - - private ThreadIterator allThreads() throws NoSessionException { - threads = null; - //### Why not use runtime.allThreads().iterator() ? - return new ThreadIterator(runtime.topLevelThreadGroups()); - } - - private ThreadIterator currentThreadGroupThreads() throws NoSessionException { - threads = null; - return new ThreadIterator(getDefaultThreadGroup()); - } - - private ThreadGroupIterator allThreadGroups() throws NoSessionException { - threads = null; - return new ThreadGroupIterator(runtime.topLevelThreadGroups()); - } - - private ThreadGroupReference defaultThreadGroup; - - private ThreadGroupReference getDefaultThreadGroup() throws NoSessionException { - if (defaultThreadGroup == null) { - defaultThreadGroup = runtime.systemThreadGroup(); - } - return defaultThreadGroup; - } - - private void setDefaultThreadGroup(ThreadGroupReference tg) { - defaultThreadGroup = tg; - } - - /* - * Command handlers. - */ - - // Command: classes - - private void commandClasses() throws NoSessionException { - OutputSink out = env.getOutputSink(); - //out.println("** classes list **"); - for (ReferenceType refType : runtime.allClasses()) { - out.println(refType.name()); - } - out.show(); - } - - - // Command: methods - - private void commandMethods(StringTokenizer t) throws NoSessionException { - if (!t.hasMoreTokens()) { - env.error("No class specified."); - return; - } - String idClass = t.nextToken(); - ReferenceType cls = findClass(idClass); - if (cls != null) { - List methods = cls.allMethods(); - OutputSink out = env.getOutputSink(); - for (int i = 0; i < methods.size(); i++) { - Method method = methods.get(i); - out.print(method.declaringType().name() + " " + - method.name() + "("); - Iterator it = method.argumentTypeNames().iterator(); - if (it.hasNext()) { - while (true) { - out.print(it.next()); - if (!it.hasNext()) { - break; - } - out.print(", "); - } - } - out.println(")"); - } - out.show(); - } else { - //### Should validate class name syntax. - env.failure("\"" + idClass + "\" is not a valid id or class name."); - } - } - - private ReferenceType findClass(String pattern) throws NoSessionException { - List results = runtime.findClassesMatchingPattern(pattern); - if (results.size() > 0) { - //### Should handle multiple results sensibly. - return results.get(0); - } - return null; - } - - // Command: threads - - private void commandThreads(StringTokenizer t) throws NoSessionException { - if (!t.hasMoreTokens()) { - OutputSink out = env.getOutputSink(); - printThreadGroup(out, getDefaultThreadGroup(), 0); - out.show(); - return; - } - String name = t.nextToken(); - ThreadGroupReference tg = findThreadGroup(name); - if (tg == null) { - env.failure(name + " is not a valid threadgroup name."); - } else { - OutputSink out = env.getOutputSink(); - printThreadGroup(out, tg, 0); - out.show(); - } - } - - private ThreadGroupReference findThreadGroup(String name) throws NoSessionException { - //### Issue: Uniqueness of thread group names is not enforced. - ThreadGroupIterator tgi = allThreadGroups(); - while (tgi.hasNext()) { - ThreadGroupReference tg = tgi.nextThreadGroup(); - if (tg.name().equals(name)) { - return tg; - } - } - return null; - } - - private int printThreadGroup(OutputSink out, ThreadGroupReference tg, int iThread) { - out.println("Group " + tg.name() + ":"); - List tlist = tg.threads(); - int maxId = 0; - int maxName = 0; - for (int i = 0 ; i < tlist.size() ; i++) { - ThreadReference thr = tlist.get(i); - int len = Utils.description(thr).length(); - if (len > maxId) { - maxId = len; - } - String name = thr.name(); - int iDot = name.lastIndexOf('.'); - if (iDot >= 0 && name.length() > iDot) { - name = name.substring(iDot + 1); - } - if (name.length() > maxName) { - maxName = name.length(); - } - } - String maxNumString = String.valueOf(iThread + tlist.size()); - int maxNumDigits = maxNumString.length(); - for (int i = 0 ; i < tlist.size() ; i++) { - ThreadReference thr = tlist.get(i); - char buf[] = new char[80]; - for (int j = 0; j < 79; j++) { - buf[j] = ' '; - } - buf[79] = '\0'; - StringBuilder sbOut = new StringBuilder(); - sbOut.append(buf); - - // Right-justify the thread number at start of output string - String numString = String.valueOf(iThread + i + 1); - sbOut.insert(maxNumDigits - numString.length(), - numString); - sbOut.insert(maxNumDigits, "."); - - int iBuf = maxNumDigits + 2; - sbOut.insert(iBuf, Utils.description(thr)); - iBuf += maxId + 1; - String name = thr.name(); - int iDot = name.lastIndexOf('.'); - if (iDot >= 0 && name.length() > iDot) { - name = name.substring(iDot + 1); - } - sbOut.insert(iBuf, name); - iBuf += maxName + 1; - sbOut.insert(iBuf, Utils.getStatus(thr)); - sbOut.setLength(79); - out.println(sbOut.toString()); - } - for (ThreadGroupReference tg0 : tg.threadGroups()) { - if (!tg.equals(tg0)) { // TODO ref mgt - iThread += printThreadGroup(out, tg0, iThread + tlist.size()); - } - } - return tlist.size(); - } - - // Command: threadgroups - - private void commandThreadGroups() throws NoSessionException { - ThreadGroupIterator it = allThreadGroups(); - int cnt = 0; - OutputSink out = env.getOutputSink(); - while (it.hasNext()) { - ThreadGroupReference tg = it.nextThreadGroup(); - ++cnt; - out.println("" + cnt + ". " + Utils.description(tg) + " " + tg.name()); - } - out.show(); - } - - // Command: thread - - private void commandThread(StringTokenizer t) throws NoSessionException { - if (!t.hasMoreTokens()) { - env.error("Thread number not specified."); - return; - } - ThreadReference thread = findThread(t.nextToken()); - if (thread != null) { - //### Should notify user. - context.setCurrentThread(thread); - } - } - - // Command: threadgroup - - private void commandThreadGroup(StringTokenizer t) throws NoSessionException { - if (!t.hasMoreTokens()) { - env.error("Threadgroup name not specified."); - return; - } - String name = t.nextToken(); - ThreadGroupReference tg = findThreadGroup(name); - if (tg == null) { - env.failure(name + " is not a valid threadgroup name."); - } else { - //### Should notify user. - setDefaultThreadGroup(tg); - } - } - - // Command: run - - private void commandRun(StringTokenizer t) throws NoSessionException { - if (doLoad(false, t)) { - env.notice("Running ..."); - } - } - - // Command: load - - private void commandLoad(StringTokenizer t) throws NoSessionException { - if (doLoad(true, t)) {} - } - - private boolean doLoad(boolean suspended, - StringTokenizer t) throws NoSessionException { - - String clname; - - if (!t.hasMoreTokens()) { - clname = context.getMainClassName(); - if (!clname.equals("")) { - // Run from prevously-set class name. - try { - String vmArgs = context.getVmArguments(); - runtime.run(suspended, - vmArgs, - clname, - context.getProgramArguments()); - return true; - } catch (VMLaunchFailureException e) { - env.failure("Attempt to launch main class \"" + clname + "\" failed."); - } - } else { - env.failure("No main class specified and no current default defined."); - } - } else { - clname = t.nextToken(); - StringBuilder str = new StringBuilder(); - // Allow VM arguments to be specified here? - while (t.hasMoreTokens()) { - String tok = t.nextToken(); - str.append(tok); - if (t.hasMoreTokens()) { - str.append(' '); - } - } - String args = str.toString(); - try { - String vmArgs = context.getVmArguments(); - runtime.run(suspended, vmArgs, clname, args); - context.setMainClassName(clname); - //context.setVmArguments(vmArgs); - context.setProgramArguments(args); - return true; - } catch (VMLaunchFailureException e) { - env.failure("Attempt to launch main class \"" + clname + "\" failed."); - } - } - return false; - } - - // Command: connect - - private void commandConnect(StringTokenizer t) { - try { - LaunchTool.queryAndLaunchVM(runtime); - } catch (VMLaunchFailureException e) { - env.failure("Attempt to connect failed."); - } - } - - // Command: attach - - private void commandAttach(StringTokenizer t) { - String portName; - if (!t.hasMoreTokens()) { - portName = context.getRemotePort(); - if (!portName.equals("")) { - try { - runtime.attach(portName); - } catch (VMLaunchFailureException e) { - env.failure("Attempt to attach to port \"" + portName + "\" failed."); - } - } else { - env.failure("No port specified and no current default defined."); - } - } else { - portName = t.nextToken(); - try { - runtime.attach(portName); - } catch (VMLaunchFailureException e) { - env.failure("Attempt to attach to port \"" + portName + "\" failed."); - } - context.setRemotePort(portName); - } - } - - // Command: detach - - private void commandDetach(StringTokenizer t) throws NoSessionException { - runtime.detach(); - } - - // Command: interrupt - - private void commandInterrupt(StringTokenizer t) throws NoSessionException { - runtime.interrupt(); - } - - // Command: suspend - - private void commandSuspend(StringTokenizer t) throws NoSessionException { - if (!t.hasMoreTokens()) { - // Suspend all threads in the current thread group. - //### Issue: help message says default is all threads. - //### Behavior here agrees with 'jdb', however. - ThreadIterator ti = currentThreadGroupThreads(); - while (ti.hasNext()) { - // TODO - don't suspend debugger threads - ti.nextThread().suspend(); - } - env.notice("All (non-system) threads suspended."); - } else { - while (t.hasMoreTokens()) { - ThreadReference thread = findThread(t.nextToken()); - if (thread != null) { - //thread.suspend(); - runtime.suspendThread(thread); - } - } - } - } - - // Command: resume - - private void commandResume(StringTokenizer t) throws NoSessionException { - if (!t.hasMoreTokens()) { - // Suspend all threads in the current thread group. - //### Issue: help message says default is all threads. - //### Behavior here agrees with 'jdb', however. - ThreadIterator ti = currentThreadGroupThreads(); - while (ti.hasNext()) { - // TODO - don't suspend debugger threads - ti.nextThread().resume(); - } - env.notice("All threads resumed."); - } else { - while (t.hasMoreTokens()) { - ThreadReference thread = findThread(t.nextToken()); - if (thread != null) { - //thread.resume(); - runtime.resumeThread(thread); - } - } - } - } - - // Command: cont - - private void commandCont() throws NoSessionException { - try { - runtime.go(); - } catch (VMNotInterruptedException e) { - //### failure? - env.notice("Target VM is already running."); - } - } - - // Command: step - - private void commandStep(StringTokenizer t) throws NoSessionException{ - ThreadReference current = context.getCurrentThread(); - if (current == null) { - env.failure("No current thread."); - return; - } - try { - if (t.hasMoreTokens() && - t.nextToken().toLowerCase().equals("up")) { - runtime.stepOut(current); - } else { - runtime.stepIntoLine(current); - } - } catch (AbsentInformationException e) { - env.failure("No linenumber information available -- " + - "Try \"stepi\" to step by instructions."); - } - } - - // Command: stepi - - private void commandStepi() throws NoSessionException { - ThreadReference current = context.getCurrentThread(); - if (current == null) { - env.failure("No current thread."); - return; - } - runtime.stepIntoInstruction(current); - } - - // Command: next - - private void commandNext() throws NoSessionException { - ThreadReference current = context.getCurrentThread(); - if (current == null) { - env.failure("No current thread."); - return; - } - try { - runtime.stepOverLine(current); - } catch (AbsentInformationException e) { - env.failure("No linenumber information available -- " + - "Try \"nexti\" to step by instructions."); - } - } - - // Command: nexti (NEW) - - private void commandNexti() throws NoSessionException { - ThreadReference current = context.getCurrentThread(); - if (current == null) { - env.failure("No current thread."); - return; - } - runtime.stepOverInstruction(current); - } - - // Command: kill - - private void commandKill(StringTokenizer t) throws NoSessionException { - //### Should change the way in which thread ids and threadgroup names - //### are distinguished. - if (!t.hasMoreTokens()) { - env.error("Usage: kill or "); - return; - } - while (t.hasMoreTokens()) { - String idToken = t.nextToken(); - ThreadReference thread = findThread(idToken); - if (thread != null) { - runtime.stopThread(thread); - env.notice("Thread " + thread.name() + " killed."); - return; - } else { - /* Check for threadgroup name, NOT skipping "system". */ - //### Should skip "system"? Classic 'jdb' does this. - //### Should deal with possible non-uniqueness of threadgroup names. - ThreadGroupIterator itg = allThreadGroups(); - while (itg.hasNext()) { - ThreadGroupReference tg = itg.nextThreadGroup(); - if (tg.name().equals(idToken)) { - ThreadIterator it = new ThreadIterator(tg); - while (it.hasNext()) { - runtime.stopThread(it.nextThread()); - } - env.notice("Threadgroup " + tg.name() + "killed."); - return; - } - } - env.failure("\"" + idToken + - "\" is not a valid threadgroup or id."); - } - } - } - - - /************* - // TODO - private void commandCatchException(StringTokenizer t) throws NoSessionException {} - // TODO - private void commandIgnoreException(StringTokenizer t) throws NoSessionException {} - *************/ - - // Command: up - - //### Print current frame after command? - - int readCount(StringTokenizer t) { - int cnt = 1; - if (t.hasMoreTokens()) { - String idToken = t.nextToken(); - try { - cnt = Integer.valueOf(idToken).intValue(); - } catch (NumberFormatException e) { - cnt = -1; - } - } - return cnt; - } - - void commandUp(StringTokenizer t) throws NoSessionException { - ThreadReference current = context.getCurrentThread(); - if (current == null) { - env.failure("No current thread."); - return; - } - int nLevels = readCount(t); - if (nLevels <= 0) { - env.error("usage: up [n frames]"); - return; - } - try { - int delta = context.moveCurrentFrameIndex(current, -nLevels); - if (delta == 0) { - env.notice("Already at top of stack."); - } else if (-delta < nLevels) { - env.notice("Moved up " + delta + " frames to top of stack."); - } - } catch (VMNotInterruptedException e) { - env.failure("Target VM must be in interrupted state."); - } - } - - private void commandDown(StringTokenizer t) throws NoSessionException { - ThreadReference current = context.getCurrentThread(); - if (current == null) { - env.failure("No current thread."); - return; - } - int nLevels = readCount(t); - if (nLevels <= 0) { - env.error("usage: down [n frames]"); - return; - } - try { - int delta = context.moveCurrentFrameIndex(current, nLevels); - if (delta == 0) { - env.notice("Already at bottom of stack."); - } else if (delta < nLevels) { - env.notice("Moved down " + delta + " frames to bottom of stack."); - } - } catch (VMNotInterruptedException e) { - env.failure("Target VM must be in interrupted state."); - } - } - - // Command: frame - - private void commandFrame(StringTokenizer t) throws NoSessionException { - ThreadReference current = context.getCurrentThread(); - if (current == null) { - env.failure("No current thread."); - return; - } - if (!t.hasMoreTokens()) { - env.error("usage: frame "); - return; - } - String idToken = t.nextToken(); - int n; - try { - n = Integer.valueOf(idToken).intValue(); - } catch (NumberFormatException e) { - n = 0; - } - if (n <= 0) { - env.error("use positive frame index"); - return; - } - try { - int delta = context.setCurrentFrameIndex(current, n); - if (delta == 0) { - env.notice("Frame unchanged."); - } else if (delta < 0) { - env.notice("Moved up " + -delta + " frames."); - } else { - env.notice("Moved down " + delta + " frames."); - } - } catch (VMNotInterruptedException e) { - env.failure("Target VM must be in interrupted state."); - } - } - - // Command: where - - //### Should we insist that VM be interrupted here? - //### There is an inconsistency between the 'where' command - //### and 'up' and 'down' in this respect. - - private void commandWhere(StringTokenizer t, boolean showPC) - throws NoSessionException { - ThreadReference current = context.getCurrentThread(); - if (!t.hasMoreTokens()) { - if (current == null) { - env.error("No thread specified."); - return; - } - dumpStack(current, showPC); - } else { - String token = t.nextToken(); - if (token.toLowerCase().equals("all")) { - ThreadIterator it = allThreads(); - while (it.hasNext()) { - ThreadReference thread = it.next(); - out.println(thread.name() + ": "); - dumpStack(thread, showPC); - } - } else { - ThreadReference thread = findThread(t.nextToken()); - //### Do we want to set current thread here? - //### Should notify user of change. - if (thread != null) { - context.setCurrentThread(thread); - } - dumpStack(thread, showPC); - } - } - } - - private void dumpStack(ThreadReference thread, boolean showPC) { - //### Check for these. - //env.failure("Thread no longer exists."); - //env.failure("Target VM must be in interrupted state."); - //env.failure("Current thread isn't suspended."); - //### Should handle extremely long stack traces sensibly for user. - List stack = null; - try { - stack = thread.frames(); - } catch (IncompatibleThreadStateException e) { - env.failure("Thread is not suspended."); - } - //### Fix this! - //### Previously mishandled cases where thread was not current. - //### Now, prints all of the stack regardless of current frame. - int frameIndex = 0; - //int frameIndex = context.getCurrentFrameIndex(); - if (stack == null) { - env.failure("Thread is not running (no stack)."); - } else { - OutputSink out = env.getOutputSink(); - int nFrames = stack.size(); - for (int i = frameIndex; i < nFrames; i++) { - StackFrame frame = stack.get(i); - Location loc = frame.location(); - Method meth = loc.method(); - out.print(" [" + (i + 1) + "] "); - out.print(meth.declaringType().name()); - out.print('.'); - out.print(meth.name()); - out.print(" ("); - if (meth.isNative()) { - out.print("native method"); - } else if (loc.lineNumber() != -1) { - try { - out.print(loc.sourceName()); - } catch (AbsentInformationException e) { - out.print(""); - } - out.print(':'); - out.print(loc.lineNumber()); - } - out.print(')'); - if (showPC) { - long pc = loc.codeIndex(); - if (pc != -1) { - out.print(", pc = " + pc); - } - } - out.println(); - } - out.show(); - } - } - - private void listEventRequests() throws NoSessionException { - // Print set breakpoints - List specs = runtime.eventRequestSpecs(); - if (specs.isEmpty()) { - env.notice("No breakpoints/watchpoints/exceptions set."); - } else { - OutputSink out = env.getOutputSink(); - out.println("Current breakpoints/watchpoints/exceptions set:"); - for (EventRequestSpec bp : specs) { - out.println("\t" + bp); - } - out.show(); - } - } - - private BreakpointSpec parseBreakpointSpec(String bptSpec) { - StringTokenizer t = new StringTokenizer(bptSpec); - BreakpointSpec bpSpec = null; -// try { - String token = t.nextToken("@:( \t\n\r"); - // We can't use hasMoreTokens here because it will cause any leading - // paren to be lost. - String rest; - try { - rest = t.nextToken("").trim(); - } catch (NoSuchElementException e) { - rest = null; - } - if ((rest != null) && rest.startsWith("@")) { - t = new StringTokenizer(rest.substring(1)); - String sourceName = token; - String lineToken = t.nextToken(); - int lineNumber = Integer.valueOf(lineToken).intValue(); - if (t.hasMoreTokens()) { - return null; - } - bpSpec = runtime.createSourceLineBreakpoint(sourceName, - lineNumber); - } else if ((rest != null) && rest.startsWith(":")) { - t = new StringTokenizer(rest.substring(1)); - String classId = token; - String lineToken = t.nextToken(); - int lineNumber = Integer.valueOf(lineToken).intValue(); - if (t.hasMoreTokens()) { - return null; - } - bpSpec = runtime.createClassLineBreakpoint(classId, lineNumber); - } else { - // Try stripping method from class.method token. - int idot = token.lastIndexOf('.'); - if ( (idot <= 0) || /* No dot or dot in first char */ - (idot >= token.length() - 1) ) { /* dot in last char */ - return null; - } - String methodName = token.substring(idot + 1); - String classId = token.substring(0, idot); - List argumentList = null; - if (rest != null) { - if (!rest.startsWith("(") || !rest.endsWith(")")) { - //### Should throw exception with error message - //out.println("Invalid method specification: " - // + methodName + rest); - return null; - } - // Trim the parens - //### What about spaces in arglist? - rest = rest.substring(1, rest.length() - 1); - argumentList = new ArrayList(); - t = new StringTokenizer(rest, ","); - while (t.hasMoreTokens()) { - argumentList.add(t.nextToken()); - } - } - bpSpec = runtime.createMethodBreakpoint(classId, - methodName, - argumentList); - } -// } catch (Exception e) { -// env.error("Exception attempting to create breakpoint: " + e); -// return null; -// } - return bpSpec; - } - - private void commandStop(StringTokenizer t) throws NoSessionException { - String token; - - if (!t.hasMoreTokens()) { - listEventRequests(); - } else { - token = t.nextToken(); - // Ignore optional "at" or "in" token. - // Allowed for backward compatibility. - if (token.equals("at") || token.equals("in")) { - if (t.hasMoreTokens()) { - token = t.nextToken(); - } else { - env.error("Missing breakpoint specification."); - return; - } - } - BreakpointSpec bpSpec = parseBreakpointSpec(token); - if (bpSpec != null) { - //### Add sanity-checks for deferred breakpoint. - runtime.install(bpSpec); - } else { - env.error("Ill-formed breakpoint specification."); - } - } - } - - private void commandClear(StringTokenizer t) throws NoSessionException { - if (!t.hasMoreTokens()) { - // Print set breakpoints - listEventRequests(); - return; - } - //### need 'clear all' - BreakpointSpec bpSpec = parseBreakpointSpec(t.nextToken()); - if (bpSpec != null) { - List specs = runtime.eventRequestSpecs(); - - if (specs.isEmpty()) { - env.notice("No breakpoints set."); - } else { - List toDelete = new ArrayList(); - for (EventRequestSpec spec : specs) { - if (spec.equals(bpSpec)) { - toDelete.add(spec); - } - } - // The request used for matching should be found - if (toDelete.size() <= 1) { - env.notice("No matching breakpoint set."); - } - for (EventRequestSpec spec : toDelete) { - runtime.delete(spec); - } - } - } else { - env.error("Ill-formed breakpoint specification."); - } - } - - // Command: list - - private void commandList(StringTokenizer t) throws NoSessionException { - ThreadReference current = context.getCurrentThread(); - if (current == null) { - env.error("No thread specified."); - return; - } - Location loc; - try { - StackFrame frame = context.getCurrentFrame(current); - if (frame == null) { - env.failure("Thread has not yet begun execution."); - return; - } - loc = frame.location(); - } catch (VMNotInterruptedException e) { - env.failure("Target VM must be in interrupted state."); - return; - } - SourceModel source = sourceManager.sourceForLocation(loc); - if (source == null) { - if (loc.method().isNative()) { - env.failure("Current method is native."); - return; - } - env.failure("No source available for " + Utils.locationString(loc) + "."); - return; - } - ReferenceType refType = loc.declaringType(); - int lineno = loc.lineNumber(); - if (t.hasMoreTokens()) { - String id = t.nextToken(); - // See if token is a line number. - try { - lineno = Integer.valueOf(id).intValue(); - } catch (NumberFormatException nfe) { - // It isn't -- see if it's a method name. - List meths = refType.methodsByName(id); - if (meths == null || meths.size() == 0) { - env.failure(id + - " is not a valid line number or " + - "method name for class " + - refType.name()); - return; - } else if (meths.size() > 1) { - env.failure(id + - " is an ambiguous method name in" + - refType.name()); - return; - } - loc = meths.get(0).location(); - lineno = loc.lineNumber(); - } - } - int startLine = (lineno > 4) ? lineno - 4 : 1; - int endLine = startLine + 9; - String sourceLine = source.sourceLine(lineno); - if (sourceLine == null) { - env.failure("" + - lineno + - " is an invalid line number for " + - refType.name()); - } else { - OutputSink out = env.getOutputSink(); - for (int i = startLine; i <= endLine; i++) { - sourceLine = source.sourceLine(i); - if (sourceLine == null) { - break; - } - out.print(i); - out.print("\t"); - if (i == lineno) { - out.print("=> "); - } else { - out.print(" "); - } - out.println(sourceLine); - } - out.show(); - } - } - - // Command: use - // Get or set the source file path list. - - private void commandUse(StringTokenizer t) { - if (!t.hasMoreTokens()) { - out.println(sourceManager.getSourcePath().asString()); - } else { - //### Should throw exception for invalid path. - //### E.g., vetoable property change. - sourceManager.setSourcePath(new SearchPath(t.nextToken())); - } - } - - // Command: sourcepath - // Get or set the source file path list. (Alternate to 'use'.) - - private void commandSourcepath(StringTokenizer t) { - if (!t.hasMoreTokens()) { - out.println(sourceManager.getSourcePath().asString()); - } else { - //### Should throw exception for invalid path. - //### E.g., vetoable property change. - sourceManager.setSourcePath(new SearchPath(t.nextToken())); - } - } - - // Command: classpath - // Get or set the class file path list. - - private void commandClasspath(StringTokenizer t) { - if (!t.hasMoreTokens()) { - out.println(classManager.getClassPath().asString()); - } else { - //### Should throw exception for invalid path. - //### E.g., vetoable property change. - classManager.setClassPath(new SearchPath(t.nextToken())); - } - } - - // Command: view - // Display source for source file or class. - - private void commandView(StringTokenizer t) throws NoSessionException { - if (!t.hasMoreTokens()) { - env.error("Argument required"); - } else { - String name = t.nextToken(); - if (name.endsWith(".java") || - name.indexOf(File.separatorChar) >= 0) { - env.viewSource(name); - } else { - //### JDI crashes taking line number for class. - /***** - ReferenceType cls = findClass(name); - if (cls != null) { - env.viewLocation(cls.location()); - } else { - env.failure("No such class"); - } - *****/ - String fileName = name.replace('.', File.separatorChar) + ".java"; - env.viewSource(fileName); - } - } - } - - // Command: locals - // Print all local variables in current stack frame. - - private void commandLocals() throws NoSessionException { - ThreadReference current = context.getCurrentThread(); - if (current == null) { - env.failure("No default thread specified: " + - "use the \"thread\" command first."); - return; - } - StackFrame frame; - try { - frame = context.getCurrentFrame(current); - if (frame == null) { - env.failure("Thread has not yet created any stack frames."); - return; - } - } catch (VMNotInterruptedException e) { - env.failure("Target VM must be in interrupted state."); - return; - } - - List vars; - try { - vars = frame.visibleVariables(); - if (vars == null || vars.size() == 0) { - env.failure("No local variables"); - return; - } - } catch (AbsentInformationException e) { - env.failure("Local variable information not available." + - " Compile with -g to generate variable information"); - return; - } - - OutputSink out = env.getOutputSink(); - out.println("Method arguments:"); - for (LocalVariable var : vars) { - if (var.isArgument()) { - printVar(out, var, frame); - } - } - out.println("Local variables:"); - for (LocalVariable var : vars) { - if (!var.isArgument()) { - printVar(out, var, frame); - } - } - out.show(); - return; - } - - /** - * Command: monitor - * Monitor an expression - */ - private void commandMonitor(StringTokenizer t) throws NoSessionException { - if (!t.hasMoreTokens()) { - env.error("Argument required"); - } else { - env.getMonitorListModel().add(t.nextToken("")); - } - } - - /** - * Command: unmonitor - * Unmonitor an expression - */ - private void commandUnmonitor(StringTokenizer t) throws NoSessionException { - if (!t.hasMoreTokens()) { - env.error("Argument required"); - } else { - env.getMonitorListModel().remove(t.nextToken("")); - } - } - - // Print a stack variable. - - private void printVar(OutputSink out, LocalVariable var, StackFrame frame) { - out.print(" " + var.name()); - if (var.isVisible(frame)) { - Value val = frame.getValue(var); - out.println(" = " + val.toString()); - } else { - out.println(" is not in scope"); - } - } - - // Command: print - // Evaluate an expression. - - private void commandPrint(StringTokenizer t, boolean dumpObject) throws NoSessionException { - if (!t.hasMoreTokens()) { - //### Probably confused if expresion contains whitespace. - env.error("No expression specified."); - return; - } - ThreadReference current = context.getCurrentThread(); - if (current == null) { - env.failure("No default thread specified: " + - "use the \"thread\" command first."); - return; - } - StackFrame frame; - try { - frame = context.getCurrentFrame(current); - if (frame == null) { - env.failure("Thread has not yet created any stack frames."); - return; - } - } catch (VMNotInterruptedException e) { - env.failure("Target VM must be in interrupted state."); - return; - } - while (t.hasMoreTokens()) { - String expr = t.nextToken(""); - Value val = null; - try { - val = runtime.evaluate(frame, expr); - } catch(Exception e) { - env.error("Exception: " + e); - //### Fix this! - } - if (val == null) { - return; // Error message already printed - } - OutputSink out = env.getOutputSink(); - if (dumpObject && (val instanceof ObjectReference) && - !(val instanceof StringReference)) { - ObjectReference obj = (ObjectReference)val; - ReferenceType refType = obj.referenceType(); - out.println(expr + " = " + val.toString() + " {"); - dump(out, obj, refType, refType); - out.println("}"); - } else { - out.println(expr + " = " + val.toString()); - } - out.show(); - } - } - - private void dump(OutputSink out, - ObjectReference obj, ReferenceType refType, - ReferenceType refTypeBase) { - for (Field field : refType.fields()) { - out.print(" "); - if (!refType.equals(refTypeBase)) { - out.print(refType.name() + "."); - } - out.print(field.name() + ": "); - Object o = obj.getValue(field); - out.println((o == null) ? "null" : o.toString()); // Bug ID 4374471 - } - if (refType instanceof ClassType) { - ClassType sup = ((ClassType)refType).superclass(); - if (sup != null) { - dump(out, obj, sup, refTypeBase); - } - } else if (refType instanceof InterfaceType) { - for (InterfaceType sup : ((InterfaceType)refType).superinterfaces()) { - dump(out, obj, sup, refTypeBase); - } - } - } - - /* - * Display help message. - */ - - private void help() { - out.println("** command list **"); - out.println("threads [threadgroup] -- list threads"); - out.println("thread -- set default thread"); - out.println("suspend [thread id(s)] -- suspend threads (default: all)"); - out.println("resume [thread id(s)] -- resume threads (default: all)"); - out.println("where [thread id] | all -- dump a thread's stack"); - out.println("wherei [thread id] | all -- dump a thread's stack, with pc info"); - out.println("threadgroups -- list threadgroups"); - out.println("threadgroup -- set current threadgroup\n"); -// out.println("print -- print value of expression"); - out.println("dump -- print all object information\n"); -// out.println("eval -- evaluate expression (same as print)"); - out.println("locals -- print all local variables in current stack frame\n"); - out.println("classes -- list currently known classes"); - out.println("methods -- list a class's methods\n"); - out.println("stop [in] .[(argument_type,...)] -- set a breakpoint in a method"); - out.println("stop [at] : -- set a breakpoint at a line"); - out.println("up [n frames] -- move up a thread's stack"); - out.println("down [n frames] -- move down a thread's stack"); - out.println("frame -- to a frame"); - out.println("clear .[(argument_type,...)] -- clear a breakpoint in a method"); - out.println("clear : -- clear a breakpoint at a line"); - out.println("clear -- list breakpoints"); - out.println("step -- execute current line"); - out.println("step up -- execute until the current method returns to its caller"); - out.println("stepi -- execute current instruction"); - out.println("next -- step one line (step OVER calls)"); - out.println("nexti -- step one instruction (step OVER calls)"); - out.println("cont -- continue execution from breakpoint\n"); -// out.println("catch -- break for the specified exception"); -// out.println("ignore -- ignore when the specified exception\n"); - out.println("view classname|filename -- display source file"); - out.println("list [line number|method] -- print source code context at line or method"); - out.println("use -- display or change the source path\n"); -//### new - out.println("sourcepath -- display or change the source path\n"); -//### new - out.println("classpath -- display or change the class path\n"); - out.println("monitor -- evaluate an expression each time the program stops\n"); - out.println("unmonitor -- delete a monitor\n"); - out.println("read -- read and execute a command file\n"); -// out.println("memory -- report memory usage"); -// out.println("gc -- free unused objects\n"); - out.println("run [args] -- start execution of a Java class"); - out.println("run -- re-execute last class run"); - out.println("load [args] -- start execution of a Java class, initially suspended"); - out.println("load -- re-execute last class run, initially suspended"); - out.println("attach -- debug existing process\n"); - out.println("detach -- detach from debuggee process\n"); - out.println("kill -- kill a thread or threadgroup\n"); - out.println("!! -- repeat last command"); - out.println("help (or ?) -- list commands"); - out.println("exit (or quit) -- exit debugger"); - } - - /* - * Execute a command. - */ - - public void executeCommand(String command) { - //### Treatment of 'out' here is dirty... - out = env.getOutputSink(); - if (echo) { - out.println(">>> " + command); - } - StringTokenizer t = new StringTokenizer(command); - try { - String cmd; - if (t.hasMoreTokens()) { - cmd = t.nextToken().toLowerCase(); - lastCommand = cmd; - } else { - cmd = lastCommand; - } - if (cmd.equals("print")) { - commandPrint(t, false); - } else if (cmd.equals("eval")) { - commandPrint(t, false); - } else if (cmd.equals("dump")) { - commandPrint(t, true); - } else if (cmd.equals("locals")) { - commandLocals(); - } else if (cmd.equals("classes")) { - commandClasses(); - } else if (cmd.equals("methods")) { - commandMethods(t); - } else if (cmd.equals("threads")) { - commandThreads(t); - } else if (cmd.equals("thread")) { - commandThread(t); - } else if (cmd.equals("suspend")) { - commandSuspend(t); - } else if (cmd.equals("resume")) { - commandResume(t); - } else if (cmd.equals("cont")) { - commandCont(); - } else if (cmd.equals("threadgroups")) { - commandThreadGroups(); - } else if (cmd.equals("threadgroup")) { - commandThreadGroup(t); - } else if (cmd.equals("run")) { - commandRun(t); - } else if (cmd.equals("load")) { - commandLoad(t); - } else if (cmd.equals("connect")) { - commandConnect(t); - } else if (cmd.equals("attach")) { - commandAttach(t); - } else if (cmd.equals("detach")) { - commandDetach(t); - } else if (cmd.equals("interrupt")) { - commandInterrupt(t); -//### Not implemented. -// } else if (cmd.equals("catch")) { -// commandCatchException(t); -//### Not implemented. -// } else if (cmd.equals("ignore")) { -// commandIgnoreException(t); - } else if (cmd.equals("step")) { - commandStep(t); - } else if (cmd.equals("stepi")) { - commandStepi(); - } else if (cmd.equals("next")) { - commandNext(); - } else if (cmd.equals("nexti")) { - commandNexti(); - } else if (cmd.equals("kill")) { - commandKill(t); - } else if (cmd.equals("where")) { - commandWhere(t, false); - } else if (cmd.equals("wherei")) { - commandWhere(t, true); - } else if (cmd.equals("up")) { - commandUp(t); - } else if (cmd.equals("down")) { - commandDown(t); - } else if (cmd.equals("frame")) { - commandFrame(t); - } else if (cmd.equals("stop")) { - commandStop(t); - } else if (cmd.equals("clear")) { - commandClear(t); - } else if (cmd.equals("list")) { - commandList(t); - } else if (cmd.equals("use")) { - commandUse(t); - } else if (cmd.equals("sourcepath")) { - commandSourcepath(t); - } else if (cmd.equals("classpath")) { - commandClasspath(t); - } else if (cmd.equals("monitor")) { - commandMonitor(t); - } else if (cmd.equals("unmonitor")) { - commandUnmonitor(t); - } else if (cmd.equals("view")) { - commandView(t); -// } else if (cmd.equals("read")) { -// readCommand(t); - } else if (cmd.equals("help") || cmd.equals("?")) { - help(); - } else if (cmd.equals("quit") || cmd.equals("exit")) { - try { - runtime.detach(); - } catch (NoSessionException e) { - // ignore - } - env.terminate(); - } else { - //### Dubious repeat-count feature inherited from 'jdb' - if (t.hasMoreTokens()) { - try { - int repeat = Integer.parseInt(cmd); - String subcom = t.nextToken(""); - while (repeat-- > 0) { - executeCommand(subcom); - } - return; - } catch (NumberFormatException exc) { - } - } - out.println("huh? Try help..."); - out.flush(); - } - } catch (NoSessionException e) { - out.println("There is no currently attached VM session."); - out.flush(); - } catch (Exception e) { - out.println("Internal exception: " + e.toString()); - out.flush(); - System.out.println("JDB internal exception: " + e.toString()); - e.printStackTrace(); - } - out.show(); - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/CommandTool.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/CommandTool.java deleted file mode 100644 index d010ec2f56b..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/CommandTool.java +++ /dev/null @@ -1,342 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.gui; - -import java.io.*; -import java.util.*; - -import javax.swing.*; -import java.awt.BorderLayout; -import java.awt.event.*; - -import com.sun.jdi.*; -import com.sun.jdi.event.*; - -import com.sun.tools.example.debug.bdi.*; -import com.sun.tools.example.debug.event.*; - -public class CommandTool extends JPanel { - - private static final long serialVersionUID = 8613516856378346415L; - - private Environment env; - - private ContextManager context; - private ExecutionManager runtime; - private SourceManager sourceManager; - - private TypeScript script; - - private static final String DEFAULT_CMD_PROMPT = "Command:"; - - public CommandTool(Environment env) { - - super(new BorderLayout()); - - this.env = env; - this.context = env.getContextManager(); - this.runtime = env.getExecutionManager(); - this.sourceManager = env.getSourceManager(); - - script = new TypeScript(DEFAULT_CMD_PROMPT, false); //no echo - this.add(script); - - final CommandInterpreter interpreter = - new CommandInterpreter(env); - - // Establish handler for incoming commands. - - script.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - interpreter.executeCommand(script.readln()); - } - }); - - // Establish ourselves as the listener for VM diagnostics. - - OutputListener diagnosticsListener = - new TypeScriptOutputListener(script, true); - runtime.addDiagnosticsListener(diagnosticsListener); - - // Establish ourselves as the shared debugger typescript. - - env.setTypeScript(new PrintWriter(new TypeScriptWriter(script))); - - // Handle VM events. - - TTYDebugListener listener = new TTYDebugListener(diagnosticsListener); - - runtime.addJDIListener(listener); - runtime.addSessionListener(listener); - runtime.addSpecListener(listener); - context.addContextListener(listener); - - //### remove listeners on exit! - - } - - private class TTYDebugListener implements - JDIListener, SessionListener, SpecListener, ContextListener { - - private OutputListener diagnostics; - - TTYDebugListener(OutputListener diagnostics) { - this.diagnostics = diagnostics; - } - - // JDIListener - - @Override - public void accessWatchpoint(AccessWatchpointEventSet e) { - setThread(e); - for (EventIterator it = e.eventIterator(); it.hasNext(); ) { - it.nextEvent(); - diagnostics.putString("Watchpoint hit: " + - locationString(e)); - } - } - - @Override - public void classPrepare(ClassPrepareEventSet e) { - if (context.getVerboseFlag()) { - String name = e.getReferenceType().name(); - diagnostics.putString("Class " + name + " loaded"); - } - } - - @Override - public void classUnload(ClassUnloadEventSet e) { - if (context.getVerboseFlag()) { - diagnostics.putString("Class " + e.getClassName() + - " unloaded."); - } - } - - @Override - public void exception(ExceptionEventSet e) { - setThread(e); - String name = e.getException().referenceType().name(); - diagnostics.putString("Exception: " + name); - } - - @Override - public void locationTrigger(LocationTriggerEventSet e) { - String locString = locationString(e); - setThread(e); - for (EventIterator it = e.eventIterator(); it.hasNext(); ) { - Event evt = it.nextEvent(); - if (evt instanceof BreakpointEvent) { - diagnostics.putString("Breakpoint hit: " + locString); - } else if (evt instanceof StepEvent) { - diagnostics.putString("Step completed: " + locString); - } else if (evt instanceof MethodEntryEvent) { - diagnostics.putString("Method entered: " + locString); - } else if (evt instanceof MethodExitEvent) { - diagnostics.putString("Method exited: " + locString); - } else { - diagnostics.putString("UNKNOWN event: " + e); - } - } - } - - @Override - public void modificationWatchpoint(ModificationWatchpointEventSet e) { - setThread(e); - for (EventIterator it = e.eventIterator(); it.hasNext(); ) { - it.nextEvent(); - diagnostics.putString("Watchpoint hit: " + - locationString(e)); - } - } - - @Override - public void threadDeath(ThreadDeathEventSet e) { - if (context.getVerboseFlag()) { - diagnostics.putString("Thread " + e.getThread() + - " ended."); - } - } - - @Override - public void threadStart(ThreadStartEventSet e) { - if (context.getVerboseFlag()) { - diagnostics.putString("Thread " + e.getThread() + - " started."); - } - } - - @Override - public void vmDeath(VMDeathEventSet e) { - script.setPrompt(DEFAULT_CMD_PROMPT); - diagnostics.putString("VM exited"); - } - - @Override - public void vmDisconnect(VMDisconnectEventSet e) { - script.setPrompt(DEFAULT_CMD_PROMPT); - diagnostics.putString("Disconnected from VM"); - } - - @Override - public void vmStart(VMStartEventSet e) { - script.setPrompt(DEFAULT_CMD_PROMPT); - diagnostics.putString("VM started"); - } - - // SessionListener - - @Override - public void sessionStart(EventObject e) {} - - @Override - public void sessionInterrupt(EventObject e) { - Thread.yield(); // fetch output - diagnostics.putString("VM interrupted by user."); - script.setPrompt(DEFAULT_CMD_PROMPT); - } - - @Override - public void sessionContinue(EventObject e) { - diagnostics.putString("Execution resumed."); - script.setPrompt(DEFAULT_CMD_PROMPT); - } - - // SpecListener - - @Override - public void breakpointSet(SpecEvent e) { - EventRequestSpec spec = e.getEventRequestSpec(); - diagnostics.putString("Breakpoint set at " + spec + "."); - } - @Override - public void breakpointDeferred(SpecEvent e) { - EventRequestSpec spec = e.getEventRequestSpec(); - diagnostics.putString("Breakpoint will be set at " + - spec + " when its class is loaded."); - } - @Override - public void breakpointDeleted(SpecEvent e) { - EventRequestSpec spec = e.getEventRequestSpec(); - diagnostics.putString("Breakpoint at " + spec.toString() + " deleted."); - } - @Override - public void breakpointResolved(SpecEvent e) { - EventRequestSpec spec = e.getEventRequestSpec(); - diagnostics.putString("Breakpoint resolved to " + spec.toString() + "."); - } - @Override - public void breakpointError(SpecErrorEvent e) { - EventRequestSpec spec = e.getEventRequestSpec(); - diagnostics.putString("Deferred breakpoint at " + - spec + " could not be resolved:" + - e.getReason()); - } - -//### Add info for watchpoints and exceptions - - @Override - public void watchpointSet(SpecEvent e) { - } - @Override - public void watchpointDeferred(SpecEvent e) { - } - @Override - public void watchpointDeleted(SpecEvent e) { - } - @Override - public void watchpointResolved(SpecEvent e) { - } - @Override - public void watchpointError(SpecErrorEvent e) { - } - - @Override - public void exceptionInterceptSet(SpecEvent e) { - } - @Override - public void exceptionInterceptDeferred(SpecEvent e) { - } - @Override - public void exceptionInterceptDeleted(SpecEvent e) { - } - @Override - public void exceptionInterceptResolved(SpecEvent e) { - } - @Override - public void exceptionInterceptError(SpecErrorEvent e) { - } - - - // ContextListener. - - // If the user selects a new current thread or frame, update prompt. - - @Override - public void currentFrameChanged(CurrentFrameChangedEvent e) { - // Update prompt only if affect thread is current. - ThreadReference thread = e.getThread(); - if (thread == context.getCurrentThread()) { - script.setPrompt(promptString(thread, e.getIndex())); - } - } - - } - - private String locationString(LocatableEventSet e) { - Location loc = e.getLocation(); - return "thread=\"" + e.getThread().name() + - "\", " + Utils.locationString(loc); - } - - private void setThread(LocatableEventSet e) { - if (!e.suspendedNone()) { - Thread.yield(); // fetch output - script.setPrompt(promptString(e.getThread(), 0)); - //### Current thread should be set elsewhere, e.g., - //### in ContextManager - //### context.setCurrentThread(thread); - } - } - - private String promptString(ThreadReference thread, int frameIndex) { - if (thread == null) { - return DEFAULT_CMD_PROMPT; - } else { - // Frame indices are presented to user as indexed from 1. - return (thread.name() + "[" + (frameIndex + 1) + "]:"); - } - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/ContextManager.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/ContextManager.java deleted file mode 100644 index fb2416789e8..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/ContextManager.java +++ /dev/null @@ -1,362 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.gui; - -import java.io.*; -import java.util.*; - -import com.sun.jdi.*; -import com.sun.tools.example.debug.event.*; -import com.sun.tools.example.debug.bdi.*; - -public class ContextManager { - - private ClassManager classManager; - private ExecutionManager runtime; - - private String mainClassName; - private String vmArguments; - private String commandArguments; - private String remotePort; - - private ThreadReference currentThread; - - private boolean verbose; - - private ArrayList contextListeners = new ArrayList(); - - public ContextManager(Environment env) { - classManager = env.getClassManager(); - runtime = env.getExecutionManager(); - mainClassName = ""; - vmArguments = ""; - commandArguments = ""; - currentThread = null; - - ContextManagerListener listener = new ContextManagerListener(); - runtime.addJDIListener(listener); - runtime.addSessionListener(listener); - } - - // Program execution defaults. - - //### Should there be change listeners for these? - //### They would be needed if we expected a dialog to be - //### synchronized with command input while it was open. - - public String getMainClassName() { - return mainClassName; - } - - public void setMainClassName(String mainClassName) { - this.mainClassName = mainClassName; - } - - public String getVmArguments() { - return processClasspathDefaults(vmArguments); - } - - public void setVmArguments(String vmArguments) { - this.vmArguments = vmArguments; - } - - public String getProgramArguments() { - return commandArguments; - } - - public void setProgramArguments(String commandArguments) { - this.commandArguments = commandArguments; - } - - public String getRemotePort() { - return remotePort; - } - - public void setRemotePort(String remotePort) { - this.remotePort = remotePort; - - } - - - // Miscellaneous debugger session preferences. - - public boolean getVerboseFlag() { - return verbose; - } - - public void setVerboseFlag(boolean verbose) { - this.verbose = verbose; - } - - - // Thread focus. - - public ThreadReference getCurrentThread() { - return currentThread; - } - - public void setCurrentThread(ThreadReference t) { - if (t != currentThread) { - currentThread = t; - notifyCurrentThreadChanged(t); - } - } - - public void setCurrentThreadInvalidate(ThreadReference t) { - currentThread = t; - notifyCurrentFrameChanged(runtime.threadInfo(t), - 0, true); - } - - public void invalidateCurrentThread() { - notifyCurrentFrameChanged(null, 0, true); - } - - - // If a view is displaying the current thread, it may - // choose to indicate which frame is current in the - // sense of the command-line UI. It may also "warp" the - // selection to that frame when changed by an 'up' or 'down' - // command. Hence, a notifier is provided. - - /****** - public int getCurrentFrameIndex() { - return getCurrentFrameIndex(currentThreadInfo); - } - ******/ - - public int getCurrentFrameIndex(ThreadReference t) { - return getCurrentFrameIndex(runtime.threadInfo(t)); - } - - //### Used in StackTraceTool. - public int getCurrentFrameIndex(ThreadInfo tinfo) { - if (tinfo == null) { - return 0; - } - Integer currentFrame = (Integer)tinfo.getUserObject(); - if (currentFrame == null) { - return 0; - } else { - return currentFrame.intValue(); - } - } - - public int moveCurrentFrameIndex(ThreadReference t, int count) throws VMNotInterruptedException { - return setCurrentFrameIndex(t,count, true); - } - - public int setCurrentFrameIndex(ThreadReference t, int newIndex) throws VMNotInterruptedException { - return setCurrentFrameIndex(t, newIndex, false); - } - - public int setCurrentFrameIndex(int newIndex) throws VMNotInterruptedException { - if (currentThread == null) { - return 0; - } else { - return setCurrentFrameIndex(currentThread, newIndex, false); - } - } - - private int setCurrentFrameIndex(ThreadReference t, int x, boolean relative) throws VMNotInterruptedException { - boolean sameThread = t.equals(currentThread); - ThreadInfo tinfo = runtime.threadInfo(t); - if (tinfo == null) { - return 0; - } - int maxIndex = tinfo.getFrameCount()-1; - int oldIndex = getCurrentFrameIndex(tinfo); - int newIndex = relative? oldIndex + x : x; - if (newIndex > maxIndex) { - newIndex = maxIndex; - } else if (newIndex < 0) { - newIndex = 0; - } - if (!sameThread || newIndex != oldIndex) { // don't recurse - setCurrentFrameIndex(tinfo, newIndex); - } - return newIndex - oldIndex; - } - - private void setCurrentFrameIndex(ThreadInfo tinfo, int index) { - tinfo.setUserObject(index); - //### In fact, the value may not have changed at this point. - //### We need to signal that the user attempted to change it, - //### however, so that the selection can be "warped" to the - //### current location. - notifyCurrentFrameChanged(tinfo.thread(), index); - } - - public StackFrame getCurrentFrame() throws VMNotInterruptedException { - return getCurrentFrame(runtime.threadInfo(currentThread)); - } - - public StackFrame getCurrentFrame(ThreadReference t) throws VMNotInterruptedException { - return getCurrentFrame(runtime.threadInfo(t)); - } - - public StackFrame getCurrentFrame(ThreadInfo tinfo) throws VMNotInterruptedException { - int index = getCurrentFrameIndex(tinfo); - try { - // It is possible, though unlikely, that the VM was interrupted - // before the thread created its Java stack. - return tinfo.getFrame(index); - } catch (FrameIndexOutOfBoundsException e) { - return null; - } - } - - public void addContextListener(ContextListener cl) { - contextListeners.add(cl); - } - - public void removeContextListener(ContextListener cl) { - contextListeners.remove(cl); - } - - //### These notifiers are fired only in response to USER-INITIATED changes - //### to the current thread and current frame. When the current thread is set automatically - //### after a breakpoint hit or step completion, no event is generated. Instead, - //### interested parties are expected to listen for the BreakpointHit and StepCompleted - //### events. This convention is unclean, and I believe that it reflects a defect in - //### in the current architecture. Unfortunately, however, we cannot guarantee the - //### order in which various listeners receive a given event, and the handlers for - //### the very same events that cause automatic changes to the current thread may also - //### need to know the current thread. - - private void notifyCurrentThreadChanged(ThreadReference t) { - ThreadInfo tinfo = null; - int index = 0; - if (t != null) { - tinfo = runtime.threadInfo(t); - index = getCurrentFrameIndex(tinfo); - } - notifyCurrentFrameChanged(tinfo, index, false); - } - - private void notifyCurrentFrameChanged(ThreadReference t, int index) { - notifyCurrentFrameChanged(runtime.threadInfo(t), - index, false); - } - - private void notifyCurrentFrameChanged(ThreadInfo tinfo, int index, - boolean invalidate) { - ArrayList l = new ArrayList(contextListeners); - CurrentFrameChangedEvent evt = - new CurrentFrameChangedEvent(this, tinfo, index, invalidate); - for (int i = 0; i < l.size(); i++) { - l.get(i).currentFrameChanged(evt); - } - } - - private class ContextManagerListener extends JDIAdapter - implements SessionListener, JDIListener { - - // SessionListener - - @Override - public void sessionStart(EventObject e) { - invalidateCurrentThread(); - } - - @Override - public void sessionInterrupt(EventObject e) { - setCurrentThreadInvalidate(currentThread); - } - - @Override - public void sessionContinue(EventObject e) { - invalidateCurrentThread(); - } - - // JDIListener - - @Override - public void locationTrigger(LocationTriggerEventSet e) { - setCurrentThreadInvalidate(e.getThread()); - } - - @Override - public void exception(ExceptionEventSet e) { - setCurrentThreadInvalidate(e.getThread()); - } - - @Override - public void vmDisconnect(VMDisconnectEventSet e) { - invalidateCurrentThread(); - } - - } - - - /** - * Add a -classpath argument to the arguments passed to the exec'ed - * VM with the contents of CLASSPATH environment variable, - * if -classpath was not already specified. - * - * @param javaArgs the arguments to the VM being exec'd that - * potentially has a user specified -classpath argument. - * @return a javaArgs whose -classpath option has been added - */ - - private String processClasspathDefaults(String javaArgs) { - if (javaArgs.indexOf("-classpath ") == -1) { - StringBuilder munged = new StringBuilder(javaArgs); - SearchPath classpath = classManager.getClassPath(); - if (classpath.isEmpty()) { - String envcp = System.getProperty("env.class.path"); - if ((envcp != null) && (envcp.length() > 0)) { - munged.append(" -classpath " + envcp); - } - } else { - munged.append(" -classpath " + classpath.asString()); - } - return munged.toString(); - } else { - return javaArgs; - } - } - - private String appendPath(String path1, String path2) { - if (path1 == null || path1.length() == 0) { - return path2 == null ? "." : path2; - } else if (path2 == null || path2.length() == 0) { - return path1; - } else { - return path1 + File.pathSeparator + path2; - } - } - -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/CurrentFrameChangedEvent.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/CurrentFrameChangedEvent.java deleted file mode 100644 index b933e758f38..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/CurrentFrameChangedEvent.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.gui; - -import com.sun.jdi.*; -import com.sun.tools.example.debug.bdi.*; -import java.util.EventObject; - -public class CurrentFrameChangedEvent extends EventObject { - - private static final long serialVersionUID = 4214479486546762179L; - private ThreadInfo tinfo; - private int index; - private boolean invalidate; - - public CurrentFrameChangedEvent(Object source, ThreadInfo tinfo, - int index, boolean invalidate) { - super(source); - this.tinfo = tinfo; - this.index = index; - this.invalidate = invalidate; - } - - public ThreadReference getThread() { - return tinfo == null? null : tinfo.thread(); - } - - public ThreadInfo getThreadInfo() { - return tinfo; - } - - public int getIndex() { - return index; - } - - public boolean getInvalidate() { - return invalidate; - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/Environment.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/Environment.java deleted file mode 100644 index b06ae4d6c79..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/Environment.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.gui; - -import java.io.*; -import com.sun.jdi.*; -import com.sun.tools.example.debug.bdi.*; - -public class Environment { - - private SourceManager sourceManager; - private ClassManager classManager; - private ContextManager contextManager; - private MonitorListModel monitorListModel; - private ExecutionManager runtime; - - private PrintWriter typeScript; - - private boolean verbose; - - public Environment() { - this.classManager = new ClassManager(this); - //### Order of the next three lines is important! (FIX THIS) - this.runtime = new ExecutionManager(); - this.sourceManager = new SourceManager(this); - this.contextManager = new ContextManager(this); - this.monitorListModel = new MonitorListModel(this); - } - - // Services used by debugging tools. - - public SourceManager getSourceManager() { - return sourceManager; - } - - public ClassManager getClassManager() { - return classManager; - } - - public ContextManager getContextManager() { - return contextManager; - } - - public MonitorListModel getMonitorListModel() { - return monitorListModel; - } - - public ExecutionManager getExecutionManager() { - return runtime; - } - - //### TODO: - //### Tools should attach/detach from environment - //### via a property, which should call an 'addTool' - //### method when set to maintain a registry of - //### tools for exit-time cleanup, etc. Tool - //### class constructors should be argument-free, so - //### that they may be instantiated by bean builders. - //### Will also need 'removeTool' in case property - //### value is changed. - // - // public void addTool(Tool t); - // public void removeTool(Tool t); - - public void terminate() { - System.exit(0); - } - - // public void refresh(); // notify all tools to refresh their views - - - // public void addStatusListener(StatusListener l); - // public void removeStatusListener(StatusListener l); - - // public void addOutputListener(OutputListener l); - // public void removeOutputListener(OutputListener l); - - public void setTypeScript(PrintWriter writer) { - typeScript = writer; - } - - public void error(String message) { - if (typeScript != null) { - typeScript.println(message); - } else { - System.out.println(message); - } - } - - public void failure(String message) { - if (typeScript != null) { - typeScript.println(message); - } else { - System.out.println(message); - } - } - - public void notice(String message) { - if (typeScript != null) { - typeScript.println(message); - } else { - System.out.println(message); - } - } - - public OutputSink getOutputSink() { - return new OutputSink(typeScript); - } - - public void viewSource(String fileName) { - //### HACK ### - //### Should use listener here. - com.sun.tools.example.debug.gui.GUI.srcTool.showSourceFile(fileName); - } - - public void viewLocation(Location locn) { - //### HACK ### - //### Should use listener here. - //### Should we use sourceForLocation here? - com.sun.tools.example.debug.gui.GUI.srcTool.showSourceForLocation(locn); - } - - //### Also in 'ContextManager'. Do we need both? - - public boolean getVerboseFlag() { - return verbose; - } - - public void setVerboseFlag(boolean verbose) { - this.verbose = verbose; - } - -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/GUI.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/GUI.java deleted file mode 100644 index eefbcfa7b61..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/GUI.java +++ /dev/null @@ -1,265 +0,0 @@ -/* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.debug.gui; - -import java.io.*; -import javax.swing.*; -import javax.swing.border.*; -import java.awt.*; -import java.awt.event.*; - -import com.sun.jdi.*; -import com.sun.tools.example.debug.bdi.*; - -public class GUI extends JPanel { - - private static final long serialVersionUID = 3292463234530679091L; - private CommandTool cmdTool; - private ApplicationTool appTool; - //###HACK## - //### There is currently dirty code in Environment that - //### accesses this directly. - //private SourceTool srcTool; - public static SourceTool srcTool; - - private SourceTreeTool sourceTreeTool; - private ClassTreeTool classTreeTool; - private ThreadTreeTool threadTreeTool; - private StackTraceTool stackTool; - private MonitorTool monitorTool; - - public static final String progname = "javadt"; - public static final String version = "1.0Beta"; //### FIX ME. - public static final String windowBanner = "Java(tm) platform Debug Tool"; - - private Font fixedFont = new Font("monospaced", Font.PLAIN, 10); - - private GUI(Environment env) { - setLayout(new BorderLayout()); - - setBorder(new EmptyBorder(5, 5, 5, 5)); - - add(new JDBToolBar(env), BorderLayout.NORTH); - - srcTool = new SourceTool(env); - srcTool.setPreferredSize(new java.awt.Dimension(500, 300)); - srcTool.setTextFont(fixedFont); - - stackTool = new StackTraceTool(env); - stackTool.setPreferredSize(new java.awt.Dimension(500, 100)); - - monitorTool = new MonitorTool(env); - monitorTool.setPreferredSize(new java.awt.Dimension(500, 50)); - - JSplitPane right = new JSplitPane(JSplitPane.VERTICAL_SPLIT, srcTool, - new JSplitPane(JSplitPane.VERTICAL_SPLIT, stackTool, monitorTool)); - - sourceTreeTool = new SourceTreeTool(env); - sourceTreeTool.setPreferredSize(new java.awt.Dimension(200, 450)); - - classTreeTool = new ClassTreeTool(env); - classTreeTool.setPreferredSize(new java.awt.Dimension(200, 450)); - - threadTreeTool = new ThreadTreeTool(env); - threadTreeTool.setPreferredSize(new java.awt.Dimension(200, 450)); - - JTabbedPane treePane = new JTabbedPane(SwingConstants.BOTTOM); - treePane.addTab("Source", null, sourceTreeTool); - treePane.addTab("Classes", null, classTreeTool); - treePane.addTab("Threads", null, threadTreeTool); - - JSplitPane centerTop = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treePane, right); - - cmdTool = new CommandTool(env); - cmdTool.setPreferredSize(new java.awt.Dimension(700, 150)); - - appTool = new ApplicationTool(env); - appTool.setPreferredSize(new java.awt.Dimension(700, 200)); - - JSplitPane centerBottom = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cmdTool, appTool); - // centerBottom.setPreferredSize(new java.awt.Dimension(700, 350)); - - JSplitPane center = new JSplitPane(JSplitPane.VERTICAL_SPLIT, centerTop, centerBottom); - - add(center, BorderLayout.CENTER); - - - } - - private static void usage() { - String separator = File.pathSeparator; - System.out.println("Usage: " + progname + " "); - System.out.println(); - System.out.println("where options include:"); - System.out.println(" -help print out this message and exit"); - System.out.println(" -sourcepath "); - System.out.println(" list directories in which to look for source files"); - System.out.println(" -remote :"); - System.out.println(" host machine and port number of interpreter to attach to"); - System.out.println(" -dbgtrace [flags] print info for debugging " + progname); - System.out.println(); - System.out.println("options forwarded to debuggee process:"); - System.out.println(" -v -verbose[:class|gc|jni]"); - System.out.println(" turn on verbose mode"); - System.out.println(" -D= set a system property"); - System.out.println(" -classpath "); - System.out.println(" list directories in which to look for classes"); - System.out.println(" -X

Example JDI Applications

-This example download contains the source code and -documentation for three applications written using -the JavaTM Debug Interface (JDI) -of the Java Platform Debugger Architecture (JPDA). -They are provided as educational tools and as starting -points for debugger development. -

-In increasing order of complexity: -

    -
  • Trace displays traces -of program execution. It is very simple (less than 600 lines) -yet uses most of the basic JDI functionality. It is a -good starting point. -
  • Jdb is the command line debugger -distributed with the J2SE SDK. -
  • Javadt is the beginnings of -a GUI debugger. -
-

-Trace is in the trace directory. -Jdb and Javadt share a package, and are under the -debug directory. - -

Required Set-up

- -

Where is JPDA?

-New versions of the J2SE SDK have JPDA included. For -older versions JPDA must be separately downloaded. -
-
SDKs with JPDA included -
J2SE SDK v1.3 and later and J2SE SDK for Linux v1.2.2 -
SDKs requiring JPDA download -
J2SE SDK v1.2.1 and v1.2.2 for Solaris and Windows -
Other SDKs -
Check with vendor -
-

-

Set-up for J2SE SDKs with JPDA included

-Your classpath must include the JDI Library code, which is -in tools.jar in the lib directory. -This is needed for both compiling the example code and -executing it. -

-

Set-up for J2SE SDKs without JPDA - Solaris

-Download JPDA v1.0 from -http://java.sun.com/products/jpda. Follow the -Installation Instructions -found there. Pay particular attention to setting the library -path. -

-Your classpath must include the JDI Library code, which is -in jpda_home/lib/tools.jar. -This is needed for both compiling the example code and -executing it. -

-

Set-up for J2SE SDKs without JPDA - Windows

-Download JPDA v1.0 from -http://java.sun.com/products/jpda. Follow the -Installation Instructions -found there. Be sure to add: -
-        jpda_home\bin
-
-to your path. -

-Your classpath must include the JDI Library code, which is -in jpda_home\lib\tools.jar. -This is needed for both compiling the example code and -executing it. -

-


-
java-debugger@java.sun.com
-

-

-

- - - diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/doc/javadt.html b/jdk/src/demo/share/jpda/com/sun/tools/example/doc/javadt.html deleted file mode 100644 index f9d28a166bb..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/doc/javadt.html +++ /dev/null @@ -1,174 +0,0 @@ - - - Release notes for the javadt debugger - - -

Release notes for the javadt debugger

- -

-As a demonstration of the - -JavaTM Platform Debugger Architecture -we are providing source code for -a simple GUI debugging tool - javadt. -It is included as an example and demonstration of - -JDI. It is not a finished or polished debugger and is -missing many features of importance for real debugging work. -

- -

Invoking javadt

-

-javadt can be run by executing: -

-   java com.sun.tools.example.debug.gui.GUI <options>.. <class-name>
-
-where <class-name> is the name you would normally -place on the java command line. -Note: the path to the JDI Library and to -the compiled javadt class files must be on the class path -used to invoke gui.GUI. -

-For example, you can invoke the javadt debugger as follows: -

-   java com.sun.tools.example.debug.gui.GUI -classpath . Hello
-
-Note: this -classpath option controls the -class path for the Hello application. -Once the window appears, you can issue the 'run' command to begin -execution immediately. It is also -possible to give the class name in the 'run' command, in -which case it may be omitted when invoking the debugger from the -shell. -

-The classpath may also be set from within the debugger, using the -'classpath' command. Currently, other arguments to the VM must be -given on the shell command line when the debugger is initially -invoked. The most recently mentioned classpath, VM arguments, main -class name, and program arguments are retained as defaults for later -'run' and 'load' commands. (Unfortunately, at present, the debugger -will likely crash if you attempt to begin another debugging session -with another debuggee process from within the same invocation of the -debugger. You should exit to the shell and start a new debugger -process.) -

- -

Using javadt

-The javadt normally displays context related to the "current thread", -that is, the thread that most recently encountered a breakpoint, threw -an uncaught exception, or was single-stepped by the user. When -program execution is suspended on account of one of these events, a -current thread exists, and the javadt displays the following information -about it: -

-

    -
  • A stack backtrace. - -
  • The source code surrounding the line corresponding to the - instruction counter for the thread, if the source code is - available. -
-

-In addition, a tabbed pane allows the user to view one of three -additional views: -

-

    -
  • A tree of all source files available on the source path. - -
  • A tree of all loaded class files, organized hierarchically - by package. - -
  • A tree of all active threads, organized hierarchically - by thread group. -
-

-By clicking on the name of a source file, the source view can be -directed to display it. Likewise, clicking on a thread will make that -thread the current thread. These features are normally used while the -program is suspended, e.g, at a breakpoint. Upon resumption and -encountering another breakpoint, for example, the current thread will -be automatically reset and the views will be updated. The views tile -the javadt display, and are adjustable in size. -

-The javadt functionality is rather basic, thus a command-line interaction -window is also provided that allows access to functions that are not -yet exposed in the javadt. In particular, it is necessary to use the -command line in order to set breakpoints and examine variables. The -javadt debugger command interpreter implements roughly a subset of the -jdb - functionality, but adds a few commands of its own. The -'help' command lists the complete set of commands and their function. -Shortcuts for a set of the most common commands is provided on a -button-bar at the top of the display. -

-The program to be debugged may be started either as a child of the -debugger, or the debugger can be attached to an existing process, -provided that its VM is prepared to accept the connection. If the -debuggee is started by the debugger as a child, a line-oriented -interface to its standard input, output, and error streams is provided -in an application interaction pane. -

-The debugger expects to find the program source code on its -sourcepath, set with the 'use' or 'sourcepath' command. If you find -that sources are not being displayed because the sourcepath is -incorrect, you may change it at that time, and the source view will be -immediately updated. -

-The message "No current thread" is often encountered when stepping -through a program. This message does not mean that the thread or -the VM has died, merely that a current thread is undefined. This -situation can easily occur unexpectedly when the program being -stepped is waiting, eg., for input. The VM appears to be stopped, -as it would be after the successful completion of a step, but it -is considered to be "running", not "interrupted". The prompt -in the command interaction pane indicates the state by changing -to a thread name and frame number when the VM is interrupted. -When it is running, the prompt "Command:" is displayed. -

-

Source for javadt

-Full source code for javadt is included under the -debug directory of examples.jar. -Note: these directories also include the -source for jdb. -Source code for these example applications is included to provide concrete -examples for debugger developers. Example code may be used, modified -and redistributed by debugger developers providing they adhere to the -terms in the COPYRIGHT notice. -

-javadt uses the following packages (found under the -debug directory): -

-
gui -
User interface code -
bdi -
Debugger core code -
events -
Event Set code -
expr -
Expression processing code -
-

-

Building javadt

-To build the javadt classes from the -provided source files under the debug directory, -you need only to compile them. No special -options are required, aside from those which set your classpath to -include the JDI Library. -

-

-However, if you want to modify the expression parser in the file -Expr.jj, you will need the - -JavaCC parser generator. -It is available free from -Metamata -(now part of WebGain). -

-


-
java-debugger@java.sun.com
-

-

-

- - diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/doc/jdb.html b/jdk/src/demo/share/jpda/com/sun/tools/example/doc/jdb.html deleted file mode 100644 index a8232b0207d..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/doc/jdb.html +++ /dev/null @@ -1,104 +0,0 @@ - - - Release notes for the jdb debugger - - -  - - - - - -
-
-

Release notes for the jdb debugger

-
- -

-Home Page - -

-As a demonstration of the - -JavaTM Platform Debugger Architecture -we are providing source code for the jdb debugger, which was -re-written to use - -JDI. - -

-

jdb man pages

-
-jdb man pages for Windows -

-jdb man pages for Solaris -

-

-

Invoking jdb

-The jdb sample can be started by executing: -
-   java com.sun.tools.example.debug.tty.TTY <options>.. <class-name>
-
-where <class-name> is the name you would normally -place on the java command line. The -help -option provides information on options. -

-

-Note: the path to the JDI Library and to -the compiled jdb class files must be on the class path -used to invoke com.sun.tools.example.debug.tty.TTY. - -

-For more information on invoking and connecting, refer to the - -Connection and Invocation Details section of the - -JPDA documentation, -particularly the section on jdb. -

- - -

Source for jdb

-Full source code for jdb is included under the -debug directory of examples.jar. -Note: these directories also include the -source for javadt. -Source code for these example applications is included to provide concrete -examples for debugger developers. Example code may be used, modified -and redistributed by debugger developers providing they adhere to the -terms in the COPYRIGHT notice. -

-jdb uses the following packages (found under the -debug directory): -

-
tty -
Application code -
expr -
Expression processing code -
- -

-

Building jdb

-To completely rebuild the jdb classes from the -provided source files under the debug directory, -you need only to compile them. No special -options are required, aside from those which set your classpath to -include the JDI Library. -

-

-However, if you want to modify the expression parser in the file -Expr.jj, you will need the - -JavaCC parser generator. -It is available free from -Metamata -(now part of WebGain). -

-


-
java-debugger@java.sun.com
-

-

-

- - diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/doc/trace.html b/jdk/src/demo/share/jpda/com/sun/tools/example/doc/trace.html deleted file mode 100644 index 8cae84dfe1e..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/doc/trace.html +++ /dev/null @@ -1,71 +0,0 @@ - - - - trace example - - -

trace example

- -Trace runs the Java language program passed as an argument and -generates a trace of its execution. Trace is a simple command -line tool that uses the - -Java Debug Interface (JDI). Programs need -not be compiled for debugging since this information is not -used. -

-Trace can be invoked as follows: -

-        java com.sun.tools.example.trace.Trace options class args
-
-Your classpath must include the JDI Library -(see set-up), -the path to the compiled trace class files, -and the path for the application being traced. -

-Available options are: - -

-  -output filename   
-        Set destination for output trace. By default output
-        goes to the terminal.
-
-  -all                 
-        Include system classes in output.  By default
-        java.*, javax.*, sun.* and com.sun.* events are
-        not diplayed.
-
-  -fields
-        Also show assignments into fields.
-
-  -help              
-        Print a help message
-
-
-class is the program to trace. args are the arguments to class. -

- -

Source for trace

-Full source code for trace is included in the -trace directory of examples.jar. -Source code for these example applications is included to provide concrete -examples for debugger developers. Example code may be used, modified -and redistributed by debugger developers providing they adhere to the -terms in the COPYRIGHT notice. - -

-

Building trace

-To completely rebuild the trace classes from the -provided source files in the trace directory, -you need only to compile them. No special -options are required, aside from those which set your classpath to -include the JDI Library. - -

-


-
java-debugger@java.sun.com
-

-

-

- - diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/trace/EventThread.java b/jdk/src/demo/share/jpda/com/sun/tools/example/trace/EventThread.java deleted file mode 100644 index 11084df5dd2..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/trace/EventThread.java +++ /dev/null @@ -1,353 +0,0 @@ -/* - * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.trace; - -import com.sun.jdi.*; -import com.sun.jdi.request.*; -import com.sun.jdi.event.*; - -import java.util.*; -import java.io.PrintWriter; - -/** - * This class processes incoming JDI events and displays them - * - * @author Robert Field - */ -public class EventThread extends Thread { - - private final VirtualMachine vm; // Running VM - private final String[] excludes; // Packages to exclude - private final PrintWriter writer; // Where output goes - - static String nextBaseIndent = ""; // Starting indent for next thread - - private boolean connected = true; // Connected to VM - private boolean vmDied = true; // VMDeath occurred - - // Maps ThreadReference to ThreadTrace instances - private Map traceMap = - new HashMap<>(); - - EventThread(VirtualMachine vm, String[] excludes, PrintWriter writer) { - super("event-handler"); - this.vm = vm; - this.excludes = excludes; - this.writer = writer; - } - - /** - * Run the event handling thread. - * As long as we are connected, get event sets off - * the queue and dispatch the events within them. - */ - @Override - public void run() { - EventQueue queue = vm.eventQueue(); - while (connected) { - try { - EventSet eventSet = queue.remove(); - EventIterator it = eventSet.eventIterator(); - while (it.hasNext()) { - handleEvent(it.nextEvent()); - } - eventSet.resume(); - } catch (InterruptedException exc) { - // Ignore - } catch (VMDisconnectedException discExc) { - handleDisconnectedException(); - break; - } - } - } - - /** - * Create the desired event requests, and enable - * them so that we will get events. - * @param excludes Class patterns for which we don't want events - * @param watchFields Do we want to watch assignments to fields - */ - void setEventRequests(boolean watchFields) { - EventRequestManager mgr = vm.eventRequestManager(); - - // want all exceptions - ExceptionRequest excReq = mgr.createExceptionRequest(null, - true, true); - // suspend so we can step - excReq.setSuspendPolicy(EventRequest.SUSPEND_ALL); - excReq.enable(); - - MethodEntryRequest menr = mgr.createMethodEntryRequest(); - for (int i=0; i 0) { - indent.append("| "); - } - - EventRequestManager mgr = vm.eventRequestManager(); - mgr.deleteEventRequest(event.request()); - } - - void threadDeathEvent(ThreadDeathEvent event) { - indent = new StringBuffer(baseIndent); - println("====== " + thread.name() + " end ======"); - } - } - - /** - * Returns the ThreadTrace instance for the specified thread, - * creating one if needed. - */ - ThreadTrace threadTrace(ThreadReference thread) { - ThreadTrace trace = traceMap.get(thread); - if (trace == null) { - trace = new ThreadTrace(thread); - traceMap.put(thread, trace); - } - return trace; - } - - /** - * Dispatch incoming events - */ - private void handleEvent(Event event) { - if (event instanceof ExceptionEvent) { - exceptionEvent((ExceptionEvent)event); - } else if (event instanceof ModificationWatchpointEvent) { - fieldWatchEvent((ModificationWatchpointEvent)event); - } else if (event instanceof MethodEntryEvent) { - methodEntryEvent((MethodEntryEvent)event); - } else if (event instanceof MethodExitEvent) { - methodExitEvent((MethodExitEvent)event); - } else if (event instanceof StepEvent) { - stepEvent((StepEvent)event); - } else if (event instanceof ThreadDeathEvent) { - threadDeathEvent((ThreadDeathEvent)event); - } else if (event instanceof ClassPrepareEvent) { - classPrepareEvent((ClassPrepareEvent)event); - } else if (event instanceof VMStartEvent) { - vmStartEvent((VMStartEvent)event); - } else if (event instanceof VMDeathEvent) { - vmDeathEvent((VMDeathEvent)event); - } else if (event instanceof VMDisconnectEvent) { - vmDisconnectEvent((VMDisconnectEvent)event); - } else { - throw new Error("Unexpected event type"); - } - } - - /*** - * A VMDisconnectedException has happened while dealing with - * another event. We need to flush the event queue, dealing only - * with exit events (VMDeath, VMDisconnect) so that we terminate - * correctly. - */ - synchronized void handleDisconnectedException() { - EventQueue queue = vm.eventQueue(); - while (connected) { - try { - EventSet eventSet = queue.remove(); - EventIterator iter = eventSet.eventIterator(); - while (iter.hasNext()) { - Event event = iter.nextEvent(); - if (event instanceof VMDeathEvent) { - vmDeathEvent((VMDeathEvent)event); - } else if (event instanceof VMDisconnectEvent) { - vmDisconnectEvent((VMDisconnectEvent)event); - } - } - eventSet.resume(); // Resume the VM - } catch (InterruptedException exc) { - // ignore - } - } - } - - private void vmStartEvent(VMStartEvent event) { - writer.println("-- VM Started --"); - } - - // Forward event for thread specific processing - private void methodEntryEvent(MethodEntryEvent event) { - threadTrace(event.thread()).methodEntryEvent(event); - } - - // Forward event for thread specific processing - private void methodExitEvent(MethodExitEvent event) { - threadTrace(event.thread()).methodExitEvent(event); - } - - // Forward event for thread specific processing - private void stepEvent(StepEvent event) { - threadTrace(event.thread()).stepEvent(event); - } - - // Forward event for thread specific processing - private void fieldWatchEvent(ModificationWatchpointEvent event) { - threadTrace(event.thread()).fieldWatchEvent(event); - } - - void threadDeathEvent(ThreadDeathEvent event) { - ThreadTrace trace = traceMap.get(event.thread()); - if (trace != null) { // only want threads we care about - trace.threadDeathEvent(event); // Forward event - } - } - - /** - * A new class has been loaded. - * Set watchpoints on each of its fields - */ - private void classPrepareEvent(ClassPrepareEvent event) { - EventRequestManager mgr = vm.eventRequestManager(); - List fields = event.referenceType().visibleFields(); - for (Field field : fields) { - ModificationWatchpointRequest req = - mgr.createModificationWatchpointRequest(field); - for (int i=0; i= 0) { - out.write(cbuf, 0, count); - } - out.flush(); - } catch(IOException exc) { - System.err.println("Child I/O Transfer - " + exc); - } - } -} diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/trace/Trace.java b/jdk/src/demo/share/jpda/com/sun/tools/example/trace/Trace.java deleted file mode 100644 index 2ce99f97a01..00000000000 --- a/jdk/src/demo/share/jpda/com/sun/tools/example/trace/Trace.java +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. - * 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 source code is provided to illustrate the usage of a given feature - * or technique and has been deliberately simplified. Additional steps - * required for a production-quality application, such as security checks, - * input validation and proper error handling, might not be present in - * this sample code. - */ - - -package com.sun.tools.example.trace; - -import com.sun.jdi.VirtualMachine; -import com.sun.jdi.Bootstrap; -import com.sun.jdi.connect.*; - -import java.util.Map; -import java.util.List; - -import java.io.PrintWriter; -import java.io.FileWriter; -import java.io.IOException; - -/** - * This program traces the execution of another program. - * See "java Trace -help". - * It is a simple example of the use of the Java Debug Interface. - * - * @author Robert Field - */ -public class Trace { - - // Running remote VM - private final VirtualMachine vm; - - // Thread transferring remote error stream to our error stream - private Thread errThread = null; - - // Thread transferring remote output stream to our output stream - private Thread outThread = null; - - // Mode for tracing the Trace program (default= 0 off) - private int debugTraceMode = 0; - - // Do we want to watch assignments to fields - private boolean watchFields = false; - - // Class patterns for which we don't want events - private String[] excludes = {"java.*", "javax.*", "sun.*", - "com.sun.*"}; - - /** - * main - */ - public static void main(String[] args) { - new Trace(args); - } - - /** - * Parse the command line arguments. - * Launch target VM. - * Generate the trace. - */ - Trace(String[] args) { - PrintWriter writer = new PrintWriter(System.out); - int inx; - for (inx = 0; inx < args.length; ++inx) { - String arg = args[inx]; - if (arg.charAt(0) != '-') { - break; - } - if (arg.equals("-output")) { - try { - writer = new PrintWriter(new FileWriter(args[++inx])); - } catch (IOException exc) { - System.err.println("Cannot open output file: " + args[inx] - + " - " + exc); - System.exit(1); - } - } else if (arg.equals("-all")) { - excludes = new String[0]; - } else if (arg.equals("-fields")) { - watchFields = true; - } else if (arg.equals("-dbgtrace")) { - debugTraceMode = Integer.parseInt(args[++inx]); - } else if (arg.equals("-help")) { - usage(); - System.exit(0); - } else { - System.err.println("No option: " + arg); - usage(); - System.exit(1); - } - } - if (inx >= args.length) { - System.err.println(" missing"); - usage(); - System.exit(1); - } - StringBuilder sb = new StringBuilder(); - sb.append(args[inx]); - for (++inx; inx < args.length; ++inx) { - sb.append(' '); - sb.append(args[inx]); - } - vm = launchTarget(sb.toString()); - generateTrace(writer); - } - - - /** - * Generate the trace. - * Enable events, start thread to display events, - * start threads to forward remote error and output streams, - * resume the remote VM, wait for the final event, and shutdown. - */ - void generateTrace(PrintWriter writer) { - vm.setDebugTraceMode(debugTraceMode); - EventThread eventThread = new EventThread(vm, excludes, writer); - eventThread.setEventRequests(watchFields); - eventThread.start(); - redirectOutput(); - vm.resume(); - - // Shutdown begins when event thread terminates - try { - eventThread.join(); - errThread.join(); // Make sure output is forwarded - outThread.join(); // before we exit - } catch (InterruptedException exc) { - // we don't interrupt - } - writer.close(); - } - - /** - * Launch target VM. - * Forward target's output and error. - */ - VirtualMachine launchTarget(String mainArgs) { - LaunchingConnector connector = findLaunchingConnector(); - Map arguments = - connectorArguments(connector, mainArgs); - try { - return connector.launch(arguments); - } catch (IOException exc) { - throw new Error("Unable to launch target VM: " + exc); - } catch (IllegalConnectorArgumentsException exc) { - throw new Error("Internal error: " + exc); - } catch (VMStartException exc) { - throw new Error("Target VM failed to initialize: " + - exc.getMessage()); - } - } - - void redirectOutput() { - Process process = vm.process(); - - // Copy target's output and error to our output and error. - errThread = new StreamRedirectThread("error reader", - process.getErrorStream(), - System.err); - outThread = new StreamRedirectThread("output reader", - process.getInputStream(), - System.out); - errThread.start(); - outThread.start(); - } - - /** - * Find a com.sun.jdi.CommandLineLaunch connector - */ - LaunchingConnector findLaunchingConnector() { - List connectors = Bootstrap.virtualMachineManager().allConnectors(); - for (Connector connector : connectors) { - if (connector.name().equals("com.sun.jdi.CommandLineLaunch")) { - return (LaunchingConnector)connector; - } - } - throw new Error("No launching connector"); - } - - /** - * Return the launching connector's arguments. - */ - Map connectorArguments(LaunchingConnector connector, String mainArgs) { - Map arguments = connector.defaultArguments(); - Connector.Argument mainArg = - (Connector.Argument)arguments.get("main"); - if (mainArg == null) { - throw new Error("Bad launching connector"); - } - mainArg.setValue(mainArgs); - - if (watchFields) { - // We need a VM that supports watchpoints - Connector.Argument optionArg = - (Connector.Argument)arguments.get("options"); - if (optionArg == null) { - throw new Error("Bad launching connector"); - } - optionArg.setValue("-classic"); - } - return arguments; - } - - /** - * Print command line usage help - */ - void usage() { - System.err.println("Usage: java Trace "); - System.err.println(" are:"); - System.err.println( -" -output Output trace to "); - System.err.println( -" -all Include system classes in output"); - System.err.println( -" -help Print this help message"); - System.err.println(" is the program to trace"); - System.err.println(" are the arguments to "); - } -} diff --git a/jdk/src/demo/share/jvmti/hprof/sample.makefile.txt b/jdk/src/demo/share/jvmti/hprof/sample.makefile.txt deleted file mode 100644 index e8f84dc8577..00000000000 --- a/jdk/src/demo/share/jvmti/hprof/sample.makefile.txt +++ /dev/null @@ -1,205 +0,0 @@ -# -# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# - Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# - Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# - Neither the name of Oracle nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -######################################################################## -# -# Sample GNU Makefile for building -# -# Example uses: -# gnumake JDK= OSNAME=solaris [OPT=true] [LIBARCH=sparc] -# gnumake JDK= OSNAME=solaris [OPT=true] [LIBARCH=sparcv9] -# gnumake JDK= OSNAME=linux [OPT=true] -# gnumake JDK= OSNAME=win32 [OPT=true] -# -######################################################################## - -# Source lists -LIBNAME=hprof -SOURCES= \ - debug_malloc.c \ - hprof_blocks.c \ - hprof_class.c \ - hprof_cpu.c \ - hprof_error.c \ - hprof_event.c \ - hprof_frame.c \ - hprof_init.c \ - hprof_io.c \ - hprof_ioname.c \ - hprof_listener.c \ - hprof_loader.c \ - hprof_monitor.c \ - hprof_object.c \ - hprof_reference.c \ - hprof_site.c \ - hprof_stack.c \ - hprof_string.c \ - hprof_table.c \ - hprof_tag.c \ - hprof_tls.c \ - hprof_trace.c \ - hprof_tracker.c \ - hprof_util.c \ - hprof_md.c - -JAVA_SOURCES=Tracker.java - -# Name of jar file that needs to be created -#JARFILE=hprof.jar - -# Solaris Sun C Compiler Version 5.5 -ifeq ($(OSNAME), solaris) - # Sun Solaris Compiler options needed - COMMON_FLAGS=-mt -KPIC - # Options that help find errors - COMMON_FLAGS+= -Xa -v -xstrconst -xc99=%none - # To make hprof logging code available - COMMON_FLAGS+= -DHPROF_LOGGING - # Check LIBARCH for any special compiler options - LIBARCH=$(shell uname -p) - ifeq ($(LIBARCH), sparc) - COMMON_FLAGS+=-xarch=v8 -xregs=no%appl - endif - ifeq ($(LIBARCH), sparcv9) - COMMON_FLAGS+=-xarch=v9 -xregs=no%appl - endif - ifeq ($(OPT), true) - CFLAGS=-xO2 $(COMMON_FLAGS) -DNDEBUG - else - CFLAGS=-g $(COMMON_FLAGS) -DDEBUG - endif - # Object files needed to create library - OBJECTS=$(SOURCES:%.c=%.o) - # Library name and options needed to build it - LIBRARY=lib$(LIBNAME).so - LDFLAGS=-z defs -ztext - # Libraries we are dependent on - LIBRARIES=-lsocket -lnsl -ldl -lc - # Building a shared library - LINK_SHARED=$(LINK.c) -G -o $@ -endif - -# Linux GNU C Compiler -ifeq ($(OSNAME), linux) - # GNU Compiler options needed to build it - COMMON_FLAGS=-fno-strict-aliasing -fPIC -fno-omit-frame-pointer - # Options that help find errors - COMMON_FLAGS+= -W -Wall -Wno-unused -Wno-parentheses - # To allow access to dladdr() - COMMON_FLAGS+= -D_GNU_SOURCE - # To prevent include of procfs.h - COMMON_FLAGS+= -DLINUX - # To make sure code is reentrant - COMMON_FLAGS+= -D_REENTRANT - # To make hprof logging code available - COMMON_FLAGS+= -DHPROF_LOGGING - ifeq ($(OPT), true) - CFLAGS=-O2 $(COMMON_FLAGS) -DNDEBUG - else - CFLAGS=-g $(COMMON_FLAGS) -DDEBUG - endif - # Object files needed to create library - OBJECTS=$(SOURCES:%.c=%.o) - # Library name and options needed to build it - LIBRARY=lib$(LIBNAME).so - LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc - # Libraries we are dependent on - LIBRARIES= -ldl -lc - # Building a shared library - LINK_SHARED=$(LINK.c) -shared -o $@ -endif - -# Windows Microsoft C/C++ Optimizing Compiler Version 12 -ifeq ($(OSNAME), win32) - CC=cl - # Compiler options needed to build it - COMMON_FLAGS=-Gy -DWIN32 - # Options that help find errors - COMMON_FLAGS+=-W0 -WX - # To make hprof logging code available - COMMON_FLAGS+= -DHPROF_LOGGING - ifeq ($(OPT), true) - CFLAGS= -Ox -Op -Zi $(COMMON_FLAGS) -DNDEBUG - else - CFLAGS= -Od -Zi $(COMMON_FLAGS) -DDEBUG - endif - # Add java_crw_demo source - SOURCES += ../java_crw_demo.c - # Object files needed to create library - OBJECTS=$(SOURCES:%.c=%.obj) - # Library name and options needed to build it - LIBRARY=$(LIBNAME).dll - LDFLAGS= - # Libraries we are dependent on - LIBRARIES=wsock32.lib winmm.lib - # Building a shared library - LINK_SHARED=link -dll -out:$@ -endif - -# Common -I options -CFLAGS += -I. -CFLAGS += -I../java_crw_demo -CFLAGS += -I$(JDK)/include -I$(JDK)/include/$(OSNAME) - -# Default rule (build both native library and jar file) -all: hprof_md.c $(LIBRARY) $(JARFILE) - -# Get platform specific hprof_md.c -hprof_md.c: - rm -f $@ - cp $(OSNAME)/hprof_md.c $@ - -# Build native library -$(LIBRARY): $(OBJECTS) - $(LINK_SHARED) $(OBJECTS) $(LIBRARIES) - -# Build jar file -$(JARFILE): $(JAVA_SOURCES) - rm -f -r classes - mkdir -p classes - $(JDK)/bin/javac -d classes $(JAVA_SOURCES) - (cd classes; $(JDK)/bin/jar cf ../$@ *) - -# Cleanup the built bits -clean: - rm -f -r classes - rm -f $(LIBRARY) $(JARFILE) $(OBJECTS) - -# Simple tester -test: all - LD_LIBRARY_PATH=. $(JDK)/bin/java -agentlib:$(LIBNAME) -Xbootclasspath/a:./$(JARFILE) -version - -# Compilation rule only needed on Windows -ifeq ($(OSNAME), win32) -%.obj: %.c - $(COMPILE.c) $< -endif - diff --git a/jdk/src/demo/share/jvmti/index.html b/jdk/src/demo/share/jvmti/index.html index b66ac8d9bfa..4b479c12468 100644 --- a/jdk/src/demo/share/jvmti/index.html +++ b/jdk/src/demo/share/jvmti/index.html @@ -54,17 +54,16 @@ variable (Windows). This is system and platform specific. If you are using 64bit Solaris (e.g. 'java -d64'), you should use LD_LIBRARY_PATH64. -Some agents such as hprof (heap/cpu profiler) and jdwp (debugger backend) +Some agents such as the jdwp (debugger backend) are located inside the primary JDK directories and will always be found in those locations.

The agents that instrument classfiles (i.e. BCI, usually through the java_crw_demo library) -such as hprof, heapTracker, mtrace, and minst, +such as heapTracker, mtrace, and minst, also need to have the Java classes they use available in the bootclasspath. -The one used by hprof is already in the bootclasspath, and the -other agents will make attempts at automatically adding their jar file +The agents will make attempts at automatically adding their jar file (e.g. heapTracker.jar, mtrace.jar, or minst.jar) to the bootclasspath with AddToBootstrapClassLoaderSearch from JVM TI at startup (see the agent_util code). @@ -150,19 +149,6 @@ This is a small agent that gets information about threads waiting on monitors. -

  • -hprof -
    -This is a large agent that does heap and cpu profiling. -This demo agent is actually built into the - -Java Runtime Environment (JRE). -It uses Bytecode Instrumentation (BCI) via the java_crw_demo library. -
    -Note: hprof is NOT a small or simple agent, the other smaller demos -should be looked at first. -
  • - diff --git a/jdk/src/java.base/share/classes/java/io/ByteArrayOutputStream.java b/jdk/src/java.base/share/classes/java/io/ByteArrayOutputStream.java index 71be2db3b47..3d199579249 100644 --- a/jdk/src/java.base/share/classes/java/io/ByteArrayOutputStream.java +++ b/jdk/src/java.base/share/classes/java/io/ByteArrayOutputStream.java @@ -93,6 +93,14 @@ public class ByteArrayOutputStream extends OutputStream { grow(minCapacity); } + /** + * The maximum size of array to allocate. + * Some VMs reserve some header words in an array. + * Attempts to allocate larger arrays may result in + * OutOfMemoryError: Requested array size exceeds VM limit + */ + private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8; + /** * Increases the capacity to ensure that it can hold at least the * number of elements specified by the minimum capacity argument. @@ -105,14 +113,19 @@ public class ByteArrayOutputStream extends OutputStream { int newCapacity = oldCapacity << 1; if (newCapacity - minCapacity < 0) newCapacity = minCapacity; - if (newCapacity < 0) { - if (minCapacity < 0) // overflow - throw new OutOfMemoryError(); - newCapacity = Integer.MAX_VALUE; - } + if (newCapacity - MAX_ARRAY_SIZE > 0) + newCapacity = hugeCapacity(minCapacity); buf = Arrays.copyOf(buf, newCapacity); } + private static int hugeCapacity(int minCapacity) { + if (minCapacity < 0) // overflow + throw new OutOfMemoryError(); + return (minCapacity > MAX_ARRAY_SIZE) ? + Integer.MAX_VALUE : + MAX_ARRAY_SIZE; + } + /** * Writes the specified byte to this byte array output stream. * diff --git a/jdk/src/java.base/share/classes/java/io/FileInputStream.java b/jdk/src/java.base/share/classes/java/io/FileInputStream.java index 6f13156bf98..b501b45707f 100644 --- a/jdk/src/java.base/share/classes/java/io/FileInputStream.java +++ b/jdk/src/java.base/share/classes/java/io/FileInputStream.java @@ -184,7 +184,16 @@ class FileInputStream extends InputStream * Opens the specified file for reading. * @param name the name of the file */ - private native void open(String name) throws FileNotFoundException; + private native void open0(String name) throws FileNotFoundException; + + // wrap native call to allow instrumentation + /** + * Opens the specified file for reading. + * @param name the name of the file + */ + private void open(String name) throws FileNotFoundException { + open0(name); + } /** * Reads a byte of data from this input stream. This method blocks diff --git a/jdk/src/java.base/share/classes/java/io/FileOutputStream.java b/jdk/src/java.base/share/classes/java/io/FileOutputStream.java index 1f7cff54cfa..281a695e6df 100644 --- a/jdk/src/java.base/share/classes/java/io/FileOutputStream.java +++ b/jdk/src/java.base/share/classes/java/io/FileOutputStream.java @@ -256,9 +256,20 @@ class FileOutputStream extends OutputStream * @param name name of file to be opened * @param append whether the file is to be opened in append mode */ - private native void open(String name, boolean append) + private native void open0(String name, boolean append) throws FileNotFoundException; + // wrap native call to allow instrumentation + /** + * Opens a file, with the specified name, for overwriting or appending. + * @param name name of file to be opened + * @param append whether the file is to be opened in append mode + */ + private void open(String name, boolean append) + throws FileNotFoundException { + open0(name, append); + } + /** * Writes the specified byte to this file output stream. * diff --git a/jdk/src/java.base/share/classes/java/io/FilePermission.java b/jdk/src/java.base/share/classes/java/io/FilePermission.java index 0744ea28e4a..b008d4f933a 100644 --- a/jdk/src/java.base/share/classes/java/io/FilePermission.java +++ b/jdk/src/java.base/share/classes/java/io/FilePermission.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -31,6 +31,7 @@ import java.util.List; import java.util.ArrayList; import java.util.Vector; import java.util.Collections; +import java.util.StringJoiner; import sun.security.util.SecurityConstants; /** @@ -556,39 +557,25 @@ public final class FilePermission extends Permission implements Serializable { * @return the canonical string representation of the actions. */ private static String getActions(int mask) { - StringBuilder sb = new StringBuilder(); - boolean comma = false; + StringJoiner sj = new StringJoiner(","); if ((mask & READ) == READ) { - comma = true; - sb.append("read"); + sj.add("read"); } - if ((mask & WRITE) == WRITE) { - if (comma) sb.append(','); - else comma = true; - sb.append("write"); + sj.add("write"); } - if ((mask & EXECUTE) == EXECUTE) { - if (comma) sb.append(','); - else comma = true; - sb.append("execute"); + sj.add("execute"); } - if ((mask & DELETE) == DELETE) { - if (comma) sb.append(','); - else comma = true; - sb.append("delete"); + sj.add("delete"); } - if ((mask & READLINK) == READLINK) { - if (comma) sb.append(','); - else comma = true; - sb.append("readlink"); + sj.add("readlink"); } - return sb.toString(); + return sj.toString(); } /** diff --git a/jdk/src/java.base/share/classes/java/io/ObjectOutputStream.java b/jdk/src/java.base/share/classes/java/io/ObjectOutputStream.java index 7dc6dde469f..e99e0257f31 100644 --- a/jdk/src/java.base/share/classes/java/io/ObjectOutputStream.java +++ b/jdk/src/java.base/share/classes/java/io/ObjectOutputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -32,6 +32,7 @@ import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.StringJoiner; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import static java.io.ObjectStreamClass.processQueue; @@ -2465,15 +2466,11 @@ public class ObjectOutputStream * Returns a string representation of this object */ public String toString() { - StringBuilder buffer = new StringBuilder(); - if (!stack.isEmpty()) { - for(int i = stack.size(); i > 0; i-- ) { - buffer.append(stack.get(i - 1)); - if (i != 1) - buffer.append('\n'); - } + StringJoiner sj = new StringJoiner("\n"); + for (int i = stack.size() - 1; i >= 0; i--) { + sj.add(stack.get(i)); } - return buffer.toString(); + return sj.toString(); } } diff --git a/jdk/src/java.base/share/classes/java/io/RandomAccessFile.java b/jdk/src/java.base/share/classes/java/io/RandomAccessFile.java index ae1e530f168..d6b79b245cd 100644 --- a/jdk/src/java.base/share/classes/java/io/RandomAccessFile.java +++ b/jdk/src/java.base/share/classes/java/io/RandomAccessFile.java @@ -296,9 +296,26 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable { * @param mode the mode flags, a combination of the O_ constants * defined above */ - private native void open(String name, int mode) + private native void open0(String name, int mode) throws FileNotFoundException; + // wrap native call to allow instrumentation + /** + * Opens a file and returns the file descriptor. The file is + * opened in read-write mode if the O_RDWR bit in {@code mode} + * is true, else the file is opened as read-only. + * If the {@code name} refers to a directory, an IOException + * is thrown. + * + * @param name the name of the file + * @param mode the mode flags, a combination of the O_ constants + * defined above + */ + private void open(String name, int mode) + throws FileNotFoundException { + open0(name, mode); + } + // 'Read' primitives /** diff --git a/jdk/src/java.base/share/classes/java/lang/Class.java b/jdk/src/java.base/share/classes/java/lang/Class.java index cd26ab11791..2179ee809f5 100644 --- a/jdk/src/java.base/share/classes/java/lang/Class.java +++ b/jdk/src/java.base/share/classes/java/lang/Class.java @@ -54,6 +54,7 @@ import java.util.Set; import java.util.Map; import java.util.HashMap; import java.util.Objects; +import java.util.StringJoiner; import sun.misc.Unsafe; import sun.reflect.CallerSensitive; import sun.reflect.ConstantPool; @@ -1322,7 +1323,7 @@ public final class Class implements java.io.Serializable, // (for anonymous classes): 1 or more digits. // Since getSimpleBinaryName() will strip the binary name of - // the immediatly enclosing class, we are now looking at a + // the immediately enclosing class, we are now looking at a // string that matches the regular expression "\$[0-9]*" // followed by a simple name (considering the simple of an // anonymous class to be the empty string). @@ -3141,19 +3142,14 @@ public final class Class implements java.io.Serializable, private native Class[] getDeclaredClasses0(); private static String argumentTypesToString(Class[] argTypes) { - StringBuilder buf = new StringBuilder(); - buf.append("("); + StringJoiner sj = new StringJoiner(", ", "(", ")"); if (argTypes != null) { for (int i = 0; i < argTypes.length; i++) { - if (i > 0) { - buf.append(", "); - } Class c = argTypes[i]; - buf.append((c == null) ? "null" : c.getName()); + sj.add((c == null) ? "null" : c.getName()); } } - buf.append(")"); - return buf.toString(); + return sj.toString(); } /** use serialVersionUID from JDK 1.1 for interoperability */ diff --git a/jdk/src/java.base/share/classes/java/lang/ClassLoader.java b/jdk/src/java.base/share/classes/java/lang/ClassLoader.java index 1652d6cc4eb..1def66a146b 100644 --- a/jdk/src/java.base/share/classes/java/lang/ClassLoader.java +++ b/jdk/src/java.base/share/classes/java/lang/ClassLoader.java @@ -205,7 +205,7 @@ public abstract class ClassLoader { } /** - * Registers the given class loader type as parallel capabale. + * Registers the given class loader type as parallel capable. * Returns {@code true} is successfully registered; {@code false} if * loader's super class is not registered. */ @@ -832,7 +832,7 @@ public abstract class ClassLoader { { int len = b.remaining(); - // Use byte[] if not a direct ByteBufer: + // Use byte[] if not a direct ByteBuffer: if (!b.isDirect()) { if (b.hasArray()) { return defineClass(name, b.array(), diff --git a/jdk/src/java.base/share/classes/java/lang/StringCoding.java b/jdk/src/java.base/share/classes/java/lang/StringCoding.java index 24ed0c06bbe..a4c71b4cf21 100644 --- a/jdk/src/java.base/share/classes/java/lang/StringCoding.java +++ b/jdk/src/java.base/share/classes/java/lang/StringCoding.java @@ -196,19 +196,19 @@ class StringCoding { static char[] decode(Charset cs, byte[] ba, int off, int len) { // (1)We never cache the "external" cs, the only benefit of creating // an additional StringDe/Encoder object to wrap it is to share the - // de/encode() method. These SD/E objects are short-lifed, the young-gen - // gc should be able to take care of them well. But the best approash + // de/encode() method. These SD/E objects are short-lived, the young-gen + // gc should be able to take care of them well. But the best approach // is still not to generate them if not really necessary. // (2)The defensive copy of the input byte/char[] has a big performance // impact, as well as the outgoing result byte/char[]. Need to do the // optimization check of (sm==null && classLoader0==null) for both. // (3)getClass().getClassLoader0() is expensive // (4)There might be a timing gap in isTrusted setting. getClassLoader0() - // is only chcked (and then isTrusted gets set) when (SM==null). It is + // is only checked (and then isTrusted gets set) when (SM==null). It is // possible that the SM==null for now but then SM is NOT null later // when safeTrim() is invoked...the "safe" way to do is to redundant // check (... && (isTrusted || SM == null || getClassLoader0())) in trim - // but it then can be argued that the SM is null when the opertaion + // but it then can be argued that the SM is null when the operation // is started... CharsetDecoder cd = cs.newDecoder(); int en = scale(len, cd.maxCharsPerByte()); diff --git a/jdk/src/java.base/share/classes/java/lang/System.java b/jdk/src/java.base/share/classes/java/lang/System.java index fbac697c245..345cdae1df7 100644 --- a/jdk/src/java.base/share/classes/java/lang/System.java +++ b/jdk/src/java.base/share/classes/java/lang/System.java @@ -1193,7 +1193,7 @@ public final class System { // Setup Java signal handlers for HUP, TERM, and INT (where available). Terminator.setup(); - // Initialize any miscellenous operating system settings that need to be + // Initialize any miscellaneous operating system settings that need to be // set for the class libraries. Currently this is no-op everywhere except // for Windows where the process-wide error mode is set before the java.io // classes are used. diff --git a/jdk/src/java.base/share/classes/java/lang/Throwable.java b/jdk/src/java.base/share/classes/java/lang/Throwable.java index 396d8e90ecc..d71f9ecdf0d 100644 --- a/jdk/src/java.base/share/classes/java/lang/Throwable.java +++ b/jdk/src/java.base/share/classes/java/lang/Throwable.java @@ -139,7 +139,7 @@ public class Throwable implements Serializable { * {@linkplain #setStackTrace(StackTraceElement[]) Setting the * stack trace} to a one-element array containing this sentinel * value indicates future attempts to set the stack trace will be - * ignored. The sentinal is equal to the result of calling:
    + * ignored. The sentinel is equal to the result of calling:
    * {@code new StackTraceElement("", "", null, Integer.MIN_VALUE)} */ public static final StackTraceElement STACK_TRACE_ELEMENT_SENTINEL = diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java b/jdk/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java index 752c0976d9e..9d8db4eef78 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java @@ -98,7 +98,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*; private final String implMethodClassName; // Name of type containing implementation "CC" private final String implMethodName; // Name of implementation method "impl" private final String implMethodDesc; // Type descriptor for implementation methods "(I)Ljava/lang/String;" - private final Class implMethodReturnClass; // class for implementaion method return type "Ljava/lang/String;" + private final Class implMethodReturnClass; // class for implementation method return type "Ljava/lang/String;" private final MethodType constructorType; // Generated class constructor type "(CC)void" private final ClassWriter cw; // ASM class writer private final String[] argNames; // Generated names for the constructor arguments diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java b/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java index 3ab5d9c4dcf..58e56dd246a 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java @@ -209,7 +209,7 @@ class InvokerBytecodeGenerator { throw new InternalError("observed CP placeholder twice: " + cpPlaceholder); } // insert placeholder in CP and remember the patch - int index = cw.newConst((Object) cpPlaceholder); // TODO check if aready in the constant pool + int index = cw.newConst((Object) cpPlaceholder); // TODO check if already in the constant pool cpPatches.put(cpPlaceholder, new CpPatch(index, cpPlaceholder, arg)); return cpPlaceholder; } diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java b/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java index b9c18b548bd..d3116d12963 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java @@ -37,7 +37,7 @@ import static java.lang.invoke.LambdaForm.*; * @author jrose */ class Invokers { - // exact type (sans leading taget MH) for the outgoing call + // exact type (sans leading target MH) for the outgoing call private final MethodType targetType; // FIXME: Get rid of the invokers that are not useful. diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java b/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java index 9cc901eea7a..75b26be4e0c 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java @@ -59,7 +59,7 @@ import java.util.Objects; * and properly use the named member. *

    * When resolved, a member name's internal implementation may include references to JVM metadata. - * This representation is stateless and only decriptive. + * This representation is stateless and only descriptive. * It provides no private information and no capability to use the member. *

    * By contrast, a {@linkplain java.lang.reflect.Method} contains fuller information diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandle.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandle.java index 19664528f26..5ed091e408f 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandle.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandle.java @@ -679,7 +679,7 @@ public abstract class MethodHandle { * This method provides the crucial behavioral difference between * {@link #invokeExact invokeExact} and plain, inexact {@link #invoke invoke}. * The two methods - * perform the same steps when the caller's type descriptor exactly m atches + * perform the same steps when the caller's type descriptor exactly matches * the callee's, but when the types differ, plain {@link #invoke invoke} * also calls {@code asType} (or some internal equivalent) in order * to match up the caller's and callee's types. diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java index abd8999aeaa..3e4ee65e161 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java @@ -621,7 +621,7 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; } /** - * The LambaForm shape for catchException combinator is the following: + * The LambdaForm shape for catchException combinator is the following: *

    {@code
          *  guardWithCatch=Lambda(a0:L,a1:L,a2:L)=>{
          *    t3:L=BoundMethodHandle$Species_LLLLL.argL0(a0:L);
    @@ -702,7 +702,7 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
             MethodType type = target.type();
             LambdaForm form = makeGuardWithCatchForm(type.basicType());
     
    -        // Prepare auxiliary method handles used during LambdaForm interpreation.
    +        // Prepare auxiliary method handles used during LambdaForm interpretation.
             // Box arguments and wrap them into Object[]: ValueConversions.array().
             MethodType varargsType = type.changeReturnType(Object[].class);
             MethodHandle collectArgs = ValueConversions.varargsArray(type.parameterCount())
    diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleNatives.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleNatives.java
    index 0f5169e95e2..01c3b33001d 100644
    --- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleNatives.java
    +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleNatives.java
    @@ -509,7 +509,7 @@ class MethodHandleNatives {
     
         /**
          * Is this method a caller-sensitive method?
    -     * I.e., does it call Reflection.getCallerClass or a similer method
    +     * I.e., does it call Reflection.getCallerClass or a similar method
          * to ask about the identity of its caller?
          */
         static boolean isCallerSensitive(MemberName mem) {
    diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodType.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodType.java
    index c26460048b0..2b20ae71935 100644
    --- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodType.java
    +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodType.java
    @@ -33,6 +33,7 @@ import java.util.Arrays;
     import java.util.Collections;
     import java.util.List;
     import java.util.Objects;
    +import java.util.StringJoiner;
     import java.util.concurrent.ConcurrentMap;
     import java.util.concurrent.ConcurrentHashMap;
     import sun.invoke.util.BytecodeDescriptor;
    @@ -717,15 +718,12 @@ class MethodType implements java.io.Serializable {
          */
         @Override
         public String toString() {
    -        StringBuilder sb = new StringBuilder();
    -        sb.append("(");
    +        StringJoiner sj = new StringJoiner(",", "(",
    +                ")" + rtype.getSimpleName());
             for (int i = 0; i < ptypes.length; i++) {
    -            if (i > 0)  sb.append(",");
    -            sb.append(ptypes[i].getSimpleName());
    +            sj.add(ptypes[i].getSimpleName());
             }
    -        sb.append(")");
    -        sb.append(rtype.getSimpleName());
    -        return sb.toString();
    +        return sj.toString();
         }
     
     
    diff --git a/jdk/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java b/jdk/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java
    index f85ab432388..01a074f36e0 100644
    --- a/jdk/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java
    +++ b/jdk/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java
    @@ -78,7 +78,7 @@ public class AccessibleObject implements AnnotatedElement {
          * object is a {@link Constructor} object for the class {@link
          * java.lang.Class}).  In the event of such a SecurityException, the
          * accessibility of objects is set to {@code flag} for array elements
    -     * upto (and excluding) the element for which the exception occurred; the
    +     * up to (and excluding) the element for which the exception occurred; the
          * accessibility of elements beyond (and including) the element for which
          * the exception occurred is unchanged.
          *
    diff --git a/jdk/src/java.base/share/classes/java/lang/reflect/Constructor.java b/jdk/src/java.base/share/classes/java/lang/reflect/Constructor.java
    index f424deec74a..4b112bf16b3 100644
    --- a/jdk/src/java.base/share/classes/java/lang/reflect/Constructor.java
    +++ b/jdk/src/java.base/share/classes/java/lang/reflect/Constructor.java
    @@ -544,15 +544,33 @@ public final class Constructor extends Executable {
          */
         @Override
         public AnnotatedType getAnnotatedReceiverType() {
    -        if (getDeclaringClass().getEnclosingClass() == null)
    -            return super.getAnnotatedReceiverType();
    +        Class thisDeclClass = getDeclaringClass();
    +        Class enclosingClass = thisDeclClass.getEnclosingClass();
     
    +        if (enclosingClass == null) {
    +            // A Constructor for a top-level class
    +            return null;
    +        }
    +
    +        Class outerDeclaringClass = thisDeclClass.getDeclaringClass();
    +        if (outerDeclaringClass == null) {
    +            // A constructor for a local or anonymous class
    +            return null;
    +        }
    +
    +        // Either static nested or inner class
    +        if (Modifier.isStatic(thisDeclClass.getModifiers())) {
    +            // static nested
    +            return null;
    +        }
    +
    +        // A Constructor for an inner class
             return TypeAnnotationParser.buildAnnotatedType(getTypeAnnotationBytes0(),
                     sun.misc.SharedSecrets.getJavaLangAccess().
    -                        getConstantPool(getDeclaringClass()),
    +                    getConstantPool(thisDeclClass),
                     this,
    -                getDeclaringClass(),
    -                getDeclaringClass().getEnclosingClass(),
    +                thisDeclClass,
    +                enclosingClass,
                     TypeAnnotation.TypeAnnotationTarget.METHOD_RECEIVER);
         }
     }
    diff --git a/jdk/src/java.base/share/classes/java/lang/reflect/Executable.java b/jdk/src/java.base/share/classes/java/lang/reflect/Executable.java
    index 8493d10eaa4..99eb1eb8b90 100644
    --- a/jdk/src/java.base/share/classes/java/lang/reflect/Executable.java
    +++ b/jdk/src/java.base/share/classes/java/lang/reflect/Executable.java
    @@ -585,21 +585,24 @@ public abstract class Executable extends AccessibleObject
         /**
          * Returns an {@code AnnotatedType} object that represents the use of a
          * type to specify the receiver type of the method/constructor represented
    -     * by this Executable object. The receiver type of a method/constructor is
    -     * available only if the method/constructor has a receiver
    -     * parameter (JLS 8.4.1).
    +     * by this {@code Executable} object.
          *
    -     * If this {@code Executable} object represents a constructor or instance
    -     * method that does not have a receiver parameter, or has a receiver
    -     * parameter with no annotations on its type, then the return value is an
    -     * {@code AnnotatedType} object representing an element with no
    +     * The receiver type of a method/constructor is available only if the
    +     * method/constructor has a receiver parameter (JLS 8.4.1). If this {@code
    +     * Executable} object represents an instance method or represents a
    +     * constructor of an inner member class, and the
    +     * method/constructor either has no receiver parameter or has a
    +     * receiver parameter with no annotations on its type, then the return
    +     * value is an {@code AnnotatedType} object representing an element with no
          * annotations.
          *
    -     * If this {@code Executable} object represents a static method, then the
    -     * return value is null.
    +     * If this {@code Executable} object represents a static method or
    +     * represents a constructor of a top level, static member, local, or
    +     * anoymous class, then the return value is null.
          *
          * @return an object representing the receiver type of the method or
    -     * constructor represented by this {@code Executable}
    +     * constructor represented by this {@code Executable} or {@code null} if
    +     * this {@code Executable} can not have a receiver parameter
          */
         public AnnotatedType getAnnotatedReceiverType() {
             if (Modifier.isStatic(this.getModifiers()))
    diff --git a/jdk/src/java.base/share/classes/java/lang/reflect/Parameter.java b/jdk/src/java.base/share/classes/java/lang/reflect/Parameter.java
    index f035b8e5e73..69c568f09fe 100644
    --- a/jdk/src/java.base/share/classes/java/lang/reflect/Parameter.java
    +++ b/jdk/src/java.base/share/classes/java/lang/reflect/Parameter.java
    @@ -173,7 +173,7 @@ public final class Parameter implements AnnotatedElement {
          *         a name.
          */
         public String getName() {
    -        // Note: empty strings as paramete names are now outlawed.
    +        // Note: empty strings as parameter names are now outlawed.
             // The .equals("") is for compatibility with current JVM
             // behavior.  It may be removed at some point.
             if(name == null || name.equals(""))
    diff --git a/jdk/src/java.base/share/classes/java/net/InetAddress.java b/jdk/src/java.base/share/classes/java/net/InetAddress.java
    index 09b645d4d85..eb72c091285 100644
    --- a/jdk/src/java.base/share/classes/java/net/InetAddress.java
    +++ b/jdk/src/java.base/share/classes/java/net/InetAddress.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 1995, 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
    @@ -25,11 +25,8 @@
     
     package java.net;
     
    -import java.util.HashMap;
    -import java.util.LinkedHashMap;
    -import java.util.Random;
    +import java.util.NavigableSet;
     import java.util.Iterator;
    -import java.util.LinkedList;
     import java.util.List;
     import java.util.ArrayList;
     import java.util.ServiceLoader;
    @@ -41,6 +38,11 @@ import java.io.ObjectInputStream;
     import java.io.ObjectInputStream.GetField;
     import java.io.ObjectOutputStream;
     import java.io.ObjectOutputStream.PutField;
    +import java.util.concurrent.ConcurrentHashMap;
    +import java.util.concurrent.ConcurrentMap;
    +import java.util.concurrent.ConcurrentSkipListSet;
    +import java.util.concurrent.atomic.AtomicLong;
    +
     import sun.security.action.*;
     import sun.net.InetAddressCachePolicy;
     import sun.net.util.IPAddressUtil;
    @@ -705,195 +707,130 @@ class InetAddress implements java.io.Serializable {
                 + "/" + getHostAddress();
         }
     
    -    /*
    -     * Cached addresses - our own litle nis, not!
    -     */
    -    private static Cache addressCache = new Cache(Cache.Type.Positive);
    +    // mapping from host name to Addresses - either NameServiceAddresses (while
    +    // still being looked-up by NameService(s)) or CachedAddresses when cached
    +    private static final ConcurrentMap cache =
    +        new ConcurrentHashMap<>();
     
    -    private static Cache negativeCache = new Cache(Cache.Type.Negative);
    +    // CachedAddresses that have to expire are kept ordered in this NavigableSet
    +    // which is scanned on each access
    +    private static final NavigableSet expirySet =
    +        new ConcurrentSkipListSet<>();
     
    -    private static boolean addressCacheInit = false;
    +    // common interface
    +    private interface Addresses {
    +        InetAddress[] get() throws UnknownHostException;
    +    }
     
    -    static InetAddress[]    unknown_array; // put THIS in cache
    +    // a holder for cached addresses with required metadata
    +    private static final class CachedAddresses  implements Addresses, Comparable {
    +        private static final AtomicLong seq = new AtomicLong();
    +        final String host;
    +        final InetAddress[] inetAddresses;
    +        final long expiryTime; // time of expiry (in terms of System.nanoTime())
    +        final long id = seq.incrementAndGet(); // each instance is unique
    +
    +        CachedAddresses(String host, InetAddress[] inetAddresses, long expiryTime) {
    +            this.host = host;
    +            this.inetAddresses = inetAddresses;
    +            this.expiryTime = expiryTime;
    +        }
    +
    +        @Override
    +        public InetAddress[] get() throws UnknownHostException {
    +            if (inetAddresses == null) {
    +                throw new UnknownHostException(host);
    +            }
    +            return inetAddresses;
    +        }
    +
    +        @Override
    +        public int compareTo(CachedAddresses other) {
    +            // natural order is expiry time -
    +            // compare difference of expiry times rather than
    +            // expiry times directly, to avoid possible overflow.
    +            // (see System.nanoTime() recommendations...)
    +            long diff = this.expiryTime - other.expiryTime;
    +            if (diff < 0L) return -1;
    +            if (diff > 0L) return 1;
    +            // ties are broken using unique id
    +            return Long.compare(this.id, other.id);
    +        }
    +    }
    +
    +    // a name service lookup based Addresses implementation which replaces itself
    +    // in cache when the result is obtained
    +    private static final class NameServiceAddresses implements Addresses {
    +        private final String host;
    +        private final InetAddress reqAddr;
    +
    +        NameServiceAddresses(String host, InetAddress reqAddr) {
    +            this.host = host;
    +            this.reqAddr = reqAddr;
    +        }
    +
    +        @Override
    +        public InetAddress[] get() throws UnknownHostException {
    +            Addresses addresses;
    +            // only one thread is doing lookup to name service
    +            // for particular host at any time.
    +            synchronized (this) {
    +                // re-check that we are still us + re-install us if slot empty
    +                addresses = cache.putIfAbsent(host, this);
    +                if (addresses == null) {
    +                    // this can happen when we were replaced by CachedAddresses in
    +                    // some other thread, then CachedAddresses expired and were
    +                    // removed from cache while we were waiting for lock...
    +                    addresses = this;
    +                }
    +                // still us ?
    +                if (addresses == this) {
    +                    // lookup name services
    +                    InetAddress[] inetAddresses;
    +                    UnknownHostException ex;
    +                    int cachePolicy;
    +                    try {
    +                        inetAddresses = getAddressesFromNameService(host, reqAddr);
    +                        ex = null;
    +                        cachePolicy = InetAddressCachePolicy.get();
    +                    } catch (UnknownHostException uhe) {
    +                        inetAddresses = null;
    +                        ex = uhe;
    +                        cachePolicy = InetAddressCachePolicy.getNegative();
    +                    }
    +                    // remove or replace us with cached addresses according to cachePolicy
    +                    if (cachePolicy == InetAddressCachePolicy.NEVER) {
    +                        cache.remove(host, this);
    +                    } else {
    +                        CachedAddresses cachedAddresses = new CachedAddresses(
    +                            host,
    +                            inetAddresses,
    +                            cachePolicy == InetAddressCachePolicy.FOREVER
    +                            ? 0L
    +                            // cachePolicy is in [s] - we need [ns]
    +                            : System.nanoTime() + 1000_000_000L * cachePolicy
    +                        );
    +                        if (cache.replace(host, this, cachedAddresses) &&
    +                            cachePolicy != InetAddressCachePolicy.FOREVER) {
    +                            // schedule expiry
    +                            expirySet.add(cachedAddresses);
    +                        }
    +                    }
    +                    if (inetAddresses == null) {
    +                        throw ex == null ? new UnknownHostException(host) : ex;
    +                    }
    +                    return inetAddresses;
    +                }
    +                // else addresses != this
    +            }
    +            // delegate to different addresses when we are already replaced
    +            // but outside of synchronized block to avoid any chance of dead-locking
    +            return addresses.get();
    +        }
    +    }
     
         static InetAddressImpl  impl;
     
    -    private static final HashMap lookupTable = new HashMap<>();
    -
    -    /**
    -     * Represents a cache entry
    -     */
    -    static final class CacheEntry {
    -
    -        CacheEntry(InetAddress[] addresses, long expiration) {
    -            this.addresses = addresses;
    -            this.expiration = expiration;
    -        }
    -
    -        InetAddress[] addresses;
    -        long expiration;
    -    }
    -
    -    /**
    -     * A cache that manages entries based on a policy specified
    -     * at creation time.
    -     */
    -    static final class Cache {
    -        private LinkedHashMap cache;
    -        private Type type;
    -
    -        enum Type {Positive, Negative};
    -
    -        /**
    -         * Create cache
    -         */
    -        public Cache(Type type) {
    -            this.type = type;
    -            cache = new LinkedHashMap();
    -        }
    -
    -        private int getPolicy() {
    -            if (type == Type.Positive) {
    -                return InetAddressCachePolicy.get();
    -            } else {
    -                return InetAddressCachePolicy.getNegative();
    -            }
    -        }
    -
    -        /**
    -         * Add an entry to the cache. If there's already an
    -         * entry then for this host then the entry will be
    -         * replaced.
    -         */
    -        public Cache put(String host, InetAddress[] addresses) {
    -            int policy = getPolicy();
    -            if (policy == InetAddressCachePolicy.NEVER) {
    -                return this;
    -            }
    -
    -            // purge any expired entries
    -
    -            if (policy != InetAddressCachePolicy.FOREVER) {
    -
    -                // As we iterate in insertion order we can
    -                // terminate when a non-expired entry is found.
    -                LinkedList expired = new LinkedList<>();
    -                long now = System.currentTimeMillis();
    -                for (String key : cache.keySet()) {
    -                    CacheEntry entry = cache.get(key);
    -
    -                    if (entry.expiration >= 0 && entry.expiration < now) {
    -                        expired.add(key);
    -                    } else {
    -                        break;
    -                    }
    -                }
    -
    -                for (String key : expired) {
    -                    cache.remove(key);
    -                }
    -            }
    -
    -            // create new entry and add it to the cache
    -            // -- as a HashMap replaces existing entries we
    -            //    don't need to explicitly check if there is
    -            //    already an entry for this host.
    -            long expiration;
    -            if (policy == InetAddressCachePolicy.FOREVER) {
    -                expiration = -1;
    -            } else {
    -                expiration = System.currentTimeMillis() + (policy * 1000);
    -            }
    -            CacheEntry entry = new CacheEntry(addresses, expiration);
    -            cache.put(host, entry);
    -            return this;
    -        }
    -
    -        /**
    -         * Query the cache for the specific host. If found then
    -         * return its CacheEntry, or null if not found.
    -         */
    -        public CacheEntry get(String host) {
    -            int policy = getPolicy();
    -            if (policy == InetAddressCachePolicy.NEVER) {
    -                return null;
    -            }
    -            CacheEntry entry = cache.get(host);
    -
    -            // check if entry has expired
    -            if (entry != null && policy != InetAddressCachePolicy.FOREVER) {
    -                if (entry.expiration >= 0 &&
    -                    entry.expiration < System.currentTimeMillis()) {
    -                    cache.remove(host);
    -                    entry = null;
    -                }
    -            }
    -
    -            return entry;
    -        }
    -    }
    -
    -    /*
    -     * Initialize cache and insert anyLocalAddress into the
    -     * unknown array with no expiry.
    -     */
    -    private static void cacheInitIfNeeded() {
    -        assert Thread.holdsLock(addressCache);
    -        if (addressCacheInit) {
    -            return;
    -        }
    -        unknown_array = new InetAddress[1];
    -        unknown_array[0] = impl.anyLocalAddress();
    -
    -        addressCache.put(impl.anyLocalAddress().getHostName(),
    -                         unknown_array);
    -
    -        addressCacheInit = true;
    -    }
    -
    -    /*
    -     * Cache the given hostname and addresses.
    -     */
    -    private static void cacheAddresses(String hostname,
    -                                       InetAddress[] addresses,
    -                                       boolean success) {
    -        hostname = hostname.toLowerCase();
    -        synchronized (addressCache) {
    -            cacheInitIfNeeded();
    -            if (success) {
    -                addressCache.put(hostname, addresses);
    -            } else {
    -                negativeCache.put(hostname, addresses);
    -            }
    -        }
    -    }
    -
    -    /*
    -     * Lookup hostname in cache (positive & negative cache). If
    -     * found return addresses, null if not found.
    -     */
    -    private static InetAddress[] getCachedAddresses(String hostname) {
    -        hostname = hostname.toLowerCase();
    -
    -        // search both positive & negative caches
    -
    -        synchronized (addressCache) {
    -            cacheInitIfNeeded();
    -
    -            CacheEntry entry = addressCache.get(hostname);
    -            if (entry == null) {
    -                entry = negativeCache.get(hostname);
    -            }
    -
    -            if (entry != null) {
    -                return entry.addresses;
    -            }
    -        }
    -
    -        // not found
    -        return null;
    -    }
    -
         private static NameService createNSProvider(String provider) {
             if (provider == null)
                 return null;
    @@ -1168,7 +1105,7 @@ class InetAddress implements java.io.Serializable {
                 // We were expecting an IPv6 Litteral, but got something else
                 throw new UnknownHostException("["+host+"]");
             }
    -        return getAllByName0(host, reqAddr, true);
    +        return getAllByName0(host, reqAddr, true, true);
         }
     
         /**
    @@ -1229,14 +1166,27 @@ class InetAddress implements java.io.Serializable {
          */
         static InetAddress[] getAllByName0 (String host, boolean check)
             throws UnknownHostException  {
    -        return getAllByName0 (host, null, check);
    +        return getAllByName0 (host, null, check, true);
         }
     
    -    private static InetAddress[] getAllByName0 (String host, InetAddress reqAddr, boolean check)
    +    /**
    +     * Designated lookup method.
    +     *
    +     * @param host host name to look up
    +     * @param reqAddr requested address to be the 1st in returned array
    +     * @param check perform security check
    +     * @param useCache use cached value if not expired else always
    +     *                 perform name service lookup (and cache the result)
    +     * @return array of InetAddress(es)
    +     * @throws UnknownHostException if host name is not found
    +     */
    +    private static InetAddress[] getAllByName0(String host,
    +                                               InetAddress reqAddr,
    +                                               boolean check,
    +                                               boolean useCache)
             throws UnknownHostException  {
     
             /* If it gets here it is presumed to be a hostname */
    -        /* Cache.get can return: null, unknownAddress, or InetAddress[] */
     
             /* make sure the connection to the host is allowed, before we
              * give out a hostname
    @@ -1248,155 +1198,106 @@ class InetAddress implements java.io.Serializable {
                 }
             }
     
    -        InetAddress[] addresses = getCachedAddresses(host);
    -
    -        /* If no entry in cache, then do the host lookup */
    -        if (addresses == null) {
    -            addresses = getAddressesFromNameService(host, reqAddr);
    +        // remove expired addresses from cache - expirySet keeps them ordered
    +        // by expiry time so we only need to iterate the prefix of the NavigableSet...
    +        long now = System.nanoTime();
    +        for (CachedAddresses caddrs : expirySet) {
    +            // compare difference of time instants rather than
    +            // time instants directly, to avoid possible overflow.
    +            // (see System.nanoTime() recommendations...)
    +            if ((caddrs.expiryTime - now) < 0L) {
    +                // ConcurrentSkipListSet uses weakly consistent iterator,
    +                // so removing while iterating is OK...
    +                if (expirySet.remove(caddrs)) {
    +                    // ... remove from cache
    +                    cache.remove(caddrs.host, caddrs);
    +                }
    +            } else {
    +                // we encountered 1st element that expires in future
    +                break;
    +            }
             }
     
    -        if (addresses == unknown_array)
    -            throw new UnknownHostException(host);
    +        // look-up or remove from cache
    +        Addresses addrs;
    +        if (useCache) {
    +            addrs = cache.get(host);
    +        } else {
    +            addrs = cache.remove(host);
    +            if (addrs != null) {
    +                if (addrs instanceof CachedAddresses) {
    +                    // try removing from expirySet too if CachedAddresses
    +                    expirySet.remove(addrs);
    +                }
    +                addrs = null;
    +            }
    +        }
     
    -        return addresses.clone();
    +        if (addrs == null) {
    +            // create a NameServiceAddresses instance which will look up
    +            // the name service and install it within cache...
    +            Addresses oldAddrs = cache.putIfAbsent(
    +                host,
    +                addrs = new NameServiceAddresses(host, reqAddr)
    +            );
    +            if (oldAddrs != null) { // lost putIfAbsent race
    +                addrs = oldAddrs;
    +            }
    +        }
    +
    +        // ask Addresses to get an array of InetAddress(es) and clone it
    +        return addrs.get().clone();
         }
     
    -    private static InetAddress[] getAddressesFromNameService(String host, InetAddress reqAddr)
    +    static InetAddress[] getAddressesFromNameService(String host, InetAddress reqAddr)
             throws UnknownHostException
         {
             InetAddress[] addresses = null;
    -        boolean success = false;
             UnknownHostException ex = null;
     
    -        // Check whether the host is in the lookupTable.
    -        // 1) If the host isn't in the lookupTable when
    -        //    checkLookupTable() is called, checkLookupTable()
    -        //    would add the host in the lookupTable and
    -        //    return null. So we will do the lookup.
    -        // 2) If the host is in the lookupTable when
    -        //    checkLookupTable() is called, the current thread
    -        //    would be blocked until the host is removed
    -        //    from the lookupTable. Then this thread
    -        //    should try to look up the addressCache.
    -        //     i) if it found the addresses in the
    -        //        addressCache, checkLookupTable()  would
    -        //        return the addresses.
    -        //     ii) if it didn't find the addresses in the
    -        //         addressCache for any reason,
    -        //         it should add the host in the
    -        //         lookupTable and return null so the
    -        //         following code would do  a lookup itself.
    -        if ((addresses = checkLookupTable(host)) == null) {
    +        for (NameService nameService : nameServices) {
                 try {
    -                // This is the first thread which looks up the addresses
    -                // this host or the cache entry for this host has been
    -                // expired so this thread should do the lookup.
    -                for (NameService nameService : nameServices) {
    -                    try {
    -                        /*
    -                         * Do not put the call to lookup() inside the
    -                         * constructor.  if you do you will still be
    -                         * allocating space when the lookup fails.
    -                         */
    -
    -                        addresses = nameService.lookupAllHostAddr(host);
    -                        success = true;
    -                        break;
    -                    } catch (UnknownHostException uhe) {
    -                        if (host.equalsIgnoreCase("localhost")) {
    -                            InetAddress[] local = new InetAddress[] { impl.loopbackAddress() };
    -                            addresses = local;
    -                            success = true;
    -                            break;
    -                        }
    -                        else {
    -                            addresses = unknown_array;
    -                            success = false;
    -                            ex = uhe;
    -                        }
    -                    }
    +                addresses = nameService.lookupAllHostAddr(host);
    +                break;
    +            } catch (UnknownHostException uhe) {
    +                if (host.equalsIgnoreCase("localhost")) {
    +                    addresses = new InetAddress[] { impl.loopbackAddress() };
    +                    break;
                     }
    -
    -                // More to do?
    -                if (reqAddr != null && addresses.length > 1 && !addresses[0].equals(reqAddr)) {
    -                    // Find it?
    -                    int i = 1;
    -                    for (; i < addresses.length; i++) {
    -                        if (addresses[i].equals(reqAddr)) {
    -                            break;
    -                        }
    -                    }
    -                    // Rotate
    -                    if (i < addresses.length) {
    -                        InetAddress tmp, tmp2 = reqAddr;
    -                        for (int j = 0; j < i; j++) {
    -                            tmp = addresses[j];
    -                            addresses[j] = tmp2;
    -                            tmp2 = tmp;
    -                        }
    -                        addresses[i] = tmp2;
    -                    }
    -                }
    -                // Cache the address.
    -                cacheAddresses(host, addresses, success);
    -
    -                if (!success && ex != null)
    -                    throw ex;
    -
    -            } finally {
    -                // Delete host from the lookupTable and notify
    -                // all threads waiting on the lookupTable monitor.
    -                updateLookupTable(host);
    -            }
    -        }
    -
    -        return addresses;
    -    }
    -
    -
    -    private static InetAddress[] checkLookupTable(String host) {
    -        synchronized (lookupTable) {
    -            // If the host isn't in the lookupTable, add it in the
    -            // lookuptable and return null. The caller should do
    -            // the lookup.
    -            if (lookupTable.containsKey(host) == false) {
    -                lookupTable.put(host, null);
    -                return null;
    -            }
    -
    -            // If the host is in the lookupTable, it means that another
    -            // thread is trying to look up the addresses of this host.
    -            // This thread should wait.
    -            while (lookupTable.containsKey(host)) {
    -                try {
    -                    lookupTable.wait();
    -                } catch (InterruptedException e) {
    +                else {
    +                    ex = uhe;
                     }
                 }
             }
     
    -        // The other thread has finished looking up the addresses of
    -        // the host. This thread should retry to get the addresses
    -        // from the addressCache. If it doesn't get the addresses from
    -        // the cache, it will try to look up the addresses itself.
    -        InetAddress[] addresses = getCachedAddresses(host);
             if (addresses == null) {
    -            synchronized (lookupTable) {
    -                lookupTable.put(host, null);
    -                return null;
    +            throw ex == null ? new UnknownHostException(host) : ex;
    +        }
    +
    +        // More to do?
    +        if (reqAddr != null && addresses.length > 1 && !addresses[0].equals(reqAddr)) {
    +            // Find it?
    +            int i = 1;
    +            for (; i < addresses.length; i++) {
    +                if (addresses[i].equals(reqAddr)) {
    +                    break;
    +                }
    +            }
    +            // Rotate
    +            if (i < addresses.length) {
    +                InetAddress tmp, tmp2 = reqAddr;
    +                for (int j = 0; j < i; j++) {
    +                    tmp = addresses[j];
    +                    addresses[j] = tmp2;
    +                    tmp2 = tmp;
    +                }
    +                addresses[i] = tmp2;
                 }
             }
     
             return addresses;
         }
     
    -    private static void updateLookupTable(String host) {
    -        synchronized (lookupTable) {
    -            lookupTable.remove(host);
    -            lookupTable.notifyAll();
    -        }
    -    }
    -
         /**
          * Returns an {@code InetAddress} object given the raw IP address .
          * The argument is in network byte order: the highest order
    @@ -1418,10 +1319,18 @@ class InetAddress implements java.io.Serializable {
             return getByAddress(null, addr);
         }
     
    -    private static InetAddress cachedLocalHost = null;
    -    private static long cacheTime = 0;
    -    private static final long maxCacheTime = 5000L;
    -    private static final Object cacheLock = new Object();
    +    private static final class CachedLocalHost {
    +        final String host;
    +        final InetAddress addr;
    +        final long expiryTime = System.nanoTime() + 5000_000_000L; // now + 5s;
    +
    +        CachedLocalHost(String host, InetAddress addr) {
    +            this.host = host;
    +            this.addr = addr;
    +        }
    +    }
    +
    +    private static volatile CachedLocalHost cachedLocalHost;
     
         /**
          * Returns the address of the local host. This is achieved by retrieving
    @@ -1450,47 +1359,41 @@ class InetAddress implements java.io.Serializable {
     
             SecurityManager security = System.getSecurityManager();
             try {
    +            // is cached data still valid?
    +            CachedLocalHost clh = cachedLocalHost;
    +            if (clh != null && (clh.expiryTime - System.nanoTime()) >= 0L) {
    +                if (security != null) {
    +                    security.checkConnect(clh.host, -1);
    +                }
    +                return clh.addr;
    +            }
    +
                 String local = impl.getLocalHostName();
     
                 if (security != null) {
                     security.checkConnect(local, -1);
                 }
     
    +            InetAddress localAddr;
                 if (local.equals("localhost")) {
    -                return impl.loopbackAddress();
    -            }
    -
    -            InetAddress ret = null;
    -            synchronized (cacheLock) {
    -                long now = System.currentTimeMillis();
    -                if (cachedLocalHost != null) {
    -                    if ((now - cacheTime) < maxCacheTime) // Less than 5s old?
    -                        ret = cachedLocalHost;
    -                    else
    -                        cachedLocalHost = null;
    -                }
    -
    -                // we are calling getAddressesFromNameService directly
    -                // to avoid getting localHost from cache
    -                if (ret == null) {
    -                    InetAddress[] localAddrs;
    -                    try {
    -                        localAddrs =
    -                            InetAddress.getAddressesFromNameService(local, null);
    -                    } catch (UnknownHostException uhe) {
    -                        // Rethrow with a more informative error message.
    -                        UnknownHostException uhe2 =
    -                            new UnknownHostException(local + ": " +
    -                                                     uhe.getMessage());
    -                        uhe2.initCause(uhe);
    -                        throw uhe2;
    -                    }
    -                    cachedLocalHost = localAddrs[0];
    -                    cacheTime = now;
    -                    ret = localAddrs[0];
    +                // shortcut for "localhost" host name
    +                localAddr = impl.loopbackAddress();
    +            } else {
    +                // call getAllByName0 without security checks and
    +                // without using cached data
    +                try {
    +                    localAddr = getAllByName0(local, null, false, false)[0];
    +                } catch (UnknownHostException uhe) {
    +                    // Rethrow with a more informative error message.
    +                    UnknownHostException uhe2 =
    +                        new UnknownHostException(local + ": " +
    +                                                 uhe.getMessage());
    +                    uhe2.initCause(uhe);
    +                    throw uhe2;
                     }
                 }
    -            return ret;
    +            cachedLocalHost = new CachedLocalHost(local, localAddr);
    +            return localAddr;
             } catch (java.lang.SecurityException e) {
                 return impl.loopbackAddress();
             }
    diff --git a/jdk/src/java.base/share/classes/java/net/NetPermission.java b/jdk/src/java.base/share/classes/java/net/NetPermission.java
    index 9178f348723..dad3fb99f32 100644
    --- a/jdk/src/java.base/share/classes/java/net/NetPermission.java
    +++ b/jdk/src/java.base/share/classes/java/net/NetPermission.java
    @@ -72,10 +72,10 @@ import java.util.StringTokenizer;
      *   
      *
      * 
    - *  getNetworkInformation
    - *  The ability to retrieve all information about local network interfaces.
    - *  Malicious code can read information about network hardware such as
    - *  MAC addresses, which could be used to construct local IPv6 addresses.
    + *   getNetworkInformation
    + *   The ability to retrieve all information about local network interfaces.
    + *   Malicious code can read information about network hardware such as
    + *   MAC addresses, which could be used to construct local IPv6 addresses.
      * 
      *
      * 
    @@ -98,8 +98,8 @@ import java.util.StringTokenizer;
      * 
      *   requestPasswordAuthentication
      *   The ability
    - * to ask the authenticator registered with the system for
    - * a password
    + *   to ask the authenticator registered with the system for
    + *   a password
      *   Malicious code may steal this password.
      * 
      *
    @@ -116,11 +116,11 @@ import java.util.StringTokenizer;
      * 
      *   setDefaultAuthenticator
      *   The ability to set the
    - * way authentication information is retrieved when
    - * a proxy or HTTP server asks for authentication
    + *   way authentication information is retrieved when
    + *   a proxy or HTTP server asks for authentication
      *   Malicious
    - * code can set an authenticator that monitors and steals user
    - * authentication input as it retrieves the input from the user.
    + *   code can set an authenticator that monitors and steals user
    + *   authentication input as it retrieves the input from the user.
      * 
      *
      * 
    @@ -143,13 +143,13 @@ import java.util.StringTokenizer;
      * 
      *   specifyStreamHandler
      *   The ability
    - * to specify a stream handler when constructing a URL
    + *   to specify a stream handler when constructing a URL
      *   Malicious code may create a URL with resources that it would
    -normally not have access to (like file:/foo/fum/), specifying a
    -stream handler that gets the actual bytes from someplace it does
    -have access to. Thus it might be able to trick the system into
    -creating a ProtectionDomain/CodeSource for a class even though
    -that class really didn't come from that location.
    + *   normally not have access to (like file:/foo/fum/), specifying a
    + *   stream handler that gets the actual bytes from someplace it does
    + *   have access to. Thus it might be able to trick the system into
    + *   creating a ProtectionDomain/CodeSource for a class even though
    + *   that class really didn't come from that location.
      * 
      * 
      *
    diff --git a/jdk/src/java.base/share/classes/java/net/SocketInputStream.java b/jdk/src/java.base/share/classes/java/net/SocketInputStream.java
    index 224051ff608..41b18bdc7e0 100644
    --- a/jdk/src/java.base/share/classes/java/net/SocketInputStream.java
    +++ b/jdk/src/java.base/share/classes/java/net/SocketInputStream.java
    @@ -96,6 +96,26 @@ class SocketInputStream extends FileInputStream
                                        int timeout)
             throws IOException;
     
    +    // wrap native call to allow instrumentation
    +    /**
    +     * Reads into an array of bytes at the specified offset using
    +     * the received socket primitive.
    +     * @param fd the FileDescriptor
    +     * @param b the buffer into which the data is read
    +     * @param off the start offset of the data
    +     * @param len the maximum number of bytes read
    +     * @param timeout the read timeout in ms
    +     * @return the actual number of bytes read, -1 is
    +     *          returned when the end of the stream is reached.
    +     * @exception IOException If an I/O error has occurred.
    +     */
    +    private int socketRead(FileDescriptor fd,
    +                           byte b[], int off, int len,
    +                           int timeout)
    +        throws IOException {
    +        return socketRead0(fd, b, off, len, timeout);
    +    }
    +
         /**
          * Reads into a byte array data from the socket.
          * @param b the buffer into which the data is read
    @@ -147,7 +167,7 @@ class SocketInputStream extends FileInputStream
             // acquire file descriptor and do the read
             FileDescriptor fd = impl.acquireFD();
             try {
    -            n = socketRead0(fd, b, off, length, timeout);
    +            n = socketRead(fd, b, off, length, timeout);
                 if (n > 0) {
                     return n;
                 }
    @@ -165,7 +185,7 @@ class SocketInputStream extends FileInputStream
                 impl.setConnectionResetPending();
                 impl.acquireFD();
                 try {
    -                n = socketRead0(fd, b, off, length, timeout);
    +                n = socketRead(fd, b, off, length, timeout);
                     if (n > 0) {
                         return n;
                     }
    diff --git a/jdk/src/java.base/share/classes/java/net/SocketPermission.java b/jdk/src/java.base/share/classes/java/net/SocketPermission.java
    index 1f3248077be..8894152512b 100644
    --- a/jdk/src/java.base/share/classes/java/net/SocketPermission.java
    +++ b/jdk/src/java.base/share/classes/java/net/SocketPermission.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 1997, 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
    @@ -30,6 +30,7 @@ import java.util.Vector;
     import java.util.List;
     import java.util.ArrayList;
     import java.util.Collections;
    +import java.util.StringJoiner;
     import java.util.StringTokenizer;
     import java.net.InetAddress;
     import java.security.Permission;
    @@ -1112,36 +1113,21 @@ public final class SocketPermission extends Permission
          * @param mask a specific integer action mask to translate into a string
          * @return the canonical string representation of the actions
          */
    -    private static String getActions(int mask)
    -    {
    -        StringBuilder sb = new StringBuilder();
    -        boolean comma = false;
    -
    +    private static String getActions(int mask) {
    +        StringJoiner sj = new StringJoiner(",");
             if ((mask & CONNECT) == CONNECT) {
    -            comma = true;
    -            sb.append("connect");
    +            sj.add("connect");
             }
    -
             if ((mask & LISTEN) == LISTEN) {
    -            if (comma) sb.append(',');
    -            else comma = true;
    -            sb.append("listen");
    +            sj.add("listen");
             }
    -
             if ((mask & ACCEPT) == ACCEPT) {
    -            if (comma) sb.append(',');
    -            else comma = true;
    -            sb.append("accept");
    +            sj.add("accept");
             }
    -
    -
             if ((mask & RESOLVE) == RESOLVE) {
    -            if (comma) sb.append(',');
    -            else comma = true;
    -            sb.append("resolve");
    +            sj.add("resolve");
             }
    -
    -        return sb.toString();
    +        return sj.toString();
         }
     
         /**
    diff --git a/jdk/src/java.base/share/classes/java/net/URLClassLoader.java b/jdk/src/java.base/share/classes/java/net/URLClassLoader.java
    index e448a120bdc..6f4691404c3 100644
    --- a/jdk/src/java.base/share/classes/java/net/URLClassLoader.java
    +++ b/jdk/src/java.base/share/classes/java/net/URLClassLoader.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 1997, 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
    @@ -407,6 +407,29 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
             return pkg;
         }
     
    +    // Also called by VM to define Package for classes loaded from the CDS
    +    // archive
    +    private void definePackageInternal(String pkgname, Manifest man, URL url)
    +    {
    +        if (getAndVerifyPackage(pkgname, man, url) == null) {
    +            try {
    +                if (man != null) {
    +                    definePackage(pkgname, man, url);
    +                } else {
    +                    definePackage(pkgname, null, null, null, null, null, null, null);
    +                }
    +            } catch (IllegalArgumentException iae) {
    +                // parallel-capable class loaders: re-verify in case of a
    +                // race condition
    +                if (getAndVerifyPackage(pkgname, man, url) == null) {
    +                    // Should never happen
    +                    throw new AssertionError("Cannot find package " +
    +                                             pkgname);
    +                }
    +            }
    +        }
    +    }
    +
         /*
          * Defines a Class using the class bytes obtained from the specified
          * Resource. The resulting Class must be resolved before it can be
    @@ -420,23 +443,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
                 String pkgname = name.substring(0, i);
                 // Check if package already loaded.
                 Manifest man = res.getManifest();
    -            if (getAndVerifyPackage(pkgname, man, url) == null) {
    -                try {
    -                    if (man != null) {
    -                        definePackage(pkgname, man, url);
    -                    } else {
    -                        definePackage(pkgname, null, null, null, null, null, null, null);
    -                    }
    -                } catch (IllegalArgumentException iae) {
    -                    // parallel-capable class loaders: re-verify in case of a
    -                    // race condition
    -                    if (getAndVerifyPackage(pkgname, man, url) == null) {
    -                        // Should never happen
    -                        throw new AssertionError("Cannot find package " +
    -                                                 pkgname);
    -                    }
    -                }
    -            }
    +            definePackageInternal(pkgname, man, url);
             }
             // Now read the class bytes and define the class
             java.nio.ByteBuffer bb = res.getByteBuffer();
    diff --git a/jdk/src/java.base/share/classes/java/security/SecureRandom.java b/jdk/src/java.base/share/classes/java/security/SecureRandom.java
    index b9ae7220b38..0accb4cc7a4 100644
    --- a/jdk/src/java.base/share/classes/java/security/SecureRandom.java
    +++ b/jdk/src/java.base/share/classes/java/security/SecureRandom.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 1996, 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
    @@ -39,15 +39,16 @@ import sun.security.jca.GetInstance.Instance;
      *
      * 

    A cryptographically strong random number * minimally complies with the statistical random number generator tests - * specified in + * specified in + * * FIPS 140-2, Security Requirements for Cryptographic Modules, * section 4.9.1. * Additionally, SecureRandom must produce non-deterministic output. * Therefore any seed material passed to a SecureRandom object must be * unpredictable, and all SecureRandom output sequences must be * cryptographically strong, as described in - * - * RFC 1750: Randomness Recommendations for Security. + * + * RFC 4086: Randomness Requirements for Security. * *

    A caller obtains a SecureRandom instance via the * no-argument constructor or one of the {@code getInstance} methods: diff --git a/jdk/src/java.base/share/classes/java/text/CalendarBuilder.java b/jdk/src/java.base/share/classes/java/text/CalendarBuilder.java index a8246b676ca..cb30a358ea4 100644 --- a/jdk/src/java.base/share/classes/java/text/CalendarBuilder.java +++ b/jdk/src/java.base/share/classes/java/text/CalendarBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -26,6 +26,7 @@ package java.text; import java.util.Calendar; +import java.util.StringJoiner; import static java.util.GregorianCalendar.*; /** @@ -146,19 +147,13 @@ class CalendarBuilder { } public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("CalendarBuilder:["); + StringJoiner sj = new StringJoiner(",", "CalendarBuilder:[", "]"); for (int i = 0; i < field.length; i++) { if (isSet(i)) { - sb.append(i).append('=').append(field[MAX_FIELD + i]).append(','); + sj.add(i + "=" + field[MAX_FIELD + i]); } } - int lastIndex = sb.length() - 1; - if (sb.charAt(lastIndex) == ',') { - sb.setLength(lastIndex); - } - sb.append(']'); - return sb.toString(); + return sj.toString(); } static int toISODayOfWeek(int calendarDayOfWeek) { diff --git a/jdk/src/java.base/share/classes/java/time/Duration.java b/jdk/src/java.base/share/classes/java/time/Duration.java index cb672c4d3b4..30d146dbf64 100644 --- a/jdk/src/java.base/share/classes/java/time/Duration.java +++ b/jdk/src/java.base/share/classes/java/time/Duration.java @@ -388,19 +388,21 @@ public final class Duration Matcher matcher = PATTERN.matcher(text); if (matcher.matches()) { // check for letter T but no time sections - if ("T".equals(matcher.group(3)) == false) { - boolean negate = "-".equals(matcher.group(1)); - String dayMatch = matcher.group(2); - String hourMatch = matcher.group(4); - String minuteMatch = matcher.group(5); - String secondMatch = matcher.group(6); - String fractionMatch = matcher.group(7); - if (dayMatch != null || hourMatch != null || minuteMatch != null || secondMatch != null) { - long daysAsSecs = parseNumber(text, dayMatch, SECONDS_PER_DAY, "days"); - long hoursAsSecs = parseNumber(text, hourMatch, SECONDS_PER_HOUR, "hours"); - long minsAsSecs = parseNumber(text, minuteMatch, SECONDS_PER_MINUTE, "minutes"); - long seconds = parseNumber(text, secondMatch, 1, "seconds"); - int nanos = parseFraction(text, fractionMatch, seconds < 0 ? -1 : 1); + if (!charMatch(text, matcher.start(3), matcher.end(3), 'T')) { + boolean negate = charMatch(text, matcher.start(1), matcher.end(1), '-'); + + int dayStart = matcher.start(2), dayEnd = matcher.end(2); + int hourStart = matcher.start(4), hourEnd = matcher.end(4); + int minuteStart = matcher.start(5), minuteEnd = matcher.end(5); + int secondStart = matcher.start(6), secondEnd = matcher.end(6); + int fractionStart = matcher.start(7), fractionEnd = matcher.end(7); + + if (dayStart >= 0 || hourStart >= 0 || minuteStart >= 0 || secondStart >= 0) { + long daysAsSecs = parseNumber(text, dayStart, dayEnd, SECONDS_PER_DAY, "days"); + long hoursAsSecs = parseNumber(text, hourStart, hourEnd, SECONDS_PER_HOUR, "hours"); + long minsAsSecs = parseNumber(text, minuteStart, minuteEnd, SECONDS_PER_MINUTE, "minutes"); + long seconds = parseNumber(text, secondStart, secondEnd, 1, "seconds"); + int nanos = parseFraction(text, fractionStart, fractionEnd, seconds < 0 ? -1 : 1); try { return create(negate, daysAsSecs, hoursAsSecs, minsAsSecs, seconds, nanos); } catch (ArithmeticException ex) { @@ -412,27 +414,37 @@ public final class Duration throw new DateTimeParseException("Text cannot be parsed to a Duration", text, 0); } - private static long parseNumber(CharSequence text, String parsed, int multiplier, String errorText) { + private static boolean charMatch(CharSequence text, int start, int end, char c) { + return (start >= 0 && end == start + 1 && text.charAt(start) == c); + } + + private static long parseNumber(CharSequence text, int start, int end, int multiplier, String errorText) { // regex limits to [-+]?[0-9]+ - if (parsed == null) { + if (start < 0 || end < 0) { return 0; } try { - long val = Long.parseLong(parsed); + long val = Long.parseLong(text, 10, start, end); return Math.multiplyExact(val, multiplier); } catch (NumberFormatException | ArithmeticException ex) { throw (DateTimeParseException) new DateTimeParseException("Text cannot be parsed to a Duration: " + errorText, text, 0).initCause(ex); } } - private static int parseFraction(CharSequence text, String parsed, int negate) { + private static int parseFraction(CharSequence text, int start, int end, int negate) { // regex limits to [0-9]{0,9} - if (parsed == null || parsed.length() == 0) { + if (start < 0 || end < 0 || end - start == 0) { return 0; } try { - parsed = (parsed + "000000000").substring(0, 9); - return Integer.parseInt(parsed) * negate; + int fraction = Integer.parseInt(text, 10, start, end); + + // for number strings smaller than 9 digits, interpret as if there + // were trailing zeros + for (int i = end - start; i < 9; i++) { + fraction *= 10; + } + return fraction * negate; } catch (NumberFormatException | ArithmeticException ex) { throw (DateTimeParseException) new DateTimeParseException("Text cannot be parsed to a Duration: fraction", text, 0).initCause(ex); } diff --git a/jdk/src/java.base/share/classes/java/time/Period.java b/jdk/src/java.base/share/classes/java/time/Period.java index 5d808a42b41..88adb958fa0 100644 --- a/jdk/src/java.base/share/classes/java/time/Period.java +++ b/jdk/src/java.base/share/classes/java/time/Period.java @@ -329,17 +329,17 @@ public final class Period Objects.requireNonNull(text, "text"); Matcher matcher = PATTERN.matcher(text); if (matcher.matches()) { - int negate = ("-".equals(matcher.group(1)) ? -1 : 1); - String yearMatch = matcher.group(2); - String monthMatch = matcher.group(3); - String weekMatch = matcher.group(4); - String dayMatch = matcher.group(5); - if (yearMatch != null || monthMatch != null || dayMatch != null || weekMatch != null) { + int negate = (charMatch(text, matcher.start(1), matcher.end(1), '-') ? -1 : 1); + int yearStart = matcher.start(2), yearEnd = matcher.end(2); + int monthStart = matcher.start(3), monthEnd = matcher.end(3); + int weekStart = matcher.start(4), weekEnd = matcher.end(4); + int dayStart = matcher.start(5), dayEnd = matcher.end(5); + if (yearStart >= 0 || monthStart >= 0 || weekStart >= 0 || dayStart >= 0) { try { - int years = parseNumber(text, yearMatch, negate); - int months = parseNumber(text, monthMatch, negate); - int weeks = parseNumber(text, weekMatch, negate); - int days = parseNumber(text, dayMatch, negate); + int years = parseNumber(text, yearStart, yearEnd, negate); + int months = parseNumber(text, monthStart, monthEnd, negate); + int weeks = parseNumber(text, weekStart, weekEnd, negate); + int days = parseNumber(text, dayStart, dayEnd, negate); days = Math.addExact(days, Math.multiplyExact(weeks, 7)); return create(years, months, days); } catch (NumberFormatException ex) { @@ -350,11 +350,15 @@ public final class Period throw new DateTimeParseException("Text cannot be parsed to a Period", text, 0); } - private static int parseNumber(CharSequence text, String str, int negate) { - if (str == null) { + private static boolean charMatch(CharSequence text, int start, int end, char c) { + return (start >= 0 && end == start + 1 && text.charAt(start) == c); + } + + private static int parseNumber(CharSequence text, int start, int end, int negate) { + if (start < 0 || end < 0) { return 0; } - int val = Integer.parseInt(str); + int val = Integer.parseInt(text, 10, start, end); try { return Math.multiplyExact(val, negate); } catch (ArithmeticException ex) { diff --git a/jdk/src/java.base/share/classes/java/util/JapaneseImperialCalendar.java b/jdk/src/java.base/share/classes/java/util/JapaneseImperialCalendar.java index e37374af15f..81b769af01f 100644 --- a/jdk/src/java.base/share/classes/java/util/JapaneseImperialCalendar.java +++ b/jdk/src/java.base/share/classes/java/util/JapaneseImperialCalendar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,20 +38,20 @@ import sun.util.calendar.LocalGregorianCalendar; import sun.util.calendar.ZoneInfo; /** - * JapaneseImperialCalendar implements a Japanese + * {@code JapaneseImperialCalendar} implements a Japanese * calendar system in which the imperial era-based year numbering is * supported from the Meiji era. The following are the eras supported * by this calendar system. - *

    
    + * 
    {@code
      * ERA value   Era name    Since (in Gregorian)
      * ------------------------------------------------------
      *     0       N/A         N/A
    - *     1       Meiji       1868-01-01 midnight local time
    - *     2       Taisho      1912-07-30 midnight local time
    - *     3       Showa       1926-12-25 midnight local time
    - *     4       Heisei      1989-01-08 midnight local time
    + *     1       Meiji       1868-01-01T00:00:00 local time
    + *     2       Taisho      1912-07-30T00:00:00 local time
    + *     3       Showa       1926-12-25T00:00:00 local time
    + *     4       Heisei      1989-01-08T00:00:00 local time
      * ------------------------------------------------------
    - * 
    + * }
    * *

    ERA value 0 specifies the years before Meiji and * the Gregorian year values are used. Unlike {@link @@ -63,6 +63,31 @@ import sun.util.calendar.ZoneInfo; * with time differences for applying the era transitions. This * calendar implementation assumes local time for all transitions. * + *

    A new era can be specified using property + * jdk.calendar.japanese.supplemental.era. The new era is added to the + * predefined eras. The syntax of the property is as follows. + *

    + *   {@code name=,abbr=,since=}
    + * 
    + * where + *
    + *
    {@code :}
    the full name of the new era (non-ASCII characters allowed) + *
    {@code :}
    the abbreviation of the new era (non-ASCII characters allowed) + *
    {@code :}
    the start time of the new era represented by + * milliseconds from 1970-01-01T00:00:00 local time or UTC if {@code 'u'} is + * appended to the milliseconds value. (ASCII digits only) + *
    + * + *

    If the given era is invalid, such as the since value before the + * beginning of the last predefined era, the given era will be + * ignored. + * + *

    The following is an example of the property usage. + *

    + *   java -Djdk.calendar.japanese.supplemental.era="name=NewEra,abbr=N,since=253374307200000"
    + * 
    + * The property specifies an era change to NewEra at 9999-02-11T00:00:00 local time. + * * @author Masayoshi Okutsu * @since 1.6 */ @@ -102,7 +127,6 @@ class JapaneseImperialCalendar extends Calendar { public static final int HEISEI = 4; private static final int EPOCH_OFFSET = 719163; // Fixed date of January 1, 1970 (Gregorian) - private static final int EPOCH_YEAR = 1970; // Useful millisecond constants. Although ONE_DAY and ONE_WEEK can fit // into ints, they must be longs in order to prevent arithmetic overflow @@ -111,7 +135,6 @@ class JapaneseImperialCalendar extends Calendar { private static final int ONE_MINUTE = 60*ONE_SECOND; private static final int ONE_HOUR = 60*ONE_MINUTE; private static final long ONE_DAY = 24*ONE_HOUR; - private static final long ONE_WEEK = 7*ONE_DAY; // Reference to the sun.util.calendar.LocalGregorianCalendar instance (singleton). private static final LocalGregorianCalendar jcal @@ -217,6 +240,7 @@ class JapaneseImperialCalendar extends Calendar { }; // Proclaim serialization compatibility with JDK 1.6 + @SuppressWarnings("FieldNameHidesFieldInSuperclass") private static final long serialVersionUID = -3364572813905467929L; static { @@ -340,6 +364,7 @@ class JapaneseImperialCalendar extends Calendar { * false otherwise. * @see Calendar#compareTo(Calendar) */ + @Override public boolean equals(Object obj) { return obj instanceof JapaneseImperialCalendar && super.equals(obj); @@ -349,6 +374,7 @@ class JapaneseImperialCalendar extends Calendar { * Generates the hash code for this * JapaneseImperialCalendar object. */ + @Override public int hashCode() { return super.hashCode() ^ jdate.hashCode(); } @@ -381,6 +407,7 @@ class JapaneseImperialCalendar extends Calendar { * or if any calendar fields have out-of-range values in * non-lenient mode. */ + @Override public void add(int field, int amount) { // If amount == 0, do nothing even the given field is out of // range. This is tested by JCK. @@ -509,6 +536,7 @@ class JapaneseImperialCalendar extends Calendar { } } + @Override public void roll(int field, boolean up) { roll(field, up ? +1 : -1); } @@ -533,6 +561,7 @@ class JapaneseImperialCalendar extends Calendar { * @see #add(int,int) * @see #set(int,int) */ + @Override public void roll(int field, int amount) { // If amount == 0, do nothing even the given field is out of // range. This is tested by JCK. diff --git a/jdk/src/java.base/share/classes/java/util/Locale.java b/jdk/src/java.base/share/classes/java/util/Locale.java index fbcb2f75e66..cf29686e693 100644 --- a/jdk/src/java.base/share/classes/java/util/Locale.java +++ b/jdk/src/java.base/share/classes/java/util/Locale.java @@ -2059,14 +2059,11 @@ public final class Locale implements Cloneable, Serializable { // If we have no list patterns, compose the list in a simple, // non-localized way. if (listPattern == null || listCompositionPattern == null) { - StringBuilder result = new StringBuilder(); + StringJoiner sj = new StringJoiner(","); for (int i = 0; i < stringList.length; ++i) { - if (i > 0) { - result.append(','); - } - result.append(stringList[i]); + sj.add(stringList[i]); } - return result.toString(); + return sj.toString(); } // Compose the list down to three elements if necessary diff --git a/jdk/src/java.base/share/classes/java/util/PropertyPermission.java b/jdk/src/java.base/share/classes/java/util/PropertyPermission.java index d532bddabf6..7e818a90b64 100644 --- a/jdk/src/java.base/share/classes/java/util/PropertyPermission.java +++ b/jdk/src/java.base/share/classes/java/util/PropertyPermission.java @@ -324,20 +324,16 @@ public final class PropertyPermission extends BasicPermission { * @return the canonical string representation of the actions. */ static String getActions(int mask) { - StringBuilder sb = new StringBuilder(); - boolean comma = false; - - if ((mask & READ) == READ) { - comma = true; - sb.append("read"); + switch (mask & (READ|WRITE)) { + case READ: + return SecurityConstants.PROPERTY_READ_ACTION; + case WRITE: + return SecurityConstants.PROPERTY_WRITE_ACTION; + case READ|WRITE: + return SecurityConstants.PROPERTY_RW_ACTION; + default: + return ""; } - - if ((mask & WRITE) == WRITE) { - if (comma) sb.append(','); - else comma = true; - sb.append("write"); - } - return sb.toString(); } /** diff --git a/jdk/src/java.base/share/classes/java/util/StringJoiner.java b/jdk/src/java.base/share/classes/java/util/StringJoiner.java index b6ba84c5df8..b08a2f9b711 100644 --- a/jdk/src/java.base/share/classes/java/util/StringJoiner.java +++ b/jdk/src/java.base/share/classes/java/util/StringJoiner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -24,6 +24,9 @@ */ package java.util; +import sun.misc.JavaLangAccess; +import sun.misc.SharedSecrets; + /** * {@code StringJoiner} is used to construct a sequence of characters separated * by a delimiter and optionally starting with a supplied prefix @@ -67,22 +70,24 @@ public final class StringJoiner { private final String delimiter; private final String suffix; - /* - * StringBuilder value -- at any time, the characters constructed from the - * prefix, the added element separated by the delimiter, but without the - * suffix, so that we can more easily add elements without having to jigger - * the suffix each time. - */ - private StringBuilder value; + /** Contains all the string components added so far. */ + private String[] elts; - /* - * By default, the string consisting of prefix+suffix, returned by - * toString(), or properties of value, when no elements have yet been added, - * i.e. when it is empty. This may be overridden by the user to be some - * other value including the empty String. + /** The number of string components added so far. */ + private int size; + + /** Total length in chars so far, excluding prefix and suffix. */ + private int len; + + /** + * When overriden by the user to be non-null via {@link setEmptyValue}, the + * string returned by toString() when no elements have yet been added. + * When null, prefix + suffix is used as the empty value. */ private String emptyValue; + private static final JavaLangAccess jla = SharedSecrets.getJavaLangAccess(); + /** * Constructs a {@code StringJoiner} with no characters in it, with no * {@code prefix} or {@code suffix}, and a copy of the supplied @@ -125,7 +130,6 @@ public final class StringJoiner { this.prefix = prefix.toString(); this.delimiter = delimiter.toString(); this.suffix = suffix.toString(); - this.emptyValue = this.prefix + this.suffix; } /** @@ -148,29 +152,44 @@ public final class StringJoiner { return this; } + private static int getChars(String s, char[] chars, int start) { + int len = s.length(); + s.getChars(0, len, chars, start); + return len; + } + /** * Returns the current value, consisting of the {@code prefix}, the values * added so far separated by the {@code delimiter}, and the {@code suffix}, * unless no elements have been added in which case, the - * {@code prefix + suffix} or the {@code emptyValue} characters are returned + * {@code prefix + suffix} or the {@code emptyValue} characters are returned. * * @return the string representation of this {@code StringJoiner} */ @Override public String toString() { - if (value == null) { + final String[] elts = this.elts; + if (elts == null && emptyValue != null) { return emptyValue; - } else { - if (suffix.equals("")) { - return value.toString(); - } else { - int initialLength = value.length(); - String result = value.append(suffix).toString(); - // reset value to pre-append initialLength - value.setLength(initialLength); - return result; + } + final int size = this.size; + final int addLen = prefix.length() + suffix.length(); + if (addLen == 0) { + compactElts(); + return size == 0 ? "" : elts[0]; + } + final String delimiter = this.delimiter; + final char[] chars = new char[len + addLen]; + int k = getChars(prefix, chars, 0); + if (size > 0) { + k += getChars(elts[0], chars, k); + for (int i = 1; i < size; i++) { + k += getChars(delimiter, chars, k); + k += getChars(elts[i], chars, k); } } + k += getChars(suffix, chars, k); + return jla.newStringUnsafe(chars); } /** @@ -182,7 +201,16 @@ public final class StringJoiner { * @return a reference to this {@code StringJoiner} */ public StringJoiner add(CharSequence newElement) { - prepareBuilder().append(newElement); + final String elt = String.valueOf(newElement); + if (elts == null) { + elts = new String[8]; + } else { + if (size == elts.length) + elts = Arrays.copyOf(elts, 2 * size); + len += delimiter.length(); + } + len += elt.length(); + elts[size++] = elt; return this; } @@ -207,24 +235,25 @@ public final class StringJoiner { */ public StringJoiner merge(StringJoiner other) { Objects.requireNonNull(other); - if (other.value != null) { - final int length = other.value.length(); - // lock the length so that we can seize the data to be appended - // before initiate copying to avoid interference, especially when - // merge 'this' - StringBuilder builder = prepareBuilder(); - builder.append(other.value, other.prefix.length(), length); + if (other.elts == null) { + return this; } - return this; + other.compactElts(); + return add(other.elts[0]); } - private StringBuilder prepareBuilder() { - if (value != null) { - value.append(delimiter); - } else { - value = new StringBuilder().append(prefix); + private void compactElts() { + if (size > 1) { + final char[] chars = new char[len]; + int i = 1, k = getChars(elts[0], chars, 0); + do { + k += getChars(delimiter, chars, k); + k += getChars(elts[i], chars, k); + elts[i] = null; + } while (++i < size); + size = 1; + elts[0] = jla.newStringUnsafe(chars); } - return value; } /** @@ -238,10 +267,7 @@ public final class StringJoiner { * @return the length of the current value of {@code StringJoiner} */ public int length() { - // Remember that we never actually append the suffix unless we return - // the full (present) value or some sub-string or length of it, so that - // we can add on more if we need to. - return (value != null ? value.length() + suffix.length() : - emptyValue.length()); + return (size == 0 && emptyValue != null) ? emptyValue.length() : + len + prefix.length() + suffix.length(); } } diff --git a/jdk/src/java.base/share/classes/javax/security/auth/Subject.java b/jdk/src/java.base/share/classes/javax/security/auth/Subject.java index e8ce12c9eee..0eee83c6083 100644 --- a/jdk/src/java.base/share/classes/javax/security/auth/Subject.java +++ b/jdk/src/java.base/share/classes/javax/security/auth/Subject.java @@ -182,21 +182,20 @@ public final class Subject implements java.io.Serializable { * {@code AuthPermission("modifyPublicCredentials")}. * To modify the private credential Set, the caller must have * {@code AuthPermission("modifyPrivateCredentials")}. - *

    * * @param readOnly true if the {@code Subject} is to be read-only, - * and false otherwise.

    + * and false otherwise. * * @param principals the {@code Set} of Principals - * to be associated with this {@code Subject}.

    + * to be associated with this {@code Subject}. * * @param pubCredentials the {@code Set} of public credentials - * to be associated with this {@code Subject}.

    + * to be associated with this {@code Subject}. * * @param privCredentials the {@code Set} of private credentials * to be associated with this {@code Subject}. * - * @exception NullPointerException if the specified + * @throws NullPointerException if the specified * {@code principals}, {@code pubCredentials}, * or {@code privCredentials} are {@code null}, * or a null value exists within any of these three @@ -233,10 +232,11 @@ public final class Subject implements java.io.Serializable { * Also, once a {@code Subject} is read-only, * it can not be reset to being writable again. * - *

    - * - * @exception SecurityException if the caller does not have permission - * to set this {@code Subject} to be read-only. + * @throws SecurityException if a security manager is installed and the + * caller does not have an + * {@link AuthPermission#AuthPermission(String) + * AuthPermission("setReadOnly")} permission to set this + * {@code Subject} to be read-only. */ public void setReadOnly() { java.lang.SecurityManager sm = System.getSecurityManager(); @@ -250,8 +250,6 @@ public final class Subject implements java.io.Serializable { /** * Query whether this {@code Subject} is read-only. * - *

    - * * @return true if this {@code Subject} is read-only, false otherwise. */ public boolean isReadOnly() { @@ -267,8 +265,6 @@ public final class Subject implements java.io.Serializable { * In this situation, the most recent {@code Subject} associated * with the {@code AccessControlContext} is returned. * - *

    - * * @param acc the {@code AccessControlContext} from which to retrieve * the {@code Subject}. * @@ -277,10 +273,13 @@ public final class Subject implements java.io.Serializable { * if no {@code Subject} is associated * with the provided {@code AccessControlContext}. * - * @exception SecurityException if the caller does not have permission - * to get the {@code Subject}.

    + * @throws SecurityException if a security manager is installed and the + * caller does not have an + * {@link AuthPermission#AuthPermission(String) + * AuthPermission("getSubject")} permission to get the + * {@code Subject}. * - * @exception NullPointerException if the provided + * @throws NullPointerException if the provided * {@code AccessControlContext} is {@code null}. */ public static Subject getSubject(final AccessControlContext acc) { @@ -321,26 +320,27 @@ public final class Subject implements java.io.Serializable { * passing it the provided {@code PrivilegedAction}, * as well as the newly constructed {@code AccessControlContext}. * - *

    - * * @param subject the {@code Subject} that the specified * {@code action} will run as. This parameter - * may be {@code null}.

    + * may be {@code null}. * * @param the type of the value returned by the PrivilegedAction's * {@code run} method. * * @param action the code to be run as the specified - * {@code Subject}.

    + * {@code Subject}. * * @return the value returned by the PrivilegedAction's * {@code run} method. * - * @exception NullPointerException if the {@code PrivilegedAction} - * is {@code null}.

    + * @throws NullPointerException if the {@code PrivilegedAction} + * is {@code null}. * - * @exception SecurityException if the caller does not have permission - * to invoke this method. + * @throws SecurityException if a security manager is installed and the + * caller does not have an + * {@link AuthPermission#AuthPermission(String) + * AuthPermission("doAs")} permission to invoke this + * method. */ public static T doAs(final Subject subject, final java.security.PrivilegedAction action) { @@ -377,31 +377,32 @@ public final class Subject implements java.io.Serializable { * passing it the provided {@code PrivilegedExceptionAction}, * as well as the newly constructed {@code AccessControlContext}. * - *

    - * * @param subject the {@code Subject} that the specified * {@code action} will run as. This parameter - * may be {@code null}.

    + * may be {@code null}. * * @param the type of the value returned by the * PrivilegedExceptionAction's {@code run} method. * * @param action the code to be run as the specified - * {@code Subject}.

    + * {@code Subject}. * * @return the value returned by the * PrivilegedExceptionAction's {@code run} method. * - * @exception PrivilegedActionException if the + * @throws PrivilegedActionException if the * {@code PrivilegedExceptionAction.run} - * method throws a checked exception.

    + * method throws a checked exception. * - * @exception NullPointerException if the specified + * @throws NullPointerException if the specified * {@code PrivilegedExceptionAction} is - * {@code null}.

    + * {@code null}. * - * @exception SecurityException if the caller does not have permission - * to invoke this method. + * @throws SecurityException if a security manager is installed and the + * caller does not have an + * {@link AuthPermission#AuthPermission(String) + * AuthPermission("doAs")} permission to invoke this + * method. */ public static T doAs(final Subject subject, final java.security.PrivilegedExceptionAction action) @@ -435,29 +436,30 @@ public final class Subject implements java.io.Serializable { * this method instantiates a new {@code AccessControlContext} * with an empty collection of ProtectionDomains. * - *

    - * * @param subject the {@code Subject} that the specified * {@code action} will run as. This parameter - * may be {@code null}.

    + * may be {@code null}. * * @param the type of the value returned by the PrivilegedAction's * {@code run} method. * * @param action the code to be run as the specified - * {@code Subject}.

    + * {@code Subject}. * * @param acc the {@code AccessControlContext} to be tied to the - * specified subject and action.

    + * specified subject and action. * * @return the value returned by the PrivilegedAction's * {@code run} method. * - * @exception NullPointerException if the {@code PrivilegedAction} - * is {@code null}.

    + * @throws NullPointerException if the {@code PrivilegedAction} + * is {@code null}. * - * @exception SecurityException if the caller does not have permission - * to invoke this method. + * @throws SecurityException if a security manager is installed and the + * caller does not have a + * {@link AuthPermission#AuthPermission(String) + * AuthPermission("doAsPrivileged")} permission to invoke + * this method. */ public static T doAsPrivileged(final Subject subject, final java.security.PrivilegedAction action, @@ -495,34 +497,35 @@ public final class Subject implements java.io.Serializable { * this method instantiates a new {@code AccessControlContext} * with an empty collection of ProtectionDomains. * - *

    - * * @param subject the {@code Subject} that the specified * {@code action} will run as. This parameter - * may be {@code null}.

    + * may be {@code null}. * * @param the type of the value returned by the * PrivilegedExceptionAction's {@code run} method. * * @param action the code to be run as the specified - * {@code Subject}.

    + * {@code Subject}. * * @param acc the {@code AccessControlContext} to be tied to the - * specified subject and action.

    + * specified subject and action. * * @return the value returned by the * PrivilegedExceptionAction's {@code run} method. * - * @exception PrivilegedActionException if the + * @throws PrivilegedActionException if the * {@code PrivilegedExceptionAction.run} - * method throws a checked exception.

    + * method throws a checked exception. * - * @exception NullPointerException if the specified + * @throws NullPointerException if the specified * {@code PrivilegedExceptionAction} is - * {@code null}.

    + * {@code null}. * - * @exception SecurityException if the caller does not have permission - * to invoke this method. + * @throws SecurityException if a security manager is installed and the + * caller does not have a + * {@link AuthPermission#AuthPermission(String) + * AuthPermission("doAsPrivileged")} permission to invoke + * this method. */ public static T doAsPrivileged(final Subject subject, final java.security.PrivilegedExceptionAction action, @@ -577,9 +580,12 @@ public final class Subject implements java.io.Serializable { * to the returned {@code Set} affects the internal * {@code Principal} {@code Set} as well. * - *

    + *

    If a security manager is installed, the caller must have a + * {@link AuthPermission#AuthPermission(String) + * AuthPermission("modifyPrincipals")} permission to modify + * the returned set, or a {@code SecurityException} will be thrown. * - * @return The {@code Set} of Principals associated with this + * @return the {@code Set} of Principals associated with this * {@code Subject}. */ public Set getPrincipals() { @@ -600,8 +606,6 @@ public final class Subject implements java.io.Serializable { * Modifications to the returned {@code Set} * will not affect the internal {@code Principal} {@code Set}. * - *

    - * * @param the type of the class modeled by {@code c} * * @param c the returned {@code Set} of Principals will all be @@ -610,8 +614,8 @@ public final class Subject implements java.io.Serializable { * @return a {@code Set} of Principals that are instances of the * specified {@code Class}. * - * @exception NullPointerException if the specified {@code Class} - * is {@code null}. + * @throws NullPointerException if the specified {@code Class} + * is {@code null}. */ public Set getPrincipals(Class c) { @@ -632,9 +636,12 @@ public final class Subject implements java.io.Serializable { * to the returned {@code Set} affects the internal public * Credential {@code Set} as well. * - *

    + *

    If a security manager is installed, the caller must have a + * {@link AuthPermission#AuthPermission(String) + * AuthPermission("modifyPublicCredentials")} permission to modify + * the returned set, or a {@code SecurityException} will be thrown. * - * @return A {@code Set} of public credentials held by this + * @return a {@code Set} of public credentials held by this * {@code Subject}. */ public Set getPublicCredentials() { @@ -653,20 +660,18 @@ public final class Subject implements java.io.Serializable { * to the returned {@code Set} affects the internal private * Credential {@code Set} as well. * - *

    A caller requires permissions to access the Credentials - * in the returned {@code Set}, or to modify the - * {@code Set} itself. A {@code SecurityException} - * is thrown if the caller does not have the proper permissions. + *

    If a security manager is installed, the caller must have a + * {@link AuthPermission#AuthPermission(String) + * AuthPermission("modifyPrivateCredentials")} permission to modify + * the returned set, or a {@code SecurityException} will be thrown. * *

    While iterating through the {@code Set}, - * a {@code SecurityException} is thrown - * if the caller does not have permission to access a - * particular Credential. The {@code Iterator} - * is nevertheless advanced to next element in the {@code Set}. + * a {@code SecurityException} is thrown if a security manager is installed + * and the caller does not have a {@link PrivateCredentialPermission} + * to access a particular Credential. The {@code Iterator} + * is nevertheless advanced to the next element in the {@code Set}. * - *

    - * - * @return A {@code Set} of private credentials held by this + * @return a {@code Set} of private credentials held by this * {@code Subject}. */ public Set getPrivateCredentials() { @@ -695,8 +700,6 @@ public final class Subject implements java.io.Serializable { * Modifications to the returned {@code Set} * will not affect the internal public Credential {@code Set}. * - *

    - * * @param the type of the class modeled by {@code c} * * @param c the returned {@code Set} of public credentials will all be @@ -705,7 +708,7 @@ public final class Subject implements java.io.Serializable { * @return a {@code Set} of public credentials that are instances * of the specified {@code Class}. * - * @exception NullPointerException if the specified {@code Class} + * @throws NullPointerException if the specified {@code Class} * is {@code null}. */ public Set getPublicCredentials(Class c) { @@ -723,9 +726,9 @@ public final class Subject implements java.io.Serializable { * {@code Subject} that are instances or subclasses of the specified * {@code Class}. * - *

    The caller must have permission to access all of the - * requested Credentials, or a {@code SecurityException} - * will be thrown. + *

    If a security manager is installed, the caller must have a + * {@link PrivateCredentialPermission} to access all of the requested + * Credentials, or a {@code SecurityException} will be thrown. * *

    The returned {@code Set} is not backed by this Subject's * internal private Credential {@code Set}. A new @@ -733,8 +736,6 @@ public final class Subject implements java.io.Serializable { * Modifications to the returned {@code Set} * will not affect the internal private Credential {@code Set}. * - *

    - * * @param the type of the class modeled by {@code c} * * @param c the returned {@code Set} of private credentials will all be @@ -743,7 +744,7 @@ public final class Subject implements java.io.Serializable { * @return a {@code Set} of private credentials that are instances * of the specified {@code Class}. * - * @exception NullPointerException if the specified {@code Class} + * @throws NullPointerException if the specified {@code Class} * is {@code null}. */ public Set getPrivateCredentials(Class c) { @@ -772,19 +773,18 @@ public final class Subject implements java.io.Serializable { * equal if their {@code Principal} and {@code Credential} * Sets are equal. * - *

    - * * @param o Object to be compared for equality with this * {@code Subject}. * * @return true if the specified Object is equal to this * {@code Subject}. * - * @exception SecurityException if the caller does not have permission - * to access the private credentials for this {@code Subject}, - * or if the caller does not have permission to access the - * private credentials for the provided {@code Subject}. + * @throws SecurityException if a security manager is installed and the + * caller does not have a {@link PrivateCredentialPermission} + * permission to access the private credentials for this + * {@code Subject} or the provided {@code Subject}. */ + @Override public boolean equals(Object o) { if (o == null) { @@ -834,10 +834,9 @@ public final class Subject implements java.io.Serializable { /** * Return the String representation of this {@code Subject}. * - *

    - * * @return the String representation of this {@code Subject}. */ + @Override public String toString() { return toString(true); } @@ -895,13 +894,13 @@ public final class Subject implements java.io.Serializable { /** * Returns a hashcode for this {@code Subject}. * - *

    - * * @return a hashcode for this {@code Subject}. * - * @exception SecurityException if the caller does not have permission - * to access this Subject's private credentials. + * @throws SecurityException if a security manager is installed and the + * caller does not have a {@link PrivateCredentialPermission} + * permission to access this Subject's private credentials. */ + @Override public int hashCode() { /** @@ -996,7 +995,7 @@ public final class Subject implements java.io.Serializable { * * @param coll A {@code Collection} to be tested for null references * - * @exception NullPointerException if the specified collection is either + * @throws NullPointerException if the specified collection is either * {@code null} or contains a {@code null} element */ private static void collectionNullClean(Collection coll) { @@ -1546,7 +1545,7 @@ public final class Subject implements java.io.Serializable { } } - static class AuthPermissionHolder { + static final class AuthPermissionHolder { static final AuthPermission DO_AS_PERMISSION = new AuthPermission("doAs"); diff --git a/jdk/src/java.base/share/classes/sun/net/InetAddressCachePolicy.java b/jdk/src/java.base/share/classes/sun/net/InetAddressCachePolicy.java index 31578b50d78..f20feec8ae0 100644 --- a/jdk/src/java.base/share/classes/sun/net/InetAddressCachePolicy.java +++ b/jdk/src/java.base/share/classes/sun/net/InetAddressCachePolicy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -56,7 +56,7 @@ public final class InetAddressCachePolicy { * caching. For security reasons, this caching is made forever when * a security manager is set. */ - private static int cachePolicy = FOREVER; + private static volatile int cachePolicy = FOREVER; /* The Java-level namelookup cache policy for negative lookups: * @@ -66,7 +66,7 @@ public final class InetAddressCachePolicy { * default value is 0. It can be set to some other value for * performance reasons. */ - private static int negativeCachePolicy = NEVER; + private static volatile int negativeCachePolicy = NEVER; /* * Whether or not the cache policy for successful lookups was set @@ -110,10 +110,7 @@ public final class InetAddressCachePolicy { }); if (tmp != null) { - cachePolicy = tmp.intValue(); - if (cachePolicy < 0) { - cachePolicy = FOREVER; - } + cachePolicy = tmp < 0 ? FOREVER : tmp; propertySet = true; } else { /* No properties defined for positive caching. If there is no @@ -148,19 +145,16 @@ public final class InetAddressCachePolicy { }); if (tmp != null) { - negativeCachePolicy = tmp.intValue(); - if (negativeCachePolicy < 0) { - negativeCachePolicy = FOREVER; - } + negativeCachePolicy = tmp < 0 ? FOREVER : tmp; propertyNegativeSet = true; } } - public static synchronized int get() { + public static int get() { return cachePolicy; } - public static synchronized int getNegative() { + public static int getNegative() { return negativeCachePolicy; } @@ -190,7 +184,7 @@ public final class InetAddressCachePolicy { * @param newPolicy the value in seconds for how long the lookup * should be cached */ - public static synchronized void setNegativeIfNotSet(int newPolicy) { + public static void setNegativeIfNotSet(int newPolicy) { /* * When setting the new value we may want to signal that the * cache should be flushed, though this doesn't seem strictly @@ -200,7 +194,8 @@ public final class InetAddressCachePolicy { // Negative caching does not seem to have any security // implications. // checkValue(newPolicy, negativeCachePolicy); - negativeCachePolicy = newPolicy; + // but we should normalize negative policy + negativeCachePolicy = newPolicy < 0 ? FOREVER : newPolicy; } } diff --git a/jdk/src/java.base/share/classes/sun/net/www/MimeEntry.java b/jdk/src/java.base/share/classes/sun/net/www/MimeEntry.java index 7a7bcce453c..f96953a42d4 100644 --- a/jdk/src/java.base/share/classes/sun/net/www/MimeEntry.java +++ b/jdk/src/java.base/share/classes/sun/net/www/MimeEntry.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 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 @@ -26,6 +26,7 @@ package sun.net.www; import java.net.URL; import java.io.*; +import java.util.StringJoiner; import java.util.StringTokenizer; public class MimeEntry implements Cloneable { @@ -281,52 +282,34 @@ public class MimeEntry implements Cloneable { } public synchronized String toProperty() { - StringBuilder sb = new StringBuilder(); - - String separator = "; "; - boolean needSeparator = false; + StringJoiner sj = new StringJoiner("; "); int action = getAction(); if (action != MimeEntry.UNKNOWN) { - sb.append("action=" + actionKeywords[action]); - needSeparator = true; + sj.add("action=" + actionKeywords[action]); } String command = getLaunchString(); if (command != null && command.length() > 0) { - if (needSeparator) { - sb.append(separator); - } - sb.append("application=" + command); - needSeparator = true; + sj.add("application=" + command); } - if (getImageFileName() != null) { - if (needSeparator) { - sb.append(separator); - } - sb.append("icon=" + getImageFileName()); - needSeparator = true; + String image = getImageFileName(); + if (image != null) { + sj.add("icon=" + image); } String extensions = getExtensionsAsList(); if (extensions.length() > 0) { - if (needSeparator) { - sb.append(separator); - } - sb.append("file_extensions=" + extensions); - needSeparator = true; + sj.add("file_extensions=" + extensions); } String description = getDescription(); if (description != null && !description.equals(getType())) { - if (needSeparator) { - sb.append(separator); - } - sb.append("description=" + description); + sj.add("description=" + description); } - return sb.toString(); + return sj.toString(); } public String toString() { diff --git a/jdk/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java b/jdk/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java index 781f772c1ab..f4ade7e3dfd 100644 --- a/jdk/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java +++ b/jdk/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 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 @@ -64,6 +64,7 @@ import java.util.Iterator; import java.util.HashSet; import java.util.HashMap; import java.util.Set; +import java.util.StringJoiner; import sun.net.*; import sun.net.www.*; import sun.net.www.http.HttpClient; @@ -1386,16 +1387,11 @@ public class HttpURLConnection extends java.net.HttpURLConnection { } List l = entry.getValue(); if (l != null && !l.isEmpty()) { - StringBuilder cookieValue = new StringBuilder(); + StringJoiner cookieValue = new StringJoiner("; "); for (String value : l) { - cookieValue.append(value).append("; "); - } - // strip off the trailing '; ' - try { - requests.add(key, cookieValue.substring(0, cookieValue.length() - 2)); - } catch (StringIndexOutOfBoundsException ignored) { - // no-op + cookieValue.add(value); } + requests.add(key, cookieValue.toString()); } } } @@ -2870,20 +2866,14 @@ public class HttpURLConnection extends java.net.HttpURLConnection { sun.misc.JavaNetHttpCookieAccess access = sun.misc.SharedSecrets.getJavaNetHttpCookieAccess(); - StringBuilder retValue = new StringBuilder(); + StringJoiner retValue = new StringJoiner(","); // RFC 2965, comma separated List cookies = access.parse(value); - boolean multipleCookies = false; for (HttpCookie cookie : cookies) { // skip HttpOnly cookies - if (cookie.isHttpOnly()) - continue; - if (multipleCookies) - retValue.append(','); // RFC 2965, comma separated - retValue.append(access.header(cookie)); - multipleCookies = true; + if (!cookie.isHttpOnly()) + retValue.add(access.header(cookie)); } - - return retValue.length() == 0 ? "" : retValue.toString(); + return retValue.toString(); } return value; diff --git a/jdk/src/java.base/share/classes/sun/net/www/protocol/https/HttpsURLConnectionImpl.java b/jdk/src/java.base/share/classes/sun/net/www/protocol/https/HttpsURLConnectionImpl.java index 1ec1700ea67..c3067c044e0 100644 --- a/jdk/src/java.base/share/classes/sun/net/www/protocol/https/HttpsURLConnectionImpl.java +++ b/jdk/src/java.base/share/classes/sun/net/www/protocol/https/HttpsURLConnectionImpl.java @@ -501,7 +501,8 @@ public class HttpsURLConnectionImpl } public boolean equals(Object obj) { - return delegate.equals(obj); + return this == obj || ((obj instanceof HttpsURLConnectionImpl) && + delegate.equals(((HttpsURLConnectionImpl)obj).delegate)); } public int hashCode() { diff --git a/jdk/src/java.base/share/classes/sun/util/calendar/Era.java b/jdk/src/java.base/share/classes/sun/util/calendar/Era.java index a013c57afd2..3ab04110075 100644 --- a/jdk/src/java.base/share/classes/sun/util/calendar/Era.java +++ b/jdk/src/java.base/share/classes/sun/util/calendar/Era.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -41,20 +41,15 @@ import java.util.TimeZone; * CalendarDate. * *

    The following era names are defined in this release. - * - *

    
    + * 
    {@code
      *   Calendar system         Era name         Since (in Gregorian)
      *   -----------------------------------------------------------------------
    - *   Japanese calendar       Meiji            1868-01-01 midnight local time
    - *                           Taisho           1912-07-30 midnight local time
    - *                           Showa            1926-12-26 midnight local time
    - *                           Heisei           1989-01-08 midnight local time
    - *   Julian calendar         BeforeCommonEra  -292275055-05-16T16:47:04.192Z
    - *                           CommonEra        0000-12-30 midnight local time
    - *   Taiwanese calendar      MinGuo           1911-01-01 midnight local time
    - *   Thai Buddhist calendar  BuddhistEra      -543-01-01 midnight local time
    + *   Japanese calendar       Meiji            1868-01-01T00:00:00 local time
    + *                           Taisho           1912-07-30T00:00:00 local time
    + *                           Showa            1926-12-25T00:00:00 local time
    + *                           Heisei           1989-01-08T00:00:00 local time
      *   -----------------------------------------------------------------------
    - * 
    + * }
    * * @author Masayoshi Okutsu * @since 1.5 diff --git a/jdk/src/java.base/share/classes/sun/util/calendar/LocalGregorianCalendar.java b/jdk/src/java.base/share/classes/sun/util/calendar/LocalGregorianCalendar.java index 9a9b6637471..10cbbdceee1 100644 --- a/jdk/src/java.base/share/classes/sun/util/calendar/LocalGregorianCalendar.java +++ b/jdk/src/java.base/share/classes/sun/util/calendar/LocalGregorianCalendar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,11 +25,7 @@ package sun.util.calendar; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; -import java.util.StringTokenizer; +import java.security.AccessController; import java.util.TimeZone; /** @@ -39,6 +35,28 @@ import java.util.TimeZone; */ public class LocalGregorianCalendar extends BaseCalendar { + private static final Era[] JAPANESE_ERAS = { + new Era("Meiji", "M", -3218832000000L, true), + new Era("Taisho", "T", -1812153600000L, true), + new Era("Showa", "S", -1357603200000L, true), + new Era("Heisei", "H", 600220800000L, true), + }; + + private static boolean isValidEra(Era newEra, Era[] eras) { + Era last = eras[eras.length - 1]; + if (last.getSinceDate().getYear() >= newEra.getSinceDate().getYear()) { + return false; + } + // The new era name should be unique. Its abbr may not. + String newName = newEra.getName(); + for (Era era : eras) { + if (era.getName().equals(newName)) { + return false; + } + } + return true; + } + private String name; private Era[] eras; @@ -118,58 +136,70 @@ public class LocalGregorianCalendar extends BaseCalendar { } static LocalGregorianCalendar getLocalGregorianCalendar(String name) { - Properties calendarProps; - try { - calendarProps = CalendarSystem.getCalendarProperties(); - } catch (IOException | IllegalArgumentException e) { - throw new InternalError(e); - } - // Parse calendar.*.eras - String props = calendarProps.getProperty("calendar." + name + ".eras"); - if (props == null) { + // Only the Japanese calendar is supported. + if (!"japanese".equals(name)) { return null; } - List eras = new ArrayList<>(); - StringTokenizer eraTokens = new StringTokenizer(props, ";"); - while (eraTokens.hasMoreTokens()) { - String items = eraTokens.nextToken().trim(); - StringTokenizer itemTokens = new StringTokenizer(items, ","); - String eraName = null; - boolean localTime = true; - long since = 0; - String abbr = null; - while (itemTokens.hasMoreTokens()) { - String item = itemTokens.nextToken(); - int index = item.indexOf('='); - // it must be in the key=value form. - if (index == -1) { - return null; - } - String key = item.substring(0, index); - String value = item.substring(index + 1); - if ("name".equals(key)) { - eraName = value; - } else if ("since".equals(key)) { - if (value.endsWith("u")) { - localTime = false; - since = Long.parseLong(value.substring(0, value.length() - 1)); - } else { - since = Long.parseLong(value); - } - } else if ("abbr".equals(key)) { - abbr = value; - } else { - throw new RuntimeException("Unknown key word: " + key); + // Append an era to the predefined eras if it's given by the property. + String prop = AccessController.doPrivileged( + new sun.security.action.GetPropertyAction("jdk.calendar.japanese.supplemental.era")); + if (prop != null) { + Era era = parseEraEntry(prop); + if (era != null) { + if (isValidEra(era, JAPANESE_ERAS)) { + int length = JAPANESE_ERAS.length; + Era[] eras = new Era[length + 1]; + System.arraycopy(JAPANESE_ERAS, 0, eras, 0, length); + eras[length] = era; + return new LocalGregorianCalendar(name, eras); } } - Era era = new Era(eraName, abbr, since, localTime); - eras.add(era); } - Era[] eraArray = new Era[eras.size()]; - eras.toArray(eraArray); + return new LocalGregorianCalendar(name, JAPANESE_ERAS); + } - return new LocalGregorianCalendar(name, eraArray); + private static Era parseEraEntry(String entry) { + String[] keyValuePairs = entry.split(","); + String eraName = null; + boolean localTime = true; + long since = 0; + String abbr = null; + + for (String item : keyValuePairs) { + String[] keyvalue = item.split("="); + if (keyvalue.length != 2) { + return null; + } + String key = keyvalue[0].trim(); + String value = keyvalue[1].trim(); + switch (key) { + case "name": + eraName = value; + break; + case "since": + if (value.endsWith("u")) { + localTime = false; + value = value.substring(0, value.length() - 1); + } + try { + since = Long.parseLong(value); + } catch (NumberFormatException e) { + return null; + } + break; + case "abbr": + abbr = value; + break; + default: + return null; + } + } + if (eraName == null || eraName.isEmpty() + || abbr == null || abbr.isEmpty()) { + return null; + } + return new Era(eraName, abbr, since, localTime); } private LocalGregorianCalendar(String name, Era[] eras) { @@ -262,9 +292,8 @@ public class LocalGregorianCalendar extends BaseCalendar { } private boolean validateEra(Era era) { - // Validate the era - for (int i = 0; i < eras.length; i++) { - if (era == eras[i]) { + for (Era era1 : eras) { + if (era == era1) { return true; } } @@ -333,6 +362,7 @@ public class LocalGregorianCalendar extends BaseCalendar { } if (i >= 0) { ldate.setLocalEra(era); + @SuppressWarnings("null") int y = ldate.getNormalizedYear() - era.getSinceDate().getYear() + 1; ldate.setLocalYear(y); } else { diff --git a/jdk/src/java.base/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java b/jdk/src/java.base/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java index 77f7b843d64..bda94f63bec 100644 --- a/jdk/src/java.base/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java +++ b/jdk/src/java.base/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -30,6 +30,7 @@ import java.security.AccessController; import java.security.PrivilegedAction; import java.text.spi.BreakIteratorProvider; import java.text.spi.CollatorProvider; +import java.util.Collections; import java.util.HashSet; import java.util.Locale; import java.util.ResourceBundle; @@ -102,6 +103,9 @@ public class CLDRLocaleProviderAdapter extends JRELocaleProviderAdapter { @Override protected Set createLanguageTagSet(String category) { ResourceBundle rb = ResourceBundle.getBundle("sun.util.cldr.CLDRLocaleDataMetaInfo", Locale.ROOT); + if (rb.containsKey(category)) { + return Collections.emptySet(); + } String supportedLocaleString = rb.getString(category); Set tagset = new HashSet<>(); StringTokenizer tokens = new StringTokenizer(supportedLocaleString); diff --git a/jdk/src/java.base/share/classes/sun/util/locale/BaseLocale.java b/jdk/src/java.base/share/classes/sun/util/locale/BaseLocale.java index 6eee5829095..137fd82f7dd 100644 --- a/jdk/src/java.base/share/classes/sun/util/locale/BaseLocale.java +++ b/jdk/src/java.base/share/classes/sun/util/locale/BaseLocale.java @@ -32,6 +32,7 @@ package sun.util.locale; +import java.util.StringJoiner; public final class BaseLocale { @@ -120,33 +121,20 @@ public final class BaseLocale { @Override public String toString() { - StringBuilder buf = new StringBuilder(); + StringJoiner sj = new StringJoiner(", "); if (language.length() > 0) { - buf.append("language="); - buf.append(language); + sj.add("language=" + language); } if (script.length() > 0) { - if (buf.length() > 0) { - buf.append(", "); - } - buf.append("script="); - buf.append(script); + sj.add("script=" + script); } if (region.length() > 0) { - if (buf.length() > 0) { - buf.append(", "); - } - buf.append("region="); - buf.append(region); + sj.add("region=" + region); } if (variant.length() > 0) { - if (buf.length() > 0) { - buf.append(", "); - } - buf.append("variant="); - buf.append(variant); + sj.add("variant=" + variant); } - return buf.toString(); + return sj.toString(); } @Override diff --git a/jdk/src/java.base/share/classes/sun/util/locale/LanguageTag.java b/jdk/src/java.base/share/classes/sun/util/locale/LanguageTag.java index 2247398c400..3fd7f7dbe5e 100644 --- a/jdk/src/java.base/share/classes/sun/util/locale/LanguageTag.java +++ b/jdk/src/java.base/share/classes/sun/util/locale/LanguageTag.java @@ -37,6 +37,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.StringJoiner; public class LanguageTag { // @@ -473,21 +474,18 @@ public class LanguageTag { } if (!varitr.isDone()) { // ill-formed variant subtags - StringBuilder buf = new StringBuilder(); + StringJoiner sj = new StringJoiner(SEP); while (!varitr.isDone()) { String prvv = varitr.current(); if (!isPrivateuseSubtag(prvv)) { // cannot use private use subtag - truncated break; } - if (buf.length() > 0) { - buf.append(SEP); - } - buf.append(prvv); + sj.add(prvv); varitr.next(); } - if (buf.length() > 0) { - privuseVar = buf.toString(); + if (sj.length() > 0) { + privuseVar = sj.toString(); } } } diff --git a/jdk/src/java.base/share/classes/sun/util/locale/UnicodeLocaleExtension.java b/jdk/src/java.base/share/classes/sun/util/locale/UnicodeLocaleExtension.java index cc5a5685cd0..51a723aea25 100644 --- a/jdk/src/java.base/share/classes/sun/util/locale/UnicodeLocaleExtension.java +++ b/jdk/src/java.base/share/classes/sun/util/locale/UnicodeLocaleExtension.java @@ -1,6 +1,6 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -38,6 +38,7 @@ import java.util.Map.Entry; import java.util.Set; import java.util.SortedMap; import java.util.SortedSet; +import java.util.StringJoiner; public class UnicodeLocaleExtension extends Extension { public static final char SINGLETON = 'u'; @@ -70,20 +71,20 @@ public class UnicodeLocaleExtension extends Extension { } if (!this.attributes.isEmpty() || !this.keywords.isEmpty()) { - StringBuilder sb = new StringBuilder(); + StringJoiner sj = new StringJoiner(LanguageTag.SEP); for (String attribute : this.attributes) { - sb.append(LanguageTag.SEP).append(attribute); + sj.add(attribute); } for (Entry keyword : this.keywords.entrySet()) { String key = keyword.getKey(); String value = keyword.getValue(); - sb.append(LanguageTag.SEP).append(key); + sj.add(key); if (value.length() > 0) { - sb.append(LanguageTag.SEP).append(value); + sj.add(value); } } - setValue(sb.substring(1)); // skip leading '-' + setValue(sj.toString()); } } diff --git a/jdk/src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java b/jdk/src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java index 50473cde715..f07d793a88d 100644 --- a/jdk/src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java +++ b/jdk/src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -34,6 +34,7 @@ import java.text.spi.DateFormatProvider; import java.text.spi.DateFormatSymbolsProvider; import java.text.spi.DecimalFormatSymbolsProvider; import java.text.spi.NumberFormatProvider; +import java.util.Collections; import java.util.HashSet; import java.util.Locale; import java.util.Set; @@ -356,6 +357,9 @@ public class JRELocaleProviderAdapter extends LocaleProviderAdapter implements R protected Set createLanguageTagSet(String category) { String supportedLocaleString = LocaleDataMetaInfo.getSupportedLocaleString(category); + if (supportedLocaleString == null) { + return Collections.emptySet(); + } Set tagset = new HashSet<>(); StringTokenizer tokens = new StringTokenizer(supportedLocaleString); while (tokens.hasMoreTokens()) { diff --git a/jdk/src/java.base/share/classes/sun/util/locale/provider/LocaleDataMetaInfo-XLocales.java.template b/jdk/src/java.base/share/classes/sun/util/locale/provider/LocaleDataMetaInfo-XLocales.java.template index 17d9af65817..52ac29de777 100644 --- a/jdk/src/java.base/share/classes/sun/util/locale/provider/LocaleDataMetaInfo-XLocales.java.template +++ b/jdk/src/java.base/share/classes/sun/util/locale/provider/LocaleDataMetaInfo-XLocales.java.template @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,6 +57,12 @@ public class LocaleDataMetaInfo { resourceNameToLocales.put("CollationData", " #CollationData_ENLocales# | #CollationData_NonENLocales# "); + resourceNameToLocales.put("BreakIteratorInfo", + " #BreakIteratorInfo_ENLocales# | #BreakIteratorInfo_NonENLocales# "); + + resourceNameToLocales.put("BreakIteratorRules", + " #BreakIteratorRules_ENLocales# | #BreakIteratorRules_NonENLocales# "); + resourceNameToLocales.put("TimeZoneNames", " #TimeZoneNames_ENLocales# | #TimeZoneNames_NonENLocales# "); diff --git a/jdk/src/java.base/share/classes/sun/util/locale/provider/LocaleProviderAdapter.java b/jdk/src/java.base/share/classes/sun/util/locale/provider/LocaleProviderAdapter.java index b7ba7361d2b..3f7222172d7 100644 --- a/jdk/src/java.base/share/classes/sun/util/locale/provider/LocaleProviderAdapter.java +++ b/jdk/src/java.base/share/classes/sun/util/locale/provider/LocaleProviderAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -295,7 +295,7 @@ public abstract class LocaleProviderAdapter { * A utility method for implementing the default LocaleServiceProvider.isSupportedLocale * for the JRE, CLDR, and FALLBACK adapters. */ - static boolean isSupportedLocale(Locale locale, LocaleProviderAdapter.Type type, Set langtags) { + public static boolean isSupportedLocale(Locale locale, LocaleProviderAdapter.Type type, Set langtags) { assert type == Type.JRE || type == Type.CLDR || type == Type.FALLBACK; if (Locale.ROOT.equals(locale)) { return true; diff --git a/jdk/src/java.base/share/classes/sun/util/locale/provider/RuleBasedBreakIterator.java b/jdk/src/java.base/share/classes/sun/util/locale/provider/RuleBasedBreakIterator.java index f8c68fa35c2..a1962e463da 100644 --- a/jdk/src/java.base/share/classes/sun/util/locale/provider/RuleBasedBreakIterator.java +++ b/jdk/src/java.base/share/classes/sun/util/locale/provider/RuleBasedBreakIterator.java @@ -547,12 +547,7 @@ class RuleBasedBreakIterator extends BreakIterator { */ @Override public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append('['); - sb.append("checksum=0x"); - sb.append(Long.toHexString(checksum)); - sb.append(']'); - return sb.toString(); + return "[checksum=0x" + Long.toHexString(checksum) + ']'; } /** diff --git a/jdk/src/java.base/share/classes/sun/util/resources/LocaleData.java b/jdk/src/java.base/share/classes/sun/util/resources/LocaleData.java index 00ba6dec959..679baf6ebbb 100644 --- a/jdk/src/java.base/share/classes/sun/util/resources/LocaleData.java +++ b/jdk/src/java.base/share/classes/sun/util/resources/LocaleData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -48,8 +48,11 @@ import java.util.List; import java.util.Locale; import java.util.MissingResourceException; import java.util.ResourceBundle; +import java.util.Set; +import sun.util.locale.provider.JRELocaleProviderAdapter; import sun.util.locale.provider.LocaleDataMetaInfo; import sun.util.locale.provider.LocaleProviderAdapter; +import static sun.util.locale.provider.LocaleProviderAdapter.Type.CLDR; import static sun.util.locale.provider.LocaleProviderAdapter.Type.JRE; /** @@ -204,35 +207,23 @@ public class LocaleData { @Override public List getCandidateLocales(String baseName, Locale locale) { List candidates = super.getCandidateLocales(baseName, locale); - /* Get the locale string list from LocaleDataMetaInfo class. */ - String localeString = LocaleDataMetaInfo.getSupportedLocaleString(baseName); - - if (localeString != null && localeString.length() != 0) { - for (Iterator l = candidates.iterator(); l.hasNext();) { - Locale loc = l.next(); - String lstr; - if (loc.getScript().length() > 0) { - lstr = loc.toLanguageTag().replace('-', '_'); - } else { - lstr = loc.toString(); - int idx = lstr.indexOf("_#"); - if (idx >= 0) { - lstr = lstr.substring(0, idx); - } - } - /* Every locale string in the locale string list returned from - the above getSupportedLocaleString is enclosed - within two white spaces so that we could check some locale - such as "en". - */ - if (lstr.length() != 0 && localeString.indexOf(" " + lstr + " ") == -1) { - l.remove(); + // Weed out Locales which are known to have no resource bundles + int lastDot = baseName.lastIndexOf('.'); + String category = (lastDot >= 0) ? baseName.substring(lastDot + 1) : baseName; + LocaleProviderAdapter.Type type = baseName.contains(DOTCLDR) ? CLDR : JRE; + LocaleProviderAdapter adapter = LocaleProviderAdapter.forType(type); + Set langtags = ((JRELocaleProviderAdapter)adapter).getLanguageTagSet(category); + if (!langtags.isEmpty()) { + for (Iterator itr = candidates.iterator(); itr.hasNext();) { + if (!LocaleProviderAdapter.isSupportedLocale(itr.next(), type, langtags)) { + itr.remove(); } } } + // Force fallback to Locale.ENGLISH for CLDR time zone names support if (locale.getLanguage() != "en" - && baseName.contains(CLDR) && baseName.endsWith("TimeZoneNames")) { + && type == CLDR && category.equals("TimeZoneNames")) { candidates.add(candidates.size() - 1, Locale.ENGLISH); } return candidates; @@ -254,7 +245,7 @@ public class LocaleData { return null; } - private static final String CLDR = ".cldr"; + private static final String DOTCLDR = ".cldr"; /** * Changes baseName to its per-language package name and @@ -275,8 +266,8 @@ public class LocaleData { assert JRE.getUtilResourcesPackage().length() == JRE.getTextResourcesPackage().length(); int index = JRE.getUtilResourcesPackage().length(); - if (baseName.indexOf(CLDR, index) > 0) { - index += CLDR.length(); + if (baseName.indexOf(DOTCLDR, index) > 0) { + index += DOTCLDR.length(); } newBaseName = baseName.substring(0, index + 1) + lang + baseName.substring(index); diff --git a/jdk/src/java.base/share/conf/calendars.properties b/jdk/src/java.base/share/conf/calendars.properties index 49f68aca492..46bb0e2bd60 100644 --- a/jdk/src/java.base/share/conf/calendars.properties +++ b/jdk/src/java.base/share/conf/calendars.properties @@ -1,4 +1,4 @@ -# Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -22,37 +22,6 @@ # questions. # -# -# Japanese imperial calendar -# -# Meiji since 1868-01-01 00:00:00 local time (Gregorian) -# Taisho since 1912-07-30 00:00:00 local time (Gregorian) -# Showa since 1926-12-25 00:00:00 local time (Gregorian) -# Heisei since 1989-01-08 00:00:00 local time (Gregorian) -calendar.japanese.type: LocalGregorianCalendar -calendar.japanese.eras: \ - name=Meiji,abbr=M,since=-3218832000000; \ - name=Taisho,abbr=T,since=-1812153600000; \ - name=Showa,abbr=S,since=-1357603200000; \ - name=Heisei,abbr=H,since=600220800000 - -# -# Taiwanese calendar -# Minguo since 1911-01-01 00:00:00 local time (Gregorian) -calendar.taiwanese.type: LocalGregorianCalendar -calendar.taiwanese.eras: \ - name=MinGuo,since=-1830384000000 - -# -# Thai Buddhist calendar -# Buddhist Era since -542-01-01 00:00:00 local time (Gregorian) -calendar.thai-buddhist.type: LocalGregorianCalendar -calendar.thai-buddhist.eras: \ - name=BuddhistEra,abbr=B.E.,since=-79302585600000 -calendar.thai-buddhist.year-boundary: \ - day1=4-1,since=-79302585600000; \ - day1=1-1,since=-915148800000 - # # Hijrah calendars # diff --git a/jdk/src/java.base/share/conf/security/java.security-windows b/jdk/src/java.base/share/conf/security/java.security similarity index 94% rename from jdk/src/java.base/share/conf/security/java.security-windows rename to jdk/src/java.base/share/conf/security/java.security index bd34766c653..7f7bc9c383d 100644 --- a/jdk/src/java.base/share/conf/security/java.security-windows +++ b/jdk/src/java.base/share/conf/security/java.security @@ -65,16 +65,25 @@ # # List of providers and their preference orders (see above): # -security.provider.1=sun.security.provider.Sun -security.provider.2=sun.security.rsa.SunRsaSign -security.provider.3=sun.security.ec.SunEC -security.provider.4=com.sun.net.ssl.internal.ssl.Provider -security.provider.5=com.sun.crypto.provider.SunJCE -security.provider.6=sun.security.jgss.SunProvider -security.provider.7=com.sun.security.sasl.Provider -security.provider.8=org.jcp.xml.dsig.internal.dom.XMLDSigRI -security.provider.9=sun.security.smartcardio.SunPCSC -security.provider.10=sun.security.mscapi.SunMSCAPI +#ifdef solaris +security.provider.tbd=com.oracle.security.ucrypto.UcryptoProvider ${java.home}/lib/security/ucrypto-solaris.cfg +security.provider.tbd=sun.security.pkcs11.SunPKCS11 ${java.home}/lib/security/sunpkcs11-solaris.cfg +#endif +security.provider.tbd=sun.security.provider.Sun +security.provider.tbd=sun.security.rsa.SunRsaSign +security.provider.tbd=sun.security.ec.SunEC +security.provider.tbd=com.sun.net.ssl.internal.ssl.Provider +security.provider.tbd=com.sun.crypto.provider.SunJCE +security.provider.tbd=sun.security.jgss.SunProvider +security.provider.tbd=com.sun.security.sasl.Provider +security.provider.tbd=org.jcp.xml.dsig.internal.dom.XMLDSigRI +security.provider.tbd=sun.security.smartcardio.SunPCSC +#ifdef windows +security.provider.tbd=sun.security.mscapi.SunMSCAPI +#endif +#ifdef macosx +security.provider.tbd=apple.security.AppleProvider +#endif # # Sun Provider SecureRandom seed source. @@ -127,7 +136,12 @@ securerandom.source=file:/dev/random # This is a comma-separated list of algorithm and/or algorithm:provider # entries. # +#ifdef windows securerandom.strongAlgorithms=Windows-PRNG:SunMSCAPI,SHA1PRNG:SUN +#endif +#ifndef windows +securerandom.strongAlgorithms=NativePRNGBlocking:SUN +#endif # # Class to instantiate as the javax.security.auth.login.Configuration @@ -212,7 +226,9 @@ package.access=sun.,\ jdk.nashorn.internal.,\ jdk.nashorn.tools.,\ com.sun.activation.registries.,\ - com.sun.java.accessibility. +#ifdef macosx + apple.,\ +#endif # # List of comma-separated packages that start with or equal this string @@ -259,7 +275,9 @@ package.definition=sun.,\ jdk.nashorn.internal.,\ jdk.nashorn.tools.,\ com.sun.activation.registries.,\ - com.sun.java.accessibility. +#ifdef macosx + apple.,\ +#endif # # Determines whether this properties file can be appended to diff --git a/jdk/src/java.base/share/conf/security/java.security-aix b/jdk/src/java.base/share/conf/security/java.security-aix deleted file mode 100644 index 77540a3e506..00000000000 --- a/jdk/src/java.base/share/conf/security/java.security-aix +++ /dev/null @@ -1,496 +0,0 @@ -# -# This is the "master security properties file". -# -# An alternate java.security properties file may be specified -# from the command line via the system property -# -# -Djava.security.properties= -# -# This properties file appends to the master security properties file. -# If both properties files specify values for the same key, the value -# from the command-line properties file is selected, as it is the last -# one loaded. -# -# Also, if you specify -# -# -Djava.security.properties== (2 equals), -# -# then that properties file completely overrides the master security -# properties file. -# -# To disable the ability to specify an additional properties file from -# the command line, set the key security.overridePropertiesFile -# to false in the master security properties file. It is set to true -# by default. - -# In this file, various security properties are set for use by -# java.security classes. This is where users can statically register -# Cryptography Package Providers ("providers" for short). The term -# "provider" refers to a package or set of packages that supply a -# concrete implementation of a subset of the cryptography aspects of -# the Java Security API. A provider may, for example, implement one or -# more digital signature algorithms or message digest algorithms. -# -# Each provider must implement a subclass of the Provider class. -# To register a provider in this master security properties file, -# specify the Provider subclass name and priority in the format -# -# security.provider.= -# -# This declares a provider, and specifies its preference -# order n. The preference order is the order in which providers are -# searched for requested algorithms (when no specific provider is -# requested). The order is 1-based; 1 is the most preferred, followed -# by 2, and so on. -# -# must specify the subclass of the Provider class whose -# constructor sets the values of various properties that are required -# for the Java Security API to look up the algorithms or other -# facilities implemented by the provider. -# -# There must be at least one provider specification in java.security. -# There is a default provider that comes standard with the JDK. It -# is called the "SUN" provider, and its Provider subclass -# named Sun appears in the sun.security.provider package. Thus, the -# "SUN" provider is registered via the following: -# -# security.provider.1=sun.security.provider.Sun -# -# (The number 1 is used for the default provider.) -# -# Note: Providers can be dynamically registered instead by calls to -# either the addProvider or insertProviderAt method in the Security -# class. - -# -# List of providers and their preference orders (see above): -# -security.provider.1=sun.security.provider.Sun -security.provider.2=sun.security.rsa.SunRsaSign -security.provider.3=sun.security.ec.SunEC -security.provider.4=com.sun.net.ssl.internal.ssl.Provider -security.provider.5=com.sun.crypto.provider.SunJCE -security.provider.6=sun.security.jgss.SunProvider -security.provider.7=com.sun.security.sasl.Provider -security.provider.8=org.jcp.xml.dsig.internal.dom.XMLDSigRI -security.provider.9=sun.security.smartcardio.SunPCSC - -# -# Sun Provider SecureRandom seed source. -# -# Select the primary source of seed data for the "SHA1PRNG" and -# "NativePRNG" SecureRandom implementations in the "Sun" provider. -# (Other SecureRandom implementations might also use this property.) -# -# On Unix-like systems (for example, Solaris/Linux/MacOS), the -# "NativePRNG" and "SHA1PRNG" implementations obtains seed data from -# special device files such as file:/dev/random. -# -# On Windows systems, specifying the URLs "file:/dev/random" or -# "file:/dev/urandom" will enable the native Microsoft CryptoAPI seeding -# mechanism for SHA1PRNG. -# -# By default, an attempt is made to use the entropy gathering device -# specified by the "securerandom.source" Security property. If an -# exception occurs while accessing the specified URL: -# -# SHA1PRNG: -# the traditional system/thread activity algorithm will be used. -# -# NativePRNG: -# a default value of /dev/random will be used. If neither -# are available, the implementation will be disabled. -# "file" is the only currently supported protocol type. -# -# The entropy gathering device can also be specified with the System -# property "java.security.egd". For example: -# -# % java -Djava.security.egd=file:/dev/random MainClass -# -# Specifying this System property will override the -# "securerandom.source" Security property. -# -# In addition, if "file:/dev/random" or "file:/dev/urandom" is -# specified, the "NativePRNG" implementation will be more preferred than -# SHA1PRNG in the Sun provider. -# -securerandom.source=file:/dev/random - -# -# A list of known strong SecureRandom implementations. -# -# To help guide applications in selecting a suitable strong -# java.security.SecureRandom implementation, Java distributions should -# indicate a list of known strong implementations using the property. -# -# This is a comma-separated list of algorithm and/or algorithm:provider -# entries. -# -securerandom.strongAlgorithms=NativePRNGBlocking:SUN - -# -# Class to instantiate as the javax.security.auth.login.Configuration -# provider. -# -login.configuration.provider=sun.security.provider.ConfigFile - -# -# Default login configuration file -# -#login.config.url.1=file:${user.home}/.java.login.config - -# -# Class to instantiate as the system Policy. This is the name of the class -# that will be used as the Policy object. -# -policy.provider=sun.security.provider.PolicyFile - -# The default is to have a single system-wide policy file, -# and a policy file in the user's home directory. -policy.url.1=file:${java.home}/lib/security/java.policy -policy.url.2=file:${user.home}/.java.policy - -# whether or not we expand properties in the policy file -# if this is set to false, properties (${...}) will not be expanded in policy -# files. -policy.expandProperties=true - -# whether or not we allow an extra policy to be passed on the command line -# with -Djava.security.policy=somefile. Comment out this line to disable -# this feature. -policy.allowSystemProperty=true - -# whether or not we look into the IdentityScope for trusted Identities -# when encountering a 1.1 signed JAR file. If the identity is found -# and is trusted, we grant it AllPermission. -policy.ignoreIdentityScope=false - -# -# Default keystore type. -# -keystore.type=jks - -# -# List of comma-separated packages that start with or equal this string -# will cause a security exception to be thrown when -# passed to checkPackageAccess unless the -# corresponding RuntimePermission ("accessClassInPackage."+package) has -# been granted. -package.access=sun.,\ - com.sun.xml.internal.,\ - com.sun.imageio.,\ - com.sun.istack.internal.,\ - com.sun.jmx.,\ - com.sun.media.sound.,\ - com.sun.naming.internal.,\ - com.sun.proxy.,\ - com.sun.corba.se.,\ - com.sun.org.apache.bcel.internal.,\ - com.sun.org.apache.regexp.internal.,\ - com.sun.org.apache.xerces.internal.,\ - com.sun.org.apache.xpath.internal.,\ - com.sun.org.apache.xalan.internal.extensions.,\ - com.sun.org.apache.xalan.internal.lib.,\ - com.sun.org.apache.xalan.internal.res.,\ - com.sun.org.apache.xalan.internal.templates.,\ - com.sun.org.apache.xalan.internal.utils.,\ - com.sun.org.apache.xalan.internal.xslt.,\ - com.sun.org.apache.xalan.internal.xsltc.cmdline.,\ - com.sun.org.apache.xalan.internal.xsltc.compiler.,\ - com.sun.org.apache.xalan.internal.xsltc.trax.,\ - com.sun.org.apache.xalan.internal.xsltc.util.,\ - com.sun.org.apache.xml.internal.res.,\ - com.sun.org.apache.xml.internal.security.,\ - com.sun.org.apache.xml.internal.serializer.utils.,\ - com.sun.org.apache.xml.internal.utils.,\ - com.sun.org.glassfish.,\ - com.oracle.xmlns.internal.,\ - com.oracle.webservices.internal.,\ - org.jcp.xml.dsig.internal.,\ - jdk.internal.,\ - jdk.nashorn.internal.,\ - jdk.nashorn.tools. - - -# -# List of comma-separated packages that start with or equal this string -# will cause a security exception to be thrown when -# passed to checkPackageDefinition unless the -# corresponding RuntimePermission ("defineClassInPackage."+package) has -# been granted. -# -# by default, none of the class loaders supplied with the JDK call -# checkPackageDefinition. -# -package.definition=sun.,\ - com.sun.xml.internal.,\ - com.sun.imageio.,\ - com.sun.istack.internal.,\ - com.sun.jmx.,\ - com.sun.media.sound.,\ - com.sun.naming.internal.,\ - com.sun.proxy.,\ - com.sun.corba.se.,\ - com.sun.org.apache.bcel.internal.,\ - com.sun.org.apache.regexp.internal.,\ - com.sun.org.apache.xerces.internal.,\ - com.sun.org.apache.xpath.internal.,\ - com.sun.org.apache.xalan.internal.extensions.,\ - com.sun.org.apache.xalan.internal.lib.,\ - com.sun.org.apache.xalan.internal.res.,\ - com.sun.org.apache.xalan.internal.templates.,\ - com.sun.org.apache.xalan.internal.utils.,\ - com.sun.org.apache.xalan.internal.xslt.,\ - com.sun.org.apache.xalan.internal.xsltc.cmdline.,\ - com.sun.org.apache.xalan.internal.xsltc.compiler.,\ - com.sun.org.apache.xalan.internal.xsltc.trax.,\ - com.sun.org.apache.xalan.internal.xsltc.util.,\ - com.sun.org.apache.xml.internal.res.,\ - com.sun.org.apache.xml.internal.security.,\ - com.sun.org.apache.xml.internal.serializer.utils.,\ - com.sun.org.apache.xml.internal.utils.,\ - com.sun.org.glassfish.,\ - com.oracle.xmlns.internal.,\ - com.oracle.webservices.internal.,\ - org.jcp.xml.dsig.internal.,\ - jdk.internal.,\ - jdk.nashorn.internal.,\ - jdk.nashorn.tools. - - -# -# Determines whether this properties file can be appended to -# or overridden on the command line via -Djava.security.properties -# -security.overridePropertiesFile=true - -# -# Determines the default key and trust manager factory algorithms for -# the javax.net.ssl package. -# -ssl.KeyManagerFactory.algorithm=SunX509 -ssl.TrustManagerFactory.algorithm=PKIX - -# -# The Java-level namelookup cache policy for successful lookups: -# -# any negative value: caching forever -# any positive value: the number of seconds to cache an address for -# zero: do not cache -# -# default value is forever (FOREVER). For security reasons, this -# caching is made forever when a security manager is set. When a security -# manager is not set, the default behavior in this implementation -# is to cache for 30 seconds. -# -# NOTE: setting this to anything other than the default value can have -# serious security implications. Do not set it unless -# you are sure you are not exposed to DNS spoofing attack. -# -#networkaddress.cache.ttl=-1 - -# The Java-level namelookup cache policy for failed lookups: -# -# any negative value: cache forever -# any positive value: the number of seconds to cache negative lookup results -# zero: do not cache -# -# In some Microsoft Windows networking environments that employ -# the WINS name service in addition to DNS, name service lookups -# that fail may take a noticeably long time to return (approx. 5 seconds). -# For this reason the default caching policy is to maintain these -# results for 10 seconds. -# -# -networkaddress.cache.negative.ttl=10 - -# -# Properties to configure OCSP for certificate revocation checking -# - -# Enable OCSP -# -# By default, OCSP is not used for certificate revocation checking. -# This property enables the use of OCSP when set to the value "true". -# -# NOTE: SocketPermission is required to connect to an OCSP responder. -# -# Example, -# ocsp.enable=true - -# -# Location of the OCSP responder -# -# By default, the location of the OCSP responder is determined implicitly -# from the certificate being validated. This property explicitly specifies -# the location of the OCSP responder. The property is used when the -# Authority Information Access extension (defined in RFC 3280) is absent -# from the certificate or when it requires overriding. -# -# Example, -# ocsp.responderURL=http://ocsp.example.net:80 - -# -# Subject name of the OCSP responder's certificate -# -# By default, the certificate of the OCSP responder is that of the issuer -# of the certificate being validated. This property identifies the certificate -# of the OCSP responder when the default does not apply. Its value is a string -# distinguished name (defined in RFC 2253) which identifies a certificate in -# the set of certificates supplied during cert path validation. In cases where -# the subject name alone is not sufficient to uniquely identify the certificate -# then both the "ocsp.responderCertIssuerName" and -# "ocsp.responderCertSerialNumber" properties must be used instead. When this -# property is set then those two properties are ignored. -# -# Example, -# ocsp.responderCertSubjectName="CN=OCSP Responder, O=XYZ Corp" - -# -# Issuer name of the OCSP responder's certificate -# -# By default, the certificate of the OCSP responder is that of the issuer -# of the certificate being validated. This property identifies the certificate -# of the OCSP responder when the default does not apply. Its value is a string -# distinguished name (defined in RFC 2253) which identifies a certificate in -# the set of certificates supplied during cert path validation. When this -# property is set then the "ocsp.responderCertSerialNumber" property must also -# be set. When the "ocsp.responderCertSubjectName" property is set then this -# property is ignored. -# -# Example, -# ocsp.responderCertIssuerName="CN=Enterprise CA, O=XYZ Corp" - -# -# Serial number of the OCSP responder's certificate -# -# By default, the certificate of the OCSP responder is that of the issuer -# of the certificate being validated. This property identifies the certificate -# of the OCSP responder when the default does not apply. Its value is a string -# of hexadecimal digits (colon or space separators may be present) which -# identifies a certificate in the set of certificates supplied during cert path -# validation. When this property is set then the "ocsp.responderCertIssuerName" -# property must also be set. When the "ocsp.responderCertSubjectName" property -# is set then this property is ignored. -# -# Example, -# ocsp.responderCertSerialNumber=2A:FF:00 - -# -# Policy for failed Kerberos KDC lookups: -# -# When a KDC is unavailable (network error, service failure, etc), it is -# put inside a blacklist and accessed less often for future requests. The -# value (case-insensitive) for this policy can be: -# -# tryLast -# KDCs in the blacklist are always tried after those not on the list. -# -# tryLess[:max_retries,timeout] -# KDCs in the blacklist are still tried by their order in the configuration, -# but with smaller max_retries and timeout values. max_retries and timeout -# are optional numerical parameters (default 1 and 5000, which means once -# and 5 seconds). Please notes that if any of the values defined here is -# more than what is defined in krb5.conf, it will be ignored. -# -# Whenever a KDC is detected as available, it is removed from the blacklist. -# The blacklist is reset when krb5.conf is reloaded. You can add -# refreshKrb5Config=true to a JAAS configuration file so that krb5.conf is -# reloaded whenever a JAAS authentication is attempted. -# -# Example, -# krb5.kdc.bad.policy = tryLast -# krb5.kdc.bad.policy = tryLess:2,2000 -krb5.kdc.bad.policy = tryLast - -# Algorithm restrictions for certification path (CertPath) processing -# -# In some environments, certain algorithms or key lengths may be undesirable -# for certification path building and validation. For example, "MD2" is -# generally no longer considered to be a secure hash algorithm. This section -# describes the mechanism for disabling algorithms based on algorithm name -# and/or key length. This includes algorithms used in certificates, as well -# as revocation information such as CRLs and signed OCSP Responses. -# -# The syntax of the disabled algorithm string is described as this Java -# BNF-style: -# DisabledAlgorithms: -# " DisabledAlgorithm { , DisabledAlgorithm } " -# -# DisabledAlgorithm: -# AlgorithmName [Constraint] -# -# AlgorithmName: -# (see below) -# -# Constraint: -# KeySizeConstraint -# -# KeySizeConstraint: -# keySize Operator DecimalInteger -# -# Operator: -# <= | < | == | != | >= | > -# -# DecimalInteger: -# DecimalDigits -# -# DecimalDigits: -# DecimalDigit {DecimalDigit} -# -# DecimalDigit: one of -# 1 2 3 4 5 6 7 8 9 0 -# -# The "AlgorithmName" is the standard algorithm name of the disabled -# algorithm. See "Java Cryptography Architecture Standard Algorithm Name -# Documentation" for information about Standard Algorithm Names. Matching -# is performed using a case-insensitive sub-element matching rule. (For -# example, in "SHA1withECDSA" the sub-elements are "SHA1" for hashing and -# "ECDSA" for signatures.) If the assertion "AlgorithmName" is a -# sub-element of the certificate algorithm name, the algorithm will be -# rejected during certification path building and validation. For example, -# the assertion algorithm name "DSA" will disable all certificate algorithms -# that rely on DSA, such as NONEwithDSA, SHA1withDSA. However, the assertion -# will not disable algorithms related to "ECDSA". -# -# A "Constraint" provides further guidance for the algorithm being specified. -# The "KeySizeConstraint" requires a key of a valid size range if the -# "AlgorithmName" is of a key algorithm. The "DecimalInteger" indicates the -# key size specified in number of bits. For example, "RSA keySize <= 1024" -# indicates that any RSA key with key size less than or equal to 1024 bits -# should be disabled, and "RSA keySize < 1024, RSA keySize > 2048" indicates -# that any RSA key with key size less than 1024 or greater than 2048 should -# be disabled. Note that the "KeySizeConstraint" only makes sense to key -# algorithms. -# -# Note: This property is currently used by Oracle's PKIX implementation. It -# is not guaranteed to be examined and used by other implementations. -# -# Example: -# jdk.certpath.disabledAlgorithms=MD2, DSA, RSA keySize < 2048 -# -# -jdk.certpath.disabledAlgorithms=MD2, MD5, RSA keySize < 1024 - -# Algorithm restrictions for Secure Socket Layer/Transport Layer Security -# (SSL/TLS) processing -# -# In some environments, certain algorithms or key lengths may be undesirable -# when using SSL/TLS. This section describes the mechanism for disabling -# algorithms during SSL/TLS security parameters negotiation, including cipher -# suites selection, peer authentication and key exchange mechanisms. -# -# For PKI-based peer authentication and key exchange mechanisms, this list -# of disabled algorithms will also be checked during certification path -# building and validation, including algorithms used in certificates, as -# well as revocation information such as CRLs and signed OCSP Responses. -# This is in addition to the jdk.certpath.disabledAlgorithms property above. -# -# See the specification of "jdk.certpath.disabledAlgorithms" for the -# syntax of the disabled algorithm string. -# -# Note: This property is currently used by Oracle's JSSE implementation. -# It is not guaranteed to be examined and used by other implementations. -# -# Example: -# jdk.tls.disabledAlgorithms=MD5, SHA1, DSA, RSA keySize < 2048 diff --git a/jdk/src/java.base/share/conf/security/java.security-linux b/jdk/src/java.base/share/conf/security/java.security-linux deleted file mode 100644 index 6f4204cf791..00000000000 --- a/jdk/src/java.base/share/conf/security/java.security-linux +++ /dev/null @@ -1,496 +0,0 @@ -# -# This is the "master security properties file". -# -# An alternate java.security properties file may be specified -# from the command line via the system property -# -# -Djava.security.properties= -# -# This properties file appends to the master security properties file. -# If both properties files specify values for the same key, the value -# from the command-line properties file is selected, as it is the last -# one loaded. -# -# Also, if you specify -# -# -Djava.security.properties== (2 equals), -# -# then that properties file completely overrides the master security -# properties file. -# -# To disable the ability to specify an additional properties file from -# the command line, set the key security.overridePropertiesFile -# to false in the master security properties file. It is set to true -# by default. - -# In this file, various security properties are set for use by -# java.security classes. This is where users can statically register -# Cryptography Package Providers ("providers" for short). The term -# "provider" refers to a package or set of packages that supply a -# concrete implementation of a subset of the cryptography aspects of -# the Java Security API. A provider may, for example, implement one or -# more digital signature algorithms or message digest algorithms. -# -# Each provider must implement a subclass of the Provider class. -# To register a provider in this master security properties file, -# specify the Provider subclass name and priority in the format -# -# security.provider.= -# -# This declares a provider, and specifies its preference -# order n. The preference order is the order in which providers are -# searched for requested algorithms (when no specific provider is -# requested). The order is 1-based; 1 is the most preferred, followed -# by 2, and so on. -# -# must specify the subclass of the Provider class whose -# constructor sets the values of various properties that are required -# for the Java Security API to look up the algorithms or other -# facilities implemented by the provider. -# -# There must be at least one provider specification in java.security. -# There is a default provider that comes standard with the JDK. It -# is called the "SUN" provider, and its Provider subclass -# named Sun appears in the sun.security.provider package. Thus, the -# "SUN" provider is registered via the following: -# -# security.provider.1=sun.security.provider.Sun -# -# (The number 1 is used for the default provider.) -# -# Note: Providers can be dynamically registered instead by calls to -# either the addProvider or insertProviderAt method in the Security -# class. - -# -# List of providers and their preference orders (see above): -# -security.provider.1=sun.security.provider.Sun -security.provider.2=sun.security.rsa.SunRsaSign -security.provider.3=sun.security.ec.SunEC -security.provider.4=com.sun.net.ssl.internal.ssl.Provider -security.provider.5=com.sun.crypto.provider.SunJCE -security.provider.6=sun.security.jgss.SunProvider -security.provider.7=com.sun.security.sasl.Provider -security.provider.8=org.jcp.xml.dsig.internal.dom.XMLDSigRI -security.provider.9=sun.security.smartcardio.SunPCSC - -# -# Sun Provider SecureRandom seed source. -# -# Select the primary source of seed data for the "SHA1PRNG" and -# "NativePRNG" SecureRandom implementations in the "Sun" provider. -# (Other SecureRandom implementations might also use this property.) -# -# On Unix-like systems (for example, Solaris/Linux/MacOS), the -# "NativePRNG" and "SHA1PRNG" implementations obtains seed data from -# special device files such as file:/dev/random. -# -# On Windows systems, specifying the URLs "file:/dev/random" or -# "file:/dev/urandom" will enable the native Microsoft CryptoAPI seeding -# mechanism for SHA1PRNG. -# -# By default, an attempt is made to use the entropy gathering device -# specified by the "securerandom.source" Security property. If an -# exception occurs while accessing the specified URL: -# -# SHA1PRNG: -# the traditional system/thread activity algorithm will be used. -# -# NativePRNG: -# a default value of /dev/random will be used. If neither -# are available, the implementation will be disabled. -# "file" is the only currently supported protocol type. -# -# The entropy gathering device can also be specified with the System -# property "java.security.egd". For example: -# -# % java -Djava.security.egd=file:/dev/random MainClass -# -# Specifying this System property will override the -# "securerandom.source" Security property. -# -# In addition, if "file:/dev/random" or "file:/dev/urandom" is -# specified, the "NativePRNG" implementation will be more preferred than -# SHA1PRNG in the Sun provider. -# -securerandom.source=file:/dev/random - -# -# A list of known strong SecureRandom implementations. -# -# To help guide applications in selecting a suitable strong -# java.security.SecureRandom implementation, Java distributions should -# indicate a list of known strong implementations using the property. -# -# This is a comma-separated list of algorithm and/or algorithm:provider -# entries. -# -securerandom.strongAlgorithms=NativePRNGBlocking:SUN - -# -# Class to instantiate as the javax.security.auth.login.Configuration -# provider. -# -login.configuration.provider=sun.security.provider.ConfigFile - -# -# Default login configuration file -# -#login.config.url.1=file:${user.home}/.java.login.config - -# -# Class to instantiate as the system Policy. This is the name of the class -# that will be used as the Policy object. -# -policy.provider=sun.security.provider.PolicyFile - -# The default is to have a single system-wide policy file, -# and a policy file in the user's home directory. -policy.url.1=file:${java.home}/lib/security/java.policy -policy.url.2=file:${user.home}/.java.policy - -# whether or not we expand properties in the policy file -# if this is set to false, properties (${...}) will not be expanded in policy -# files. -policy.expandProperties=true - -# whether or not we allow an extra policy to be passed on the command line -# with -Djava.security.policy=somefile. Comment out this line to disable -# this feature. -policy.allowSystemProperty=true - -# whether or not we look into the IdentityScope for trusted Identities -# when encountering a 1.1 signed JAR file. If the identity is found -# and is trusted, we grant it AllPermission. -policy.ignoreIdentityScope=false - -# -# Default keystore type. -# -keystore.type=jks - -# -# List of comma-separated packages that start with or equal this string -# will cause a security exception to be thrown when -# passed to checkPackageAccess unless the -# corresponding RuntimePermission ("accessClassInPackage."+package) has -# been granted. -package.access=sun.,\ - com.sun.xml.internal.,\ - com.sun.imageio.,\ - com.sun.istack.internal.,\ - com.sun.jmx.,\ - com.sun.media.sound.,\ - com.sun.naming.internal.,\ - com.sun.proxy.,\ - com.sun.corba.se.,\ - com.sun.org.apache.bcel.internal.,\ - com.sun.org.apache.regexp.internal.,\ - com.sun.org.apache.xerces.internal.,\ - com.sun.org.apache.xpath.internal.,\ - com.sun.org.apache.xalan.internal.extensions.,\ - com.sun.org.apache.xalan.internal.lib.,\ - com.sun.org.apache.xalan.internal.res.,\ - com.sun.org.apache.xalan.internal.templates.,\ - com.sun.org.apache.xalan.internal.utils.,\ - com.sun.org.apache.xalan.internal.xslt.,\ - com.sun.org.apache.xalan.internal.xsltc.cmdline.,\ - com.sun.org.apache.xalan.internal.xsltc.compiler.,\ - com.sun.org.apache.xalan.internal.xsltc.trax.,\ - com.sun.org.apache.xalan.internal.xsltc.util.,\ - com.sun.org.apache.xml.internal.res.,\ - com.sun.org.apache.xml.internal.security.,\ - com.sun.org.apache.xml.internal.serializer.utils.,\ - com.sun.org.apache.xml.internal.utils.,\ - com.sun.org.glassfish.,\ - com.oracle.xmlns.internal.,\ - com.oracle.webservices.internal.,\ - org.jcp.xml.dsig.internal.,\ - jdk.internal.,\ - jdk.nashorn.internal.,\ - jdk.nashorn.tools.,\ - com.sun.activation.registries. - -# -# List of comma-separated packages that start with or equal this string -# will cause a security exception to be thrown when -# passed to checkPackageDefinition unless the -# corresponding RuntimePermission ("defineClassInPackage."+package) has -# been granted. -# -# by default, none of the class loaders supplied with the JDK call -# checkPackageDefinition. -# -package.definition=sun.,\ - com.sun.xml.internal.,\ - com.sun.imageio.,\ - com.sun.istack.internal.,\ - com.sun.jmx.,\ - com.sun.media.sound.,\ - com.sun.naming.internal.,\ - com.sun.proxy.,\ - com.sun.corba.se.,\ - com.sun.org.apache.bcel.internal.,\ - com.sun.org.apache.regexp.internal.,\ - com.sun.org.apache.xerces.internal.,\ - com.sun.org.apache.xpath.internal.,\ - com.sun.org.apache.xalan.internal.extensions.,\ - com.sun.org.apache.xalan.internal.lib.,\ - com.sun.org.apache.xalan.internal.res.,\ - com.sun.org.apache.xalan.internal.templates.,\ - com.sun.org.apache.xalan.internal.utils.,\ - com.sun.org.apache.xalan.internal.xslt.,\ - com.sun.org.apache.xalan.internal.xsltc.cmdline.,\ - com.sun.org.apache.xalan.internal.xsltc.compiler.,\ - com.sun.org.apache.xalan.internal.xsltc.trax.,\ - com.sun.org.apache.xalan.internal.xsltc.util.,\ - com.sun.org.apache.xml.internal.res.,\ - com.sun.org.apache.xml.internal.security.,\ - com.sun.org.apache.xml.internal.serializer.utils.,\ - com.sun.org.apache.xml.internal.utils.,\ - com.sun.org.glassfish.,\ - com.oracle.xmlns.internal.,\ - com.oracle.webservices.internal.,\ - org.jcp.xml.dsig.internal.,\ - jdk.internal.,\ - jdk.nashorn.internal.,\ - jdk.nashorn.tools.,\ - com.sun.activation.registries. - -# -# Determines whether this properties file can be appended to -# or overridden on the command line via -Djava.security.properties -# -security.overridePropertiesFile=true - -# -# Determines the default key and trust manager factory algorithms for -# the javax.net.ssl package. -# -ssl.KeyManagerFactory.algorithm=SunX509 -ssl.TrustManagerFactory.algorithm=PKIX - -# -# The Java-level namelookup cache policy for successful lookups: -# -# any negative value: caching forever -# any positive value: the number of seconds to cache an address for -# zero: do not cache -# -# default value is forever (FOREVER). For security reasons, this -# caching is made forever when a security manager is set. When a security -# manager is not set, the default behavior in this implementation -# is to cache for 30 seconds. -# -# NOTE: setting this to anything other than the default value can have -# serious security implications. Do not set it unless -# you are sure you are not exposed to DNS spoofing attack. -# -#networkaddress.cache.ttl=-1 - -# The Java-level namelookup cache policy for failed lookups: -# -# any negative value: cache forever -# any positive value: the number of seconds to cache negative lookup results -# zero: do not cache -# -# In some Microsoft Windows networking environments that employ -# the WINS name service in addition to DNS, name service lookups -# that fail may take a noticeably long time to return (approx. 5 seconds). -# For this reason the default caching policy is to maintain these -# results for 10 seconds. -# -# -networkaddress.cache.negative.ttl=10 - -# -# Properties to configure OCSP for certificate revocation checking -# - -# Enable OCSP -# -# By default, OCSP is not used for certificate revocation checking. -# This property enables the use of OCSP when set to the value "true". -# -# NOTE: SocketPermission is required to connect to an OCSP responder. -# -# Example, -# ocsp.enable=true - -# -# Location of the OCSP responder -# -# By default, the location of the OCSP responder is determined implicitly -# from the certificate being validated. This property explicitly specifies -# the location of the OCSP responder. The property is used when the -# Authority Information Access extension (defined in RFC 3280) is absent -# from the certificate or when it requires overriding. -# -# Example, -# ocsp.responderURL=http://ocsp.example.net:80 - -# -# Subject name of the OCSP responder's certificate -# -# By default, the certificate of the OCSP responder is that of the issuer -# of the certificate being validated. This property identifies the certificate -# of the OCSP responder when the default does not apply. Its value is a string -# distinguished name (defined in RFC 2253) which identifies a certificate in -# the set of certificates supplied during cert path validation. In cases where -# the subject name alone is not sufficient to uniquely identify the certificate -# then both the "ocsp.responderCertIssuerName" and -# "ocsp.responderCertSerialNumber" properties must be used instead. When this -# property is set then those two properties are ignored. -# -# Example, -# ocsp.responderCertSubjectName="CN=OCSP Responder, O=XYZ Corp" - -# -# Issuer name of the OCSP responder's certificate -# -# By default, the certificate of the OCSP responder is that of the issuer -# of the certificate being validated. This property identifies the certificate -# of the OCSP responder when the default does not apply. Its value is a string -# distinguished name (defined in RFC 2253) which identifies a certificate in -# the set of certificates supplied during cert path validation. When this -# property is set then the "ocsp.responderCertSerialNumber" property must also -# be set. When the "ocsp.responderCertSubjectName" property is set then this -# property is ignored. -# -# Example, -# ocsp.responderCertIssuerName="CN=Enterprise CA, O=XYZ Corp" - -# -# Serial number of the OCSP responder's certificate -# -# By default, the certificate of the OCSP responder is that of the issuer -# of the certificate being validated. This property identifies the certificate -# of the OCSP responder when the default does not apply. Its value is a string -# of hexadecimal digits (colon or space separators may be present) which -# identifies a certificate in the set of certificates supplied during cert path -# validation. When this property is set then the "ocsp.responderCertIssuerName" -# property must also be set. When the "ocsp.responderCertSubjectName" property -# is set then this property is ignored. -# -# Example, -# ocsp.responderCertSerialNumber=2A:FF:00 - -# -# Policy for failed Kerberos KDC lookups: -# -# When a KDC is unavailable (network error, service failure, etc), it is -# put inside a blacklist and accessed less often for future requests. The -# value (case-insensitive) for this policy can be: -# -# tryLast -# KDCs in the blacklist are always tried after those not on the list. -# -# tryLess[:max_retries,timeout] -# KDCs in the blacklist are still tried by their order in the configuration, -# but with smaller max_retries and timeout values. max_retries and timeout -# are optional numerical parameters (default 1 and 5000, which means once -# and 5 seconds). Please notes that if any of the values defined here is -# more than what is defined in krb5.conf, it will be ignored. -# -# Whenever a KDC is detected as available, it is removed from the blacklist. -# The blacklist is reset when krb5.conf is reloaded. You can add -# refreshKrb5Config=true to a JAAS configuration file so that krb5.conf is -# reloaded whenever a JAAS authentication is attempted. -# -# Example, -# krb5.kdc.bad.policy = tryLast -# krb5.kdc.bad.policy = tryLess:2,2000 -krb5.kdc.bad.policy = tryLast - -# Algorithm restrictions for certification path (CertPath) processing -# -# In some environments, certain algorithms or key lengths may be undesirable -# for certification path building and validation. For example, "MD2" is -# generally no longer considered to be a secure hash algorithm. This section -# describes the mechanism for disabling algorithms based on algorithm name -# and/or key length. This includes algorithms used in certificates, as well -# as revocation information such as CRLs and signed OCSP Responses. -# -# The syntax of the disabled algorithm string is described as this Java -# BNF-style: -# DisabledAlgorithms: -# " DisabledAlgorithm { , DisabledAlgorithm } " -# -# DisabledAlgorithm: -# AlgorithmName [Constraint] -# -# AlgorithmName: -# (see below) -# -# Constraint: -# KeySizeConstraint -# -# KeySizeConstraint: -# keySize Operator DecimalInteger -# -# Operator: -# <= | < | == | != | >= | > -# -# DecimalInteger: -# DecimalDigits -# -# DecimalDigits: -# DecimalDigit {DecimalDigit} -# -# DecimalDigit: one of -# 1 2 3 4 5 6 7 8 9 0 -# -# The "AlgorithmName" is the standard algorithm name of the disabled -# algorithm. See "Java Cryptography Architecture Standard Algorithm Name -# Documentation" for information about Standard Algorithm Names. Matching -# is performed using a case-insensitive sub-element matching rule. (For -# example, in "SHA1withECDSA" the sub-elements are "SHA1" for hashing and -# "ECDSA" for signatures.) If the assertion "AlgorithmName" is a -# sub-element of the certificate algorithm name, the algorithm will be -# rejected during certification path building and validation. For example, -# the assertion algorithm name "DSA" will disable all certificate algorithms -# that rely on DSA, such as NONEwithDSA, SHA1withDSA. However, the assertion -# will not disable algorithms related to "ECDSA". -# -# A "Constraint" provides further guidance for the algorithm being specified. -# The "KeySizeConstraint" requires a key of a valid size range if the -# "AlgorithmName" is of a key algorithm. The "DecimalInteger" indicates the -# key size specified in number of bits. For example, "RSA keySize <= 1024" -# indicates that any RSA key with key size less than or equal to 1024 bits -# should be disabled, and "RSA keySize < 1024, RSA keySize > 2048" indicates -# that any RSA key with key size less than 1024 or greater than 2048 should -# be disabled. Note that the "KeySizeConstraint" only makes sense to key -# algorithms. -# -# Note: This property is currently used by Oracle's PKIX implementation. It -# is not guaranteed to be examined and used by other implementations. -# -# Example: -# jdk.certpath.disabledAlgorithms=MD2, DSA, RSA keySize < 2048 -# -# -jdk.certpath.disabledAlgorithms=MD2, MD5, RSA keySize < 1024 - -# Algorithm restrictions for Secure Socket Layer/Transport Layer Security -# (SSL/TLS) processing -# -# In some environments, certain algorithms or key lengths may be undesirable -# when using SSL/TLS. This section describes the mechanism for disabling -# algorithms during SSL/TLS security parameters negotiation, including cipher -# suites selection, peer authentication and key exchange mechanisms. -# -# For PKI-based peer authentication and key exchange mechanisms, this list -# of disabled algorithms will also be checked during certification path -# building and validation, including algorithms used in certificates, as -# well as revocation information such as CRLs and signed OCSP Responses. -# This is in addition to the jdk.certpath.disabledAlgorithms property above. -# -# See the specification of "jdk.certpath.disabledAlgorithms" for the -# syntax of the disabled algorithm string. -# -# Note: This property is currently used by Oracle's JSSE implementation. -# It is not guaranteed to be examined and used by other implementations. -# -# Example: -# jdk.tls.disabledAlgorithms=MD5, SHA1, DSA, RSA keySize < 2048 diff --git a/jdk/src/java.base/share/conf/security/java.security-macosx b/jdk/src/java.base/share/conf/security/java.security-macosx deleted file mode 100644 index ff726991c56..00000000000 --- a/jdk/src/java.base/share/conf/security/java.security-macosx +++ /dev/null @@ -1,499 +0,0 @@ -# -# This is the "master security properties file". -# -# An alternate java.security properties file may be specified -# from the command line via the system property -# -# -Djava.security.properties= -# -# This properties file appends to the master security properties file. -# If both properties files specify values for the same key, the value -# from the command-line properties file is selected, as it is the last -# one loaded. -# -# Also, if you specify -# -# -Djava.security.properties== (2 equals), -# -# then that properties file completely overrides the master security -# properties file. -# -# To disable the ability to specify an additional properties file from -# the command line, set the key security.overridePropertiesFile -# to false in the master security properties file. It is set to true -# by default. - -# In this file, various security properties are set for use by -# java.security classes. This is where users can statically register -# Cryptography Package Providers ("providers" for short). The term -# "provider" refers to a package or set of packages that supply a -# concrete implementation of a subset of the cryptography aspects of -# the Java Security API. A provider may, for example, implement one or -# more digital signature algorithms or message digest algorithms. -# -# Each provider must implement a subclass of the Provider class. -# To register a provider in this master security properties file, -# specify the Provider subclass name and priority in the format -# -# security.provider.= -# -# This declares a provider, and specifies its preference -# order n. The preference order is the order in which providers are -# searched for requested algorithms (when no specific provider is -# requested). The order is 1-based; 1 is the most preferred, followed -# by 2, and so on. -# -# must specify the subclass of the Provider class whose -# constructor sets the values of various properties that are required -# for the Java Security API to look up the algorithms or other -# facilities implemented by the provider. -# -# There must be at least one provider specification in java.security. -# There is a default provider that comes standard with the JDK. It -# is called the "SUN" provider, and its Provider subclass -# named Sun appears in the sun.security.provider package. Thus, the -# "SUN" provider is registered via the following: -# -# security.provider.1=sun.security.provider.Sun -# -# (The number 1 is used for the default provider.) -# -# Note: Providers can be dynamically registered instead by calls to -# either the addProvider or insertProviderAt method in the Security -# class. - -# -# List of providers and their preference orders (see above): -# -security.provider.1=sun.security.provider.Sun -security.provider.2=sun.security.rsa.SunRsaSign -security.provider.3=sun.security.ec.SunEC -security.provider.4=com.sun.net.ssl.internal.ssl.Provider -security.provider.5=com.sun.crypto.provider.SunJCE -security.provider.6=sun.security.jgss.SunProvider -security.provider.7=com.sun.security.sasl.Provider -security.provider.8=org.jcp.xml.dsig.internal.dom.XMLDSigRI -security.provider.9=sun.security.smartcardio.SunPCSC -security.provider.10=apple.security.AppleProvider - -# -# Sun Provider SecureRandom seed source. -# -# Select the primary source of seed data for the "SHA1PRNG" and -# "NativePRNG" SecureRandom implementations in the "Sun" provider. -# (Other SecureRandom implementations might also use this property.) -# -# On Unix-like systems (for example, Solaris/Linux/MacOS), the -# "NativePRNG" and "SHA1PRNG" implementations obtains seed data from -# special device files such as file:/dev/random. -# -# On Windows systems, specifying the URLs "file:/dev/random" or -# "file:/dev/urandom" will enable the native Microsoft CryptoAPI seeding -# mechanism for SHA1PRNG. -# -# By default, an attempt is made to use the entropy gathering device -# specified by the "securerandom.source" Security property. If an -# exception occurs while accessing the specified URL: -# -# SHA1PRNG: -# the traditional system/thread activity algorithm will be used. -# -# NativePRNG: -# a default value of /dev/random will be used. If neither -# are available, the implementation will be disabled. -# "file" is the only currently supported protocol type. -# -# The entropy gathering device can also be specified with the System -# property "java.security.egd". For example: -# -# % java -Djava.security.egd=file:/dev/random MainClass -# -# Specifying this System property will override the -# "securerandom.source" Security property. -# -# In addition, if "file:/dev/random" or "file:/dev/urandom" is -# specified, the "NativePRNG" implementation will be more preferred than -# SHA1PRNG in the Sun provider. -# -securerandom.source=file:/dev/random - -# -# A list of known strong SecureRandom implementations. -# -# To help guide applications in selecting a suitable strong -# java.security.SecureRandom implementation, Java distributions should -# indicate a list of known strong implementations using the property. -# -# This is a comma-separated list of algorithm and/or algorithm:provider -# entries. -# -securerandom.strongAlgorithms=NativePRNGBlocking:SUN - -# -# Class to instantiate as the javax.security.auth.login.Configuration -# provider. -# -login.configuration.provider=sun.security.provider.ConfigFile - -# -# Default login configuration file -# -#login.config.url.1=file:${user.home}/.java.login.config - -# -# Class to instantiate as the system Policy. This is the name of the class -# that will be used as the Policy object. -# -policy.provider=sun.security.provider.PolicyFile - -# The default is to have a single system-wide policy file, -# and a policy file in the user's home directory. -policy.url.1=file:${java.home}/lib/security/java.policy -policy.url.2=file:${user.home}/.java.policy - -# whether or not we expand properties in the policy file -# if this is set to false, properties (${...}) will not be expanded in policy -# files. -policy.expandProperties=true - -# whether or not we allow an extra policy to be passed on the command line -# with -Djava.security.policy=somefile. Comment out this line to disable -# this feature. -policy.allowSystemProperty=true - -# whether or not we look into the IdentityScope for trusted Identities -# when encountering a 1.1 signed JAR file. If the identity is found -# and is trusted, we grant it AllPermission. -policy.ignoreIdentityScope=false - -# -# Default keystore type. -# -keystore.type=jks - -# -# List of comma-separated packages that start with or equal this string -# will cause a security exception to be thrown when -# passed to checkPackageAccess unless the -# corresponding RuntimePermission ("accessClassInPackage."+package) has -# been granted. -package.access=sun.,\ - com.sun.xml.internal.,\ - com.sun.imageio.,\ - com.sun.istack.internal.,\ - com.sun.jmx.,\ - com.sun.media.sound.,\ - com.sun.naming.internal.,\ - com.sun.proxy.,\ - com.sun.corba.se.,\ - com.sun.org.apache.bcel.internal.,\ - com.sun.org.apache.regexp.internal.,\ - com.sun.org.apache.xerces.internal.,\ - com.sun.org.apache.xpath.internal.,\ - com.sun.org.apache.xalan.internal.extensions.,\ - com.sun.org.apache.xalan.internal.lib.,\ - com.sun.org.apache.xalan.internal.res.,\ - com.sun.org.apache.xalan.internal.templates.,\ - com.sun.org.apache.xalan.internal.utils.,\ - com.sun.org.apache.xalan.internal.xslt.,\ - com.sun.org.apache.xalan.internal.xsltc.cmdline.,\ - com.sun.org.apache.xalan.internal.xsltc.compiler.,\ - com.sun.org.apache.xalan.internal.xsltc.trax.,\ - com.sun.org.apache.xalan.internal.xsltc.util.,\ - com.sun.org.apache.xml.internal.res.,\ - com.sun.org.apache.xml.internal.security.,\ - com.sun.org.apache.xml.internal.serializer.utils.,\ - com.sun.org.apache.xml.internal.utils.,\ - com.sun.org.glassfish.,\ - com.oracle.xmlns.internal.,\ - com.oracle.webservices.internal.,\ - org.jcp.xml.dsig.internal.,\ - jdk.internal.,\ - jdk.nashorn.internal.,\ - jdk.nashorn.tools.,\ - com.sun.activation.registries.,\ - apple. - -# -# List of comma-separated packages that start with or equal this string -# will cause a security exception to be thrown when -# passed to checkPackageDefinition unless the -# corresponding RuntimePermission ("defineClassInPackage."+package) has -# been granted. -# -# by default, none of the class loaders supplied with the JDK call -# checkPackageDefinition. -# -package.definition=sun.,\ - com.sun.xml.internal.,\ - com.sun.imageio.,\ - com.sun.istack.internal.,\ - com.sun.jmx.,\ - com.sun.media.sound.,\ - com.sun.naming.internal.,\ - com.sun.proxy.,\ - com.sun.corba.se.,\ - com.sun.org.apache.bcel.internal.,\ - com.sun.org.apache.regexp.internal.,\ - com.sun.org.apache.xerces.internal.,\ - com.sun.org.apache.xpath.internal.,\ - com.sun.org.apache.xalan.internal.extensions.,\ - com.sun.org.apache.xalan.internal.lib.,\ - com.sun.org.apache.xalan.internal.res.,\ - com.sun.org.apache.xalan.internal.templates.,\ - com.sun.org.apache.xalan.internal.utils.,\ - com.sun.org.apache.xalan.internal.xslt.,\ - com.sun.org.apache.xalan.internal.xsltc.cmdline.,\ - com.sun.org.apache.xalan.internal.xsltc.compiler.,\ - com.sun.org.apache.xalan.internal.xsltc.trax.,\ - com.sun.org.apache.xalan.internal.xsltc.util.,\ - com.sun.org.apache.xml.internal.res.,\ - com.sun.org.apache.xml.internal.security.,\ - com.sun.org.apache.xml.internal.serializer.utils.,\ - com.sun.org.apache.xml.internal.utils.,\ - com.sun.org.glassfish.,\ - com.oracle.xmlns.internal.,\ - com.oracle.webservices.internal.,\ - org.jcp.xml.dsig.internal.,\ - jdk.internal.,\ - jdk.nashorn.internal.,\ - jdk.nashorn.tools.,\ - com.sun.activation.registries.,\ - apple. - -# -# Determines whether this properties file can be appended to -# or overridden on the command line via -Djava.security.properties -# -security.overridePropertiesFile=true - -# -# Determines the default key and trust manager factory algorithms for -# the javax.net.ssl package. -# -ssl.KeyManagerFactory.algorithm=SunX509 -ssl.TrustManagerFactory.algorithm=PKIX - -# -# The Java-level namelookup cache policy for successful lookups: -# -# any negative value: caching forever -# any positive value: the number of seconds to cache an address for -# zero: do not cache -# -# default value is forever (FOREVER). For security reasons, this -# caching is made forever when a security manager is set. When a security -# manager is not set, the default behavior in this implementation -# is to cache for 30 seconds. -# -# NOTE: setting this to anything other than the default value can have -# serious security implications. Do not set it unless -# you are sure you are not exposed to DNS spoofing attack. -# -#networkaddress.cache.ttl=-1 - -# The Java-level namelookup cache policy for failed lookups: -# -# any negative value: cache forever -# any positive value: the number of seconds to cache negative lookup results -# zero: do not cache -# -# In some Microsoft Windows networking environments that employ -# the WINS name service in addition to DNS, name service lookups -# that fail may take a noticeably long time to return (approx. 5 seconds). -# For this reason the default caching policy is to maintain these -# results for 10 seconds. -# -# -networkaddress.cache.negative.ttl=10 - -# -# Properties to configure OCSP for certificate revocation checking -# - -# Enable OCSP -# -# By default, OCSP is not used for certificate revocation checking. -# This property enables the use of OCSP when set to the value "true". -# -# NOTE: SocketPermission is required to connect to an OCSP responder. -# -# Example, -# ocsp.enable=true - -# -# Location of the OCSP responder -# -# By default, the location of the OCSP responder is determined implicitly -# from the certificate being validated. This property explicitly specifies -# the location of the OCSP responder. The property is used when the -# Authority Information Access extension (defined in RFC 3280) is absent -# from the certificate or when it requires overriding. -# -# Example, -# ocsp.responderURL=http://ocsp.example.net:80 - -# -# Subject name of the OCSP responder's certificate -# -# By default, the certificate of the OCSP responder is that of the issuer -# of the certificate being validated. This property identifies the certificate -# of the OCSP responder when the default does not apply. Its value is a string -# distinguished name (defined in RFC 2253) which identifies a certificate in -# the set of certificates supplied during cert path validation. In cases where -# the subject name alone is not sufficient to uniquely identify the certificate -# then both the "ocsp.responderCertIssuerName" and -# "ocsp.responderCertSerialNumber" properties must be used instead. When this -# property is set then those two properties are ignored. -# -# Example, -# ocsp.responderCertSubjectName="CN=OCSP Responder, O=XYZ Corp" - -# -# Issuer name of the OCSP responder's certificate -# -# By default, the certificate of the OCSP responder is that of the issuer -# of the certificate being validated. This property identifies the certificate -# of the OCSP responder when the default does not apply. Its value is a string -# distinguished name (defined in RFC 2253) which identifies a certificate in -# the set of certificates supplied during cert path validation. When this -# property is set then the "ocsp.responderCertSerialNumber" property must also -# be set. When the "ocsp.responderCertSubjectName" property is set then this -# property is ignored. -# -# Example, -# ocsp.responderCertIssuerName="CN=Enterprise CA, O=XYZ Corp" - -# -# Serial number of the OCSP responder's certificate -# -# By default, the certificate of the OCSP responder is that of the issuer -# of the certificate being validated. This property identifies the certificate -# of the OCSP responder when the default does not apply. Its value is a string -# of hexadecimal digits (colon or space separators may be present) which -# identifies a certificate in the set of certificates supplied during cert path -# validation. When this property is set then the "ocsp.responderCertIssuerName" -# property must also be set. When the "ocsp.responderCertSubjectName" property -# is set then this property is ignored. -# -# Example, -# ocsp.responderCertSerialNumber=2A:FF:00 - -# -# Policy for failed Kerberos KDC lookups: -# -# When a KDC is unavailable (network error, service failure, etc), it is -# put inside a blacklist and accessed less often for future requests. The -# value (case-insensitive) for this policy can be: -# -# tryLast -# KDCs in the blacklist are always tried after those not on the list. -# -# tryLess[:max_retries,timeout] -# KDCs in the blacklist are still tried by their order in the configuration, -# but with smaller max_retries and timeout values. max_retries and timeout -# are optional numerical parameters (default 1 and 5000, which means once -# and 5 seconds). Please notes that if any of the values defined here is -# more than what is defined in krb5.conf, it will be ignored. -# -# Whenever a KDC is detected as available, it is removed from the blacklist. -# The blacklist is reset when krb5.conf is reloaded. You can add -# refreshKrb5Config=true to a JAAS configuration file so that krb5.conf is -# reloaded whenever a JAAS authentication is attempted. -# -# Example, -# krb5.kdc.bad.policy = tryLast -# krb5.kdc.bad.policy = tryLess:2,2000 -krb5.kdc.bad.policy = tryLast - -# Algorithm restrictions for certification path (CertPath) processing -# -# In some environments, certain algorithms or key lengths may be undesirable -# for certification path building and validation. For example, "MD2" is -# generally no longer considered to be a secure hash algorithm. This section -# describes the mechanism for disabling algorithms based on algorithm name -# and/or key length. This includes algorithms used in certificates, as well -# as revocation information such as CRLs and signed OCSP Responses. -# -# The syntax of the disabled algorithm string is described as this Java -# BNF-style: -# DisabledAlgorithms: -# " DisabledAlgorithm { , DisabledAlgorithm } " -# -# DisabledAlgorithm: -# AlgorithmName [Constraint] -# -# AlgorithmName: -# (see below) -# -# Constraint: -# KeySizeConstraint -# -# KeySizeConstraint: -# keySize Operator DecimalInteger -# -# Operator: -# <= | < | == | != | >= | > -# -# DecimalInteger: -# DecimalDigits -# -# DecimalDigits: -# DecimalDigit {DecimalDigit} -# -# DecimalDigit: one of -# 1 2 3 4 5 6 7 8 9 0 -# -# The "AlgorithmName" is the standard algorithm name of the disabled -# algorithm. See "Java Cryptography Architecture Standard Algorithm Name -# Documentation" for information about Standard Algorithm Names. Matching -# is performed using a case-insensitive sub-element matching rule. (For -# example, in "SHA1withECDSA" the sub-elements are "SHA1" for hashing and -# "ECDSA" for signatures.) If the assertion "AlgorithmName" is a -# sub-element of the certificate algorithm name, the algorithm will be -# rejected during certification path building and validation. For example, -# the assertion algorithm name "DSA" will disable all certificate algorithms -# that rely on DSA, such as NONEwithDSA, SHA1withDSA. However, the assertion -# will not disable algorithms related to "ECDSA". -# -# A "Constraint" provides further guidance for the algorithm being specified. -# The "KeySizeConstraint" requires a key of a valid size range if the -# "AlgorithmName" is of a key algorithm. The "DecimalInteger" indicates the -# key size specified in number of bits. For example, "RSA keySize <= 1024" -# indicates that any RSA key with key size less than or equal to 1024 bits -# should be disabled, and "RSA keySize < 1024, RSA keySize > 2048" indicates -# that any RSA key with key size less than 1024 or greater than 2048 should -# be disabled. Note that the "KeySizeConstraint" only makes sense to key -# algorithms. -# -# Note: This property is currently used by Oracle's PKIX implementation. It -# is not guaranteed to be examined and used by other implementations. -# -# Example: -# jdk.certpath.disabledAlgorithms=MD2, DSA, RSA keySize < 2048 -# -# -jdk.certpath.disabledAlgorithms=MD2, MD5, RSA keySize < 1024 - -# Algorithm restrictions for Secure Socket Layer/Transport Layer Security -# (SSL/TLS) processing -# -# In some environments, certain algorithms or key lengths may be undesirable -# when using SSL/TLS. This section describes the mechanism for disabling -# algorithms during SSL/TLS security parameters negotiation, including cipher -# suites selection, peer authentication and key exchange mechanisms. -# -# For PKI-based peer authentication and key exchange mechanisms, this list -# of disabled algorithms will also be checked during certification path -# building and validation, including algorithms used in certificates, as -# well as revocation information such as CRLs and signed OCSP Responses. -# This is in addition to the jdk.certpath.disabledAlgorithms property above. -# -# See the specification of "jdk.certpath.disabledAlgorithms" for the -# syntax of the disabled algorithm string. -# -# Note: This property is currently used by Oracle's JSSE implementation. -# It is not guaranteed to be examined and used by other implementations. -# -# Example: -# jdk.tls.disabledAlgorithms=MD5, SHA1, DSA, RSA keySize < 2048 diff --git a/jdk/src/java.base/share/conf/security/java.security-solaris b/jdk/src/java.base/share/conf/security/java.security-solaris deleted file mode 100644 index e26ff143141..00000000000 --- a/jdk/src/java.base/share/conf/security/java.security-solaris +++ /dev/null @@ -1,498 +0,0 @@ -# -# This is the "master security properties file". -# -# An alternate java.security properties file may be specified -# from the command line via the system property -# -# -Djava.security.properties= -# -# This properties file appends to the master security properties file. -# If both properties files specify values for the same key, the value -# from the command-line properties file is selected, as it is the last -# one loaded. -# -# Also, if you specify -# -# -Djava.security.properties== (2 equals), -# -# then that properties file completely overrides the master security -# properties file. -# -# To disable the ability to specify an additional properties file from -# the command line, set the key security.overridePropertiesFile -# to false in the master security properties file. It is set to true -# by default. - -# In this file, various security properties are set for use by -# java.security classes. This is where users can statically register -# Cryptography Package Providers ("providers" for short). The term -# "provider" refers to a package or set of packages that supply a -# concrete implementation of a subset of the cryptography aspects of -# the Java Security API. A provider may, for example, implement one or -# more digital signature algorithms or message digest algorithms. -# -# Each provider must implement a subclass of the Provider class. -# To register a provider in this master security properties file, -# specify the Provider subclass name and priority in the format -# -# security.provider.= -# -# This declares a provider, and specifies its preference -# order n. The preference order is the order in which providers are -# searched for requested algorithms (when no specific provider is -# requested). The order is 1-based; 1 is the most preferred, followed -# by 2, and so on. -# -# must specify the subclass of the Provider class whose -# constructor sets the values of various properties that are required -# for the Java Security API to look up the algorithms or other -# facilities implemented by the provider. -# -# There must be at least one provider specification in java.security. -# There is a default provider that comes standard with the JDK. It -# is called the "SUN" provider, and its Provider subclass -# named Sun appears in the sun.security.provider package. Thus, the -# "SUN" provider is registered via the following: -# -# security.provider.1=sun.security.provider.Sun -# -# (The number 1 is used for the default provider.) -# -# Note: Providers can be dynamically registered instead by calls to -# either the addProvider or insertProviderAt method in the Security -# class. - -# -# List of providers and their preference orders (see above): -# -security.provider.1=com.oracle.security.ucrypto.UcryptoProvider ${java.home}/lib/security/ucrypto-solaris.cfg -security.provider.2=sun.security.pkcs11.SunPKCS11 ${java.home}/lib/security/sunpkcs11-solaris.cfg -security.provider.3=sun.security.provider.Sun -security.provider.4=sun.security.rsa.SunRsaSign -security.provider.5=sun.security.ec.SunEC -security.provider.6=com.sun.net.ssl.internal.ssl.Provider -security.provider.7=com.sun.crypto.provider.SunJCE -security.provider.8=sun.security.jgss.SunProvider -security.provider.9=com.sun.security.sasl.Provider -security.provider.10=org.jcp.xml.dsig.internal.dom.XMLDSigRI -security.provider.11=sun.security.smartcardio.SunPCSC - -# -# Sun Provider SecureRandom seed source. -# -# Select the primary source of seed data for the "SHA1PRNG" and -# "NativePRNG" SecureRandom implementations in the "Sun" provider. -# (Other SecureRandom implementations might also use this property.) -# -# On Unix-like systems (for example, Solaris/Linux/MacOS), the -# "NativePRNG" and "SHA1PRNG" implementations obtains seed data from -# special device files such as file:/dev/random. -# -# On Windows systems, specifying the URLs "file:/dev/random" or -# "file:/dev/urandom" will enable the native Microsoft CryptoAPI seeding -# mechanism for SHA1PRNG. -# -# By default, an attempt is made to use the entropy gathering device -# specified by the "securerandom.source" Security property. If an -# exception occurs while accessing the specified URL: -# -# SHA1PRNG: -# the traditional system/thread activity algorithm will be used. -# -# NativePRNG: -# a default value of /dev/random will be used. If neither -# are available, the implementation will be disabled. -# "file" is the only currently supported protocol type. -# -# The entropy gathering device can also be specified with the System -# property "java.security.egd". For example: -# -# % java -Djava.security.egd=file:/dev/random MainClass -# -# Specifying this System property will override the -# "securerandom.source" Security property. -# -# In addition, if "file:/dev/random" or "file:/dev/urandom" is -# specified, the "NativePRNG" implementation will be more preferred than -# SHA1PRNG in the Sun provider. -# -securerandom.source=file:/dev/random - -# -# A list of known strong SecureRandom implementations. -# -# To help guide applications in selecting a suitable strong -# java.security.SecureRandom implementation, Java distributions should -# indicate a list of known strong implementations using the property. -# -# This is a comma-separated list of algorithm and/or algorithm:provider -# entries. -# -securerandom.strongAlgorithms=NativePRNGBlocking:SUN - -# -# Class to instantiate as the javax.security.auth.login.Configuration -# provider. -# -login.configuration.provider=sun.security.provider.ConfigFile - -# -# Default login configuration file -# -#login.config.url.1=file:${user.home}/.java.login.config - -# -# Class to instantiate as the system Policy. This is the name of the class -# that will be used as the Policy object. -# -policy.provider=sun.security.provider.PolicyFile - -# The default is to have a single system-wide policy file, -# and a policy file in the user's home directory. -policy.url.1=file:${java.home}/lib/security/java.policy -policy.url.2=file:${user.home}/.java.policy - -# whether or not we expand properties in the policy file -# if this is set to false, properties (${...}) will not be expanded in policy -# files. -policy.expandProperties=true - -# whether or not we allow an extra policy to be passed on the command line -# with -Djava.security.policy=somefile. Comment out this line to disable -# this feature. -policy.allowSystemProperty=true - -# whether or not we look into the IdentityScope for trusted Identities -# when encountering a 1.1 signed JAR file. If the identity is found -# and is trusted, we grant it AllPermission. -policy.ignoreIdentityScope=false - -# -# Default keystore type. -# -keystore.type=jks - -# -# List of comma-separated packages that start with or equal this string -# will cause a security exception to be thrown when -# passed to checkPackageAccess unless the -# corresponding RuntimePermission ("accessClassInPackage."+package) has -# been granted. -package.access=sun.,\ - com.sun.xml.internal.,\ - com.sun.imageio.,\ - com.sun.istack.internal.,\ - com.sun.jmx.,\ - com.sun.media.sound.,\ - com.sun.naming.internal.,\ - com.sun.proxy.,\ - com.sun.corba.se.,\ - com.sun.org.apache.bcel.internal.,\ - com.sun.org.apache.regexp.internal.,\ - com.sun.org.apache.xerces.internal.,\ - com.sun.org.apache.xpath.internal.,\ - com.sun.org.apache.xalan.internal.extensions.,\ - com.sun.org.apache.xalan.internal.lib.,\ - com.sun.org.apache.xalan.internal.res.,\ - com.sun.org.apache.xalan.internal.templates.,\ - com.sun.org.apache.xalan.internal.utils.,\ - com.sun.org.apache.xalan.internal.xslt.,\ - com.sun.org.apache.xalan.internal.xsltc.cmdline.,\ - com.sun.org.apache.xalan.internal.xsltc.compiler.,\ - com.sun.org.apache.xalan.internal.xsltc.trax.,\ - com.sun.org.apache.xalan.internal.xsltc.util.,\ - com.sun.org.apache.xml.internal.res.,\ - com.sun.org.apache.xml.internal.security.,\ - com.sun.org.apache.xml.internal.serializer.utils.,\ - com.sun.org.apache.xml.internal.utils.,\ - com.sun.org.glassfish.,\ - com.oracle.xmlns.internal.,\ - com.oracle.webservices.internal.,\ - org.jcp.xml.dsig.internal.,\ - jdk.internal.,\ - jdk.nashorn.internal.,\ - jdk.nashorn.tools.,\ - com.sun.activation.registries. - -# -# List of comma-separated packages that start with or equal this string -# will cause a security exception to be thrown when -# passed to checkPackageDefinition unless the -# corresponding RuntimePermission ("defineClassInPackage."+package) has -# been granted. -# -# by default, none of the class loaders supplied with the JDK call -# checkPackageDefinition. -# -package.definition=sun.,\ - com.sun.xml.internal.,\ - com.sun.imageio.,\ - com.sun.istack.internal.,\ - com.sun.jmx.,\ - com.sun.media.sound.,\ - com.sun.naming.internal.,\ - com.sun.proxy.,\ - com.sun.corba.se.,\ - com.sun.org.apache.bcel.internal.,\ - com.sun.org.apache.regexp.internal.,\ - com.sun.org.apache.xerces.internal.,\ - com.sun.org.apache.xpath.internal.,\ - com.sun.org.apache.xalan.internal.extensions.,\ - com.sun.org.apache.xalan.internal.lib.,\ - com.sun.org.apache.xalan.internal.res.,\ - com.sun.org.apache.xalan.internal.templates.,\ - com.sun.org.apache.xalan.internal.utils.,\ - com.sun.org.apache.xalan.internal.xslt.,\ - com.sun.org.apache.xalan.internal.xsltc.cmdline.,\ - com.sun.org.apache.xalan.internal.xsltc.compiler.,\ - com.sun.org.apache.xalan.internal.xsltc.trax.,\ - com.sun.org.apache.xalan.internal.xsltc.util.,\ - com.sun.org.apache.xml.internal.res.,\ - com.sun.org.apache.xml.internal.security.,\ - com.sun.org.apache.xml.internal.serializer.utils.,\ - com.sun.org.apache.xml.internal.utils.,\ - com.sun.org.glassfish.,\ - com.oracle.xmlns.internal.,\ - com.oracle.webservices.internal.,\ - org.jcp.xml.dsig.internal.,\ - jdk.internal.,\ - jdk.nashorn.internal.,\ - jdk.nashorn.tools.,\ - com.sun.activation.registries. - -# -# Determines whether this properties file can be appended to -# or overridden on the command line via -Djava.security.properties -# -security.overridePropertiesFile=true - -# -# Determines the default key and trust manager factory algorithms for -# the javax.net.ssl package. -# -ssl.KeyManagerFactory.algorithm=SunX509 -ssl.TrustManagerFactory.algorithm=PKIX - -# -# The Java-level namelookup cache policy for successful lookups: -# -# any negative value: caching forever -# any positive value: the number of seconds to cache an address for -# zero: do not cache -# -# default value is forever (FOREVER). For security reasons, this -# caching is made forever when a security manager is set. When a security -# manager is not set, the default behavior in this implementation -# is to cache for 30 seconds. -# -# NOTE: setting this to anything other than the default value can have -# serious security implications. Do not set it unless -# you are sure you are not exposed to DNS spoofing attack. -# -#networkaddress.cache.ttl=-1 - -# The Java-level namelookup cache policy for failed lookups: -# -# any negative value: cache forever -# any positive value: the number of seconds to cache negative lookup results -# zero: do not cache -# -# In some Microsoft Windows networking environments that employ -# the WINS name service in addition to DNS, name service lookups -# that fail may take a noticeably long time to return (approx. 5 seconds). -# For this reason the default caching policy is to maintain these -# results for 10 seconds. -# -# -networkaddress.cache.negative.ttl=10 - -# -# Properties to configure OCSP for certificate revocation checking -# - -# Enable OCSP -# -# By default, OCSP is not used for certificate revocation checking. -# This property enables the use of OCSP when set to the value "true". -# -# NOTE: SocketPermission is required to connect to an OCSP responder. -# -# Example, -# ocsp.enable=true - -# -# Location of the OCSP responder -# -# By default, the location of the OCSP responder is determined implicitly -# from the certificate being validated. This property explicitly specifies -# the location of the OCSP responder. The property is used when the -# Authority Information Access extension (defined in RFC 3280) is absent -# from the certificate or when it requires overriding. -# -# Example, -# ocsp.responderURL=http://ocsp.example.net:80 - -# -# Subject name of the OCSP responder's certificate -# -# By default, the certificate of the OCSP responder is that of the issuer -# of the certificate being validated. This property identifies the certificate -# of the OCSP responder when the default does not apply. Its value is a string -# distinguished name (defined in RFC 2253) which identifies a certificate in -# the set of certificates supplied during cert path validation. In cases where -# the subject name alone is not sufficient to uniquely identify the certificate -# then both the "ocsp.responderCertIssuerName" and -# "ocsp.responderCertSerialNumber" properties must be used instead. When this -# property is set then those two properties are ignored. -# -# Example, -# ocsp.responderCertSubjectName="CN=OCSP Responder, O=XYZ Corp" - -# -# Issuer name of the OCSP responder's certificate -# -# By default, the certificate of the OCSP responder is that of the issuer -# of the certificate being validated. This property identifies the certificate -# of the OCSP responder when the default does not apply. Its value is a string -# distinguished name (defined in RFC 2253) which identifies a certificate in -# the set of certificates supplied during cert path validation. When this -# property is set then the "ocsp.responderCertSerialNumber" property must also -# be set. When the "ocsp.responderCertSubjectName" property is set then this -# property is ignored. -# -# Example, -# ocsp.responderCertIssuerName="CN=Enterprise CA, O=XYZ Corp" - -# -# Serial number of the OCSP responder's certificate -# -# By default, the certificate of the OCSP responder is that of the issuer -# of the certificate being validated. This property identifies the certificate -# of the OCSP responder when the default does not apply. Its value is a string -# of hexadecimal digits (colon or space separators may be present) which -# identifies a certificate in the set of certificates supplied during cert path -# validation. When this property is set then the "ocsp.responderCertIssuerName" -# property must also be set. When the "ocsp.responderCertSubjectName" property -# is set then this property is ignored. -# -# Example, -# ocsp.responderCertSerialNumber=2A:FF:00 - -# -# Policy for failed Kerberos KDC lookups: -# -# When a KDC is unavailable (network error, service failure, etc), it is -# put inside a blacklist and accessed less often for future requests. The -# value (case-insensitive) for this policy can be: -# -# tryLast -# KDCs in the blacklist are always tried after those not on the list. -# -# tryLess[:max_retries,timeout] -# KDCs in the blacklist are still tried by their order in the configuration, -# but with smaller max_retries and timeout values. max_retries and timeout -# are optional numerical parameters (default 1 and 5000, which means once -# and 5 seconds). Please notes that if any of the values defined here is -# more than what is defined in krb5.conf, it will be ignored. -# -# Whenever a KDC is detected as available, it is removed from the blacklist. -# The blacklist is reset when krb5.conf is reloaded. You can add -# refreshKrb5Config=true to a JAAS configuration file so that krb5.conf is -# reloaded whenever a JAAS authentication is attempted. -# -# Example, -# krb5.kdc.bad.policy = tryLast -# krb5.kdc.bad.policy = tryLess:2,2000 -krb5.kdc.bad.policy = tryLast - -# Algorithm restrictions for certification path (CertPath) processing -# -# In some environments, certain algorithms or key lengths may be undesirable -# for certification path building and validation. For example, "MD2" is -# generally no longer considered to be a secure hash algorithm. This section -# describes the mechanism for disabling algorithms based on algorithm name -# and/or key length. This includes algorithms used in certificates, as well -# as revocation information such as CRLs and signed OCSP Responses. -# -# The syntax of the disabled algorithm string is described as this Java -# BNF-style: -# DisabledAlgorithms: -# " DisabledAlgorithm { , DisabledAlgorithm } " -# -# DisabledAlgorithm: -# AlgorithmName [Constraint] -# -# AlgorithmName: -# (see below) -# -# Constraint: -# KeySizeConstraint -# -# KeySizeConstraint: -# keySize Operator DecimalInteger -# -# Operator: -# <= | < | == | != | >= | > -# -# DecimalInteger: -# DecimalDigits -# -# DecimalDigits: -# DecimalDigit {DecimalDigit} -# -# DecimalDigit: one of -# 1 2 3 4 5 6 7 8 9 0 -# -# The "AlgorithmName" is the standard algorithm name of the disabled -# algorithm. See "Java Cryptography Architecture Standard Algorithm Name -# Documentation" for information about Standard Algorithm Names. Matching -# is performed using a case-insensitive sub-element matching rule. (For -# example, in "SHA1withECDSA" the sub-elements are "SHA1" for hashing and -# "ECDSA" for signatures.) If the assertion "AlgorithmName" is a -# sub-element of the certificate algorithm name, the algorithm will be -# rejected during certification path building and validation. For example, -# the assertion algorithm name "DSA" will disable all certificate algorithms -# that rely on DSA, such as NONEwithDSA, SHA1withDSA. However, the assertion -# will not disable algorithms related to "ECDSA". -# -# A "Constraint" provides further guidance for the algorithm being specified. -# The "KeySizeConstraint" requires a key of a valid size range if the -# "AlgorithmName" is of a key algorithm. The "DecimalInteger" indicates the -# key size specified in number of bits. For example, "RSA keySize <= 1024" -# indicates that any RSA key with key size less than or equal to 1024 bits -# should be disabled, and "RSA keySize < 1024, RSA keySize > 2048" indicates -# that any RSA key with key size less than 1024 or greater than 2048 should -# be disabled. Note that the "KeySizeConstraint" only makes sense to key -# algorithms. -# -# Note: This property is currently used by Oracle's PKIX implementation. It -# is not guaranteed to be examined and used by other implementations. -# -# Example: -# jdk.certpath.disabledAlgorithms=MD2, DSA, RSA keySize < 2048 -# -# -jdk.certpath.disabledAlgorithms=MD2, MD5, RSA keySize < 1024 - -# Algorithm restrictions for Secure Socket Layer/Transport Layer Security -# (SSL/TLS) processing -# -# In some environments, certain algorithms or key lengths may be undesirable -# when using SSL/TLS. This section describes the mechanism for disabling -# algorithms during SSL/TLS security parameters negotiation, including cipher -# suites selection, peer authentication and key exchange mechanisms. -# -# For PKI-based peer authentication and key exchange mechanisms, this list -# of disabled algorithms will also be checked during certification path -# building and validation, including algorithms used in certificates, as -# well as revocation information such as CRLs and signed OCSP Responses. -# This is in addition to the jdk.certpath.disabledAlgorithms property above. -# -# See the specification of "jdk.certpath.disabledAlgorithms" for the -# syntax of the disabled algorithm string. -# -# Note: This property is currently used by Oracle's JSSE implementation. -# It is not guaranteed to be examined and used by other implementations. -# -# Example: -# jdk.tls.disabledAlgorithms=MD5, SHA1, DSA, RSA keySize < 2048 diff --git a/jdk/src/java.base/share/native/libjava/FileInputStream.c b/jdk/src/java.base/share/native/libjava/FileInputStream.c index 092ddbf6f1f..dc1aea5cd64 100644 --- a/jdk/src/java.base/share/native/libjava/FileInputStream.c +++ b/jdk/src/java.base/share/native/libjava/FileInputStream.c @@ -57,7 +57,7 @@ Java_java_io_FileInputStream_initIDs(JNIEnv *env, jclass fdClass) { */ JNIEXPORT void JNICALL -Java_java_io_FileInputStream_open(JNIEnv *env, jobject this, jstring path) { +Java_java_io_FileInputStream_open0(JNIEnv *env, jobject this, jstring path) { fileOpen(env, this, path, fis_fd, O_RDONLY); } diff --git a/jdk/src/java.base/share/native/libjava/RandomAccessFile.c b/jdk/src/java.base/share/native/libjava/RandomAccessFile.c index 53b5f1aac1f..a44d8f39681 100644 --- a/jdk/src/java.base/share/native/libjava/RandomAccessFile.c +++ b/jdk/src/java.base/share/native/libjava/RandomAccessFile.c @@ -47,8 +47,8 @@ Java_java_io_RandomAccessFile_initIDs(JNIEnv *env, jclass fdClass) { JNIEXPORT void JNICALL -Java_java_io_RandomAccessFile_open(JNIEnv *env, - jobject this, jstring path, jint mode) +Java_java_io_RandomAccessFile_open0(JNIEnv *env, + jobject this, jstring path, jint mode) { int flags = 0; if (mode & java_io_RandomAccessFile_O_RDONLY) diff --git a/jdk/src/java.base/unix/classes/sun/nio/ch/InheritedChannel.java b/jdk/src/java.base/unix/classes/sun/nio/ch/InheritedChannel.java index e696d3eba07..2bb712e7867 100644 --- a/jdk/src/java.base/unix/classes/sun/nio/ch/InheritedChannel.java +++ b/jdk/src/java.base/unix/classes/sun/nio/ch/InheritedChannel.java @@ -226,6 +226,7 @@ class InheritedChannel { // -- Native methods -- + private static native void initIDs(); private static native int dup(int fd) throws IOException; private static native void dup2(int fd, int fd2) throws IOException; private static native int open0(String path, int oflag) throws IOException; @@ -236,5 +237,6 @@ class InheritedChannel { static { IOUtil.load(); + initIDs(); } } diff --git a/jdk/src/java.base/unix/native/libjava/FileOutputStream_md.c b/jdk/src/java.base/unix/native/libjava/FileOutputStream_md.c index efd5864cd9c..22d80a22663 100644 --- a/jdk/src/java.base/unix/native/libjava/FileOutputStream_md.c +++ b/jdk/src/java.base/unix/native/libjava/FileOutputStream_md.c @@ -53,8 +53,8 @@ Java_java_io_FileOutputStream_initIDs(JNIEnv *env, jclass fdClass) { */ JNIEXPORT void JNICALL -Java_java_io_FileOutputStream_open(JNIEnv *env, jobject this, - jstring path, jboolean append) { +Java_java_io_FileOutputStream_open0(JNIEnv *env, jobject this, + jstring path, jboolean append) { fileOpen(env, this, path, fos_fd, O_WRONLY | O_CREAT | (append ? O_APPEND : O_TRUNC)); } diff --git a/jdk/src/java.base/unix/native/libjava/UNIXProcess_md.c b/jdk/src/java.base/unix/native/libjava/UNIXProcess_md.c index da5be2257d0..18dee4ddd41 100644 --- a/jdk/src/java.base/unix/native/libjava/UNIXProcess_md.c +++ b/jdk/src/java.base/unix/native/libjava/UNIXProcess_md.c @@ -599,9 +599,9 @@ Java_java_lang_UNIXProcess_forkAndExec(JNIEnv *env, */ assert(prog != NULL && argBlock != NULL); if ((phelperpath = getBytes(env, helperpath)) == NULL) goto Catch; - if ((pprog = getBytes(env, prog)) == NULL) goto Catch; - if ((pargBlock = getBytes(env, argBlock)) == NULL) goto Catch; - if ((c->argv = NEW(const char *, argc + 3)) == NULL) goto Catch; + if ((pprog = getBytes(env, prog)) == NULL) goto Catch; + if ((pargBlock = getBytes(env, argBlock)) == NULL) goto Catch; + if ((c->argv = NEW(const char *, argc + 3)) == NULL) goto Catch; c->argv[0] = pprog; c->argc = argc + 2; initVectorFromBlock(c->argv+1, pargBlock, argc); @@ -690,10 +690,11 @@ Java_java_lang_UNIXProcess_forkAndExec(JNIEnv *env, closeSafely(childenv[0]); closeSafely(childenv[1]); - releaseBytes(env, prog, pprog); - releaseBytes(env, argBlock, pargBlock); - releaseBytes(env, envBlock, penvBlock); - releaseBytes(env, dir, c->pdir); + releaseBytes(env, helperpath, phelperpath); + releaseBytes(env, prog, pprog); + releaseBytes(env, argBlock, pargBlock); + releaseBytes(env, envBlock, penvBlock); + releaseBytes(env, dir, c->pdir); free(c->argv); free(c->envv); diff --git a/jdk/src/java.base/unix/native/libnio/ch/IOUtil.c b/jdk/src/java.base/unix/native/libnio/ch/IOUtil.c index d8bbe849252..438bf41ddea 100644 --- a/jdk/src/java.base/unix/native/libnio/ch/IOUtil.c +++ b/jdk/src/java.base/unix/native/libnio/ch/IOUtil.c @@ -35,7 +35,6 @@ #include "java_lang_Integer.h" #include "nio.h" #include "nio_util.h" -#include "net_util.h" static jfieldID fd_fdID; /* for jint 'fd' in java.io.FileDescriptor */ @@ -45,7 +44,6 @@ Java_sun_nio_ch_IOUtil_initIDs(JNIEnv *env, jclass clazz) { CHECK_NULL(clazz = (*env)->FindClass(env, "java/io/FileDescriptor")); CHECK_NULL(fd_fdID = (*env)->GetFieldID(env, clazz, "fd", "I")); - initInetAddressIDs(env); } JNIEXPORT jboolean JNICALL diff --git a/jdk/src/java.base/unix/native/libnio/ch/InheritedChannel.c b/jdk/src/java.base/unix/native/libnio/ch/InheritedChannel.c index 986348e5320..86d1b05baa2 100644 --- a/jdk/src/java.base/unix/native/libnio/ch/InheritedChannel.c +++ b/jdk/src/java.base/unix/native/libnio/ch/InheritedChannel.c @@ -47,6 +47,13 @@ static int matchFamily(struct sockaddr *sa) { return (family == AF_INET); } +JNIEXPORT void JNICALL +Java_sun_nio_ch_InheritedChannel_initIDs(JNIEnv *env, jclass cla) +{ + /* Initialize InetAddress IDs before later use of NET_XXX functions */ + initInetAddressIDs(env); +} + JNIEXPORT jobject JNICALL Java_sun_nio_ch_InheritedChannel_peerAddress0(JNIEnv *env, jclass cla, jint fd) { diff --git a/jdk/src/java.base/unix/native/libnio/ch/Net.c b/jdk/src/java.base/unix/native/libnio/ch/Net.c index 8887f59109c..197b23a7285 100644 --- a/jdk/src/java.base/unix/native/libnio/ch/Net.c +++ b/jdk/src/java.base/unix/native/libnio/ch/Net.c @@ -151,7 +151,7 @@ static jboolean isSourceFilterSupported(){ JNIEXPORT void JNICALL Java_sun_nio_ch_Net_initIDs(JNIEnv *env, jclass clazz) { - /* Here because Windows native code does need to init IDs */ + initInetAddressIDs(env); } JNIEXPORT jboolean JNICALL diff --git a/jdk/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c b/jdk/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c index d3ee3279e54..e8a1623a87d 100644 --- a/jdk/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c +++ b/jdk/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c @@ -333,7 +333,7 @@ Java_sun_nio_fs_UnixNativeDispatcher_dup(JNIEnv* env, jclass this, jint fd) { int res = -1; RESTARTABLE(dup((int)fd), res); - if (fd == -1) { + if (res == -1) { throwUnixException(env, errno); } return (jint)res; @@ -361,13 +361,14 @@ Java_sun_nio_fs_UnixNativeDispatcher_fopen0(JNIEnv* env, jclass this, JNIEXPORT void JNICALL Java_sun_nio_fs_UnixNativeDispatcher_fclose(JNIEnv* env, jclass this, jlong stream) { - int res; FILE* fp = jlong_to_ptr(stream); - do { - res = fclose(fp); - } while (res == EOF && errno == EINTR); - if (res == EOF) { + /* NOTE: fclose() wrapper is only used with read-only streams. + * If it ever is used with write streams, it might be better to add + * RESTARTABLE(fflush(fp)) before closing, to make sure the stream + * is completely written even if fclose() failed. + */ + if (fclose(fp) == EOF && errno != EINTR) { throwUnixException(env, errno); } } @@ -675,11 +676,9 @@ Java_sun_nio_fs_UnixNativeDispatcher_fdopendir(JNIEnv* env, jclass this, int dfd JNIEXPORT void JNICALL Java_sun_nio_fs_UnixNativeDispatcher_closedir(JNIEnv* env, jclass this, jlong dir) { - int err; DIR* dirp = jlong_to_ptr(dir); - RESTARTABLE(closedir(dirp), err); - if (errno == -1) { + if (closedir(dirp) == -1 && errno != EINTR) { throwUnixException(env, errno); } } diff --git a/jdk/src/java.base/windows/native/libjava/FileOutputStream_md.c b/jdk/src/java.base/windows/native/libjava/FileOutputStream_md.c index 567ebaa0c83..02ea15e89cb 100644 --- a/jdk/src/java.base/windows/native/libjava/FileOutputStream_md.c +++ b/jdk/src/java.base/windows/native/libjava/FileOutputStream_md.c @@ -54,8 +54,8 @@ Java_java_io_FileOutputStream_initIDs(JNIEnv *env, jclass fosClass) { */ JNIEXPORT void JNICALL -Java_java_io_FileOutputStream_open(JNIEnv *env, jobject this, - jstring path, jboolean append) { +Java_java_io_FileOutputStream_open0(JNIEnv *env, jobject this, + jstring path, jboolean append) { fileOpen(env, this, path, fos_fd, O_WRONLY | O_CREAT | (append ? O_APPEND : O_TRUNC)); } diff --git a/jdk/src/java.base/windows/native/libjava/WinNTFileSystem_md.c b/jdk/src/java.base/windows/native/libjava/WinNTFileSystem_md.c index 6ecf818d3ff..3c280c0c9b4 100644 --- a/jdk/src/java.base/windows/native/libjava/WinNTFileSystem_md.c +++ b/jdk/src/java.base/windows/native/libjava/WinNTFileSystem_md.c @@ -572,10 +572,10 @@ Java_java_io_WinNTFileSystem_createFileExclusively(JNIEnv *env, jclass cls, SetLastError(error); JNU_ThrowIOExceptionWithLastError(env, "Could not open file"); } - } - free(pathbuf); - return JNI_FALSE; } + free(pathbuf); + return JNI_FALSE; + } free(pathbuf); CloseHandle(h); return JNI_TRUE; @@ -636,7 +636,7 @@ Java_java_io_WinNTFileSystem_list(JNIEnv *env, jobject this, jobject file) if (search_path == 0) { free (pathbuf); errno = ENOMEM; - JNU_ThrowOutOfMemoryError(env, "native memory allocation faiuled"); + JNU_ThrowOutOfMemoryError(env, "native memory allocation failed"); return NULL; } wcscpy(search_path, pathbuf); @@ -652,7 +652,7 @@ Java_java_io_WinNTFileSystem_list(JNIEnv *env, jobject this, jobject file) /* Remove trailing space chars from directory name */ len = (int)wcslen(search_path); - while (search_path[len-1] == ' ') { + while (search_path[len-1] == L' ') { len--; } search_path[len] = 0; @@ -713,13 +713,15 @@ Java_java_io_WinNTFileSystem_list(JNIEnv *env, jobject this, jobject file) return NULL; // error FindClose(handle); - /* Copy the final results into an appropriately-sized array */ - old = rv; - rv = (*env)->NewObjectArray(env, len, str_class, NULL); - if (rv == NULL) - return NULL; /* error */ - if (JNU_CopyObjectArray(env, rv, old, len) < 0) - return NULL; /* error */ + if (len < maxlen) { + /* Copy the final results into an appropriately-sized array */ + old = rv; + rv = (*env)->NewObjectArray(env, len, str_class, NULL); + if (rv == NULL) + return NULL; /* error */ + if (JNU_CopyObjectArray(env, rv, old, len) < 0) + return NULL; /* error */ + } return rv; } @@ -753,9 +755,7 @@ Java_java_io_WinNTFileSystem_rename0(JNIEnv *env, jobject this, jobject from, jboolean rv = JNI_FALSE; WCHAR *frompath = fileToNTPath(env, from, ids.path); WCHAR *topath = fileToNTPath(env, to, ids.path); - if (frompath == NULL || topath == NULL) - return JNI_FALSE; - if (_wrename(frompath, topath) == 0) { + if (frompath != NULL && topath != NULL && _wrename(frompath, topath) == 0) { rv = JNI_TRUE; } free(frompath); diff --git a/jdk/src/java.base/windows/native/libnio/ch/IOUtil.c b/jdk/src/java.base/windows/native/libnio/ch/IOUtil.c index 49de1eb89d7..5c33ac4de23 100644 --- a/jdk/src/java.base/windows/native/libnio/ch/IOUtil.c +++ b/jdk/src/java.base/windows/native/libnio/ch/IOUtil.c @@ -56,7 +56,6 @@ Java_sun_nio_ch_IOUtil_initIDs(JNIEnv *env, jclass clazz) CHECK_NULL(clazz = (*env)->FindClass(env, "java/io/FileDescriptor")); CHECK_NULL(fd_fdID = (*env)->GetFieldID(env, clazz, "fd", "I")); CHECK_NULL(handle_fdID = (*env)->GetFieldID(env, clazz, "handle", "J")); - initInetAddressIDs(env); } /************************************************************** diff --git a/jdk/src/java.base/windows/native/libnio/ch/Net.c b/jdk/src/java.base/windows/native/libnio/ch/Net.c index fb0faa87b84..b92e63ac11b 100644 --- a/jdk/src/java.base/windows/native/libnio/ch/Net.c +++ b/jdk/src/java.base/windows/native/libnio/ch/Net.c @@ -81,7 +81,7 @@ static void setConnectionReset(SOCKET s, BOOL enable) { JNIEXPORT void JNICALL Java_sun_nio_ch_Net_initIDs(JNIEnv *env, jclass clazz) { - /* nothing to do */ + initInetAddressIDs(env); } JNIEXPORT jboolean JNICALL diff --git a/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIControl.java b/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIControl.java index 28df9def412..eeed61d3798 100644 --- a/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIControl.java +++ b/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIControl.java @@ -114,7 +114,7 @@ public final class JRSUIControl { changes.putAll(other.changes); } - protected synchronized final void finalize() throws Throwable { + protected synchronized void finalize() throws Throwable { if (cfDictionaryPtr == 0) return; disposeCFDictionary(cfDictionaryPtr); cfDictionaryPtr = 0; diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameUI.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameUI.java index 90ce8ca5b80..2ba95f6af05 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameUI.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameUI.java @@ -938,7 +938,11 @@ public class AquaInternalFrameUI extends BasicInternalFrameUI implements SwingCo final Point pt = new Point(); final Component c = getComponentToForwardTo(e, pt); if (c == null) return; - c.dispatchEvent(new MouseWheelEvent(c, e.getID(), e.getWhen(), e.getModifiers(), pt.x, pt.y, e.getClickCount(), e.isPopupTrigger(), e.getScrollType(), e.getScrollAmount(), e.getWheelRotation())); + c.dispatchEvent(new MouseWheelEvent(c, e.getID(), e.getWhen(), + e.getModifiers(), pt.x, pt.y, e.getXOnScreen(), e.getYOnScreen(), + e.getClickCount(), e.isPopupTrigger(), e.getScrollType(), + e.getScrollAmount(), e.getWheelRotation(), + e.getPreciseWheelRotation())); } public void componentResized(final ComponentEvent e) { diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneCopyFromBasicUI.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneCopyFromBasicUI.java index 8dd4fa60d2d..3e40b843449 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneCopyFromBasicUI.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneCopyFromBasicUI.java @@ -3307,7 +3307,7 @@ public class AquaTabbedPaneCopyFromBasicUI extends TabbedPaneUI implements Swing pane.repaint(); } else if (name == "indexForTitle") { calculatedBaseline = false; - updateHtmlViews((Integer) e.getNewValue()); + updateHtmlViews((Integer) e.getNewValue(), false); } else if (name == "tabLayoutPolicy") { AquaTabbedPaneCopyFromBasicUI.this.uninstallUI(pane); AquaTabbedPaneCopyFromBasicUI.this.installUI(pane); @@ -3345,7 +3345,7 @@ public class AquaTabbedPaneCopyFromBasicUI extends TabbedPaneUI implements Swing calculatedBaseline = false; } else if (name == "indexForNullComponent") { isRunsDirty = true; - updateHtmlViews((Integer) e.getNewValue()); + updateHtmlViews((Integer) e.getNewValue(), true); } else if (name == "font") { calculatedBaseline = false; } @@ -3464,10 +3464,10 @@ public class AquaTabbedPaneCopyFromBasicUI extends TabbedPaneUI implements Swing return; } isRunsDirty = true; - updateHtmlViews(tp.indexOfComponent(child)); + updateHtmlViews(tp.indexOfComponent(child), true); } - private void updateHtmlViews(int index) { + private void updateHtmlViews(int index, boolean inserted) { final String title = tabPane.getTitleAt(index); final boolean isHTML = BasicHTML.isHTMLString(title); if (isHTML) { @@ -3475,16 +3475,24 @@ public class AquaTabbedPaneCopyFromBasicUI extends TabbedPaneUI implements Swing htmlViews = createHTMLVector(); } else { // Vector already exists final View v = BasicHTML.createHTMLView(tabPane, title); - htmlViews.insertElementAt(v, index); + setHtmlView(v, inserted, index); } } else { // Not HTML if (htmlViews != null) { // Add placeholder - htmlViews.insertElementAt(null, index); + setHtmlView(null, inserted, index); } // else nada! } updateMnemonics(); } + private void setHtmlView(View v, boolean inserted, int index) { + if (inserted || index >= htmlViews.size()) { + htmlViews.insertElementAt(v, index); + } else { + htmlViews.setElementAt(v, index); + } + } + public void componentRemoved(final ContainerEvent e) { final JTabbedPane tp = (JTabbedPane)e.getContainer(); final Component child = e.getChild(); diff --git a/jdk/src/java.desktop/macosx/classes/sun/font/CFontManager.java b/jdk/src/java.desktop/macosx/classes/sun/font/CFontManager.java index 8e1cead53c2..28c59712fe7 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/font/CFontManager.java +++ b/jdk/src/java.desktop/macosx/classes/sun/font/CFontManager.java @@ -43,7 +43,7 @@ import sun.awt.HeadlessToolkit; import sun.awt.util.ThreadGroupUtils; import sun.lwawt.macosx.*; -public class CFontManager extends SunFontManager { +public final class CFontManager extends SunFontManager { private FontConfigManager fcManager = null; private static Hashtable genericFonts = new Hashtable(); @@ -61,20 +61,14 @@ public class CFontManager extends SunFontManager { return new CFontConfiguration(this, preferLocaleFonts, preferPropFonts); } - private static String[] defaultPlatformFont = null; - /* * Returns an array of two strings. The first element is the * name of the font. The second element is the file name. */ @Override - public synchronized String[] getDefaultPlatformFont() { - if (defaultPlatformFont == null) { - defaultPlatformFont = new String[2]; - defaultPlatformFont[0] = "Lucida Grande"; - defaultPlatformFont[1] = "/System/Library/Fonts/LucidaGrande.ttc"; - } - return defaultPlatformFont; + protected String[] getDefaultPlatformFont() { + return new String[]{"Lucida Grande", + "/System/Library/Fonts/LucidaGrande.ttc"}; } // This is a way to register any kind of Font2D, not just files and composites. diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWComponentPeer.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWComponentPeer.java index 408862f7746..ca731ba3a72 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWComponentPeer.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWComponentPeer.java @@ -1233,11 +1233,13 @@ public abstract class LWComponentPeer delegate, me.getID(), me.getWhen(), me.getModifiers(), me.getX(), me.getY(), + me.getXOnScreen(), me.getYOnScreen(), me.getClickCount(), me.isPopupTrigger(), me.getScrollType(), me.getScrollAmount(), - me.getWheelRotation()); + me.getWheelRotation(), + me.getPreciseWheelRotation()); } else if (e instanceof MouseEvent) { MouseEvent me = (MouseEvent) e; diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java index b72ef77d876..4655d2bcfca 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java @@ -105,6 +105,8 @@ public class LWWindowPeer private final SecurityWarningWindow warningWindow; + private volatile boolean targetFocusable; + /** * Current modal blocker or null. * @@ -240,13 +242,12 @@ public class LWWindowPeer if (!visible && warningWindow != null) { warningWindow.setVisible(false, false); } - + updateFocusableWindowState(); super.setVisibleImpl(visible); // TODO: update graphicsConfig, see 4868278 platformWindow.setVisible(visible); if (isSimpleWindow()) { KeyboardFocusManagerPeer kfmPeer = LWKeyboardFocusManagerPeer.getInstance(); - if (visible) { if (!getTarget().isAutoRequestFocus()) { return; @@ -397,6 +398,7 @@ public class LWWindowPeer @Override public void updateFocusableWindowState() { + targetFocusable = getTarget().isFocusableWindow(); platformWindow.updateFocusableWindowState(); } @@ -1220,13 +1222,13 @@ public class LWWindowPeer } private boolean isFocusableWindow() { - boolean focusable = getTarget().isFocusableWindow(); + boolean focusable = targetFocusable; if (isSimpleWindow()) { LWWindowPeer ownerPeer = getOwnerFrameDialog(this); if (ownerPeer == null) { return false; } - return focusable && ownerPeer.getTarget().isFocusableWindow(); + return focusable && ownerPeer.targetFocusable; } return focusable; } diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java index c241aae3cc0..7618bbec2a4 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java @@ -38,7 +38,8 @@ public class CEmbeddedFrame extends EmbeddedFrame { private CPlatformResponder responder; private static final Object classLock = new Object(); - private static volatile CEmbeddedFrame focusedWindow; + private static volatile CEmbeddedFrame globalFocusedWindow; + private CEmbeddedFrame browserWindowFocusedApplet; private boolean parentWindowActive = true; public CEmbeddedFrame() { @@ -111,10 +112,10 @@ public class CEmbeddedFrame extends EmbeddedFrame { synchronized (classLock) { // In some cases an applet may not receive the focus lost event // from the parent window (see 8012330) - focusedWindow = (focused) ? this - : ((focusedWindow == this) ? null : focusedWindow); + globalFocusedWindow = (focused) ? this + : ((globalFocusedWindow == this) ? null : globalFocusedWindow); } - if (focusedWindow == this) { + if (globalFocusedWindow == this) { // see bug 8010925 // we can't put this to handleWindowFocusEvent because // it won't be invoced if focuse is moved to a html element @@ -145,9 +146,23 @@ public class CEmbeddedFrame extends EmbeddedFrame { // non-focused applet. This method can be called from different threads. public void handleWindowFocusEvent(boolean parentWindowActive) { this.parentWindowActive = parentWindowActive; + // If several applets are running in different browser's windows, it is necessary to + // detect the switching between the parent windows and update globalFocusedWindow accordingly. + synchronized (classLock) { + if (!parentWindowActive) { + this.browserWindowFocusedApplet = globalFocusedWindow; + } + if (parentWindowActive && globalFocusedWindow != this && isParentWindowChanged()) { + // It looks like we have switched to another browser window, let's restore focus to + // the previously focused applet in this window. If no applets were focused in the + // window, we will set focus to the first applet in the window. + globalFocusedWindow = (this.browserWindowFocusedApplet != null) ? this.browserWindowFocusedApplet + : this; + } + } // ignore focus "lost" native request as it may mistakenly // deactivate active window (see 8001161) - if (focusedWindow == this && parentWindowActive) { + if (globalFocusedWindow == this && parentWindowActive) { responder.handleWindowFocusEvent(parentWindowActive, null); } } @@ -155,4 +170,10 @@ public class CEmbeddedFrame extends EmbeddedFrame { public boolean isParentWindowActive() { return parentWindowActive; } + + private boolean isParentWindowChanged() { + // If globalFocusedWindow is located at inactive parent window or null, we have swithed to + // another window. + return globalFocusedWindow != null ? !globalFocusedWindow.isParentWindowActive() : true; + } } diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/NSPrintInfo.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/NSPrintInfo.java index 16bada2688c..7a33fdf22e2 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/NSPrintInfo.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/NSPrintInfo.java @@ -54,11 +54,11 @@ public final class NSPrintInfo implements PrintJobAttribute, PrintRequestAttribu return "" + fNSPrintInfo; } - public final Class getCategory() { + public Class getCategory() { return NSPrintInfo.class; } - public final String getName() { + public String getName() { return "nsPrintInfo"; } } diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/sun/awt/JavaComponentAccessibility.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/sun/awt/JavaComponentAccessibility.m index e0de79524e8..1b3ec43a9fe 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/sun/awt/JavaComponentAccessibility.m +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/sun/awt/JavaComponentAccessibility.m @@ -1108,7 +1108,10 @@ static NSObject *sAttributeNamesLOCK = nil; JNIEnv *env = [ThreadUtilities getJNIEnv]; id value = nil; + NSWindow* hostWindow = [[self->fView window] retain]; jobject focused = JNFCallStaticObjectMethod(env, jm_getFocusOwner, fComponent); // AWT_THREADING Safe (AWTRunLoop) + [hostWindow release]; + if (focused != NULL) { if (JNFIsInstanceOf(env, focused, &sjc_Accessible)) { value = [JavaComponentAccessibility createWithAccessible:focused withEnv:env withView:fView]; diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/FFT.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/FFT.java index b378c8cc65d..8b1436736c0 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/FFT.java +++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/FFT.java @@ -68,7 +68,7 @@ public final class FFT { calc(fftFrameSize, data, sign, w); } - private final static double[] computeTwiddleFactors(int fftFrameSize, + private static double[] computeTwiddleFactors(int fftFrameSize, int sign) { int imax = (int) (Math.log(fftFrameSize) / Math.log(2.)); @@ -122,7 +122,7 @@ public final class FFT { return warray; } - private final static void calc(int fftFrameSize, double[] data, int sign, + private static void calc(int fftFrameSize, double[] data, int sign, double[] w) { final int fftFrameSize2 = fftFrameSize << 1; @@ -139,7 +139,7 @@ public final class FFT { } - private final static void calcF2E(int fftFrameSize, double[] data, int i, + private static void calcF2E(int fftFrameSize, double[] data, int i, int nstep, double[] w) { int jmax = nstep; for (int n = 0; n < jmax; n += 2) { @@ -163,7 +163,7 @@ public final class FFT { // Perform Factor-4 Decomposition with 3 * complex operators and 8 +/- // complex operators - private final static void calcF4F(int fftFrameSize, double[] data, int i, + private static void calcF4F(int fftFrameSize, double[] data, int i, int nstep, double[] w) { final int fftFrameSize2 = fftFrameSize << 1; // 2*fftFrameSize; // Factor-4 Decomposition @@ -331,7 +331,7 @@ public final class FFT { // Perform Factor-4 Decomposition with 3 * complex operators and 8 +/- // complex operators - private final static void calcF4I(int fftFrameSize, double[] data, int i, + private static void calcF4I(int fftFrameSize, double[] data, int i, int nstep, double[] w) { final int fftFrameSize2 = fftFrameSize << 1; // 2*fftFrameSize; // Factor-4 Decomposition @@ -499,7 +499,7 @@ public final class FFT { // Perform Factor-4 Decomposition with 3 * complex operators and 8 +/- // complex operators - private final static void calcF4FE(int fftFrameSize, double[] data, int i, + private static void calcF4FE(int fftFrameSize, double[] data, int i, int nstep, double[] w) { final int fftFrameSize2 = fftFrameSize << 1; // 2*fftFrameSize; // Factor-4 Decomposition @@ -593,7 +593,7 @@ public final class FFT { // Perform Factor-4 Decomposition with 3 * complex operators and 8 +/- // complex operators - private final static void calcF4IE(int fftFrameSize, double[] data, int i, + private static void calcF4IE(int fftFrameSize, double[] data, int i, int nstep, double[] w) { final int fftFrameSize2 = fftFrameSize << 1; // 2*fftFrameSize; // Factor-4 Decomposition @@ -685,7 +685,7 @@ public final class FFT { } - private final void bitreversal(double[] data) { + private void bitreversal(double[] data) { if (fftFrameSize < 4) return; diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/JDK13Services.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/JDK13Services.java index 9c93d06dc23..3805bb8848c 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/JDK13Services.java +++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/JDK13Services.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -25,6 +25,8 @@ package com.sun.media.sound; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -176,11 +178,11 @@ public final class JDK13Services { && !Sequencer.class.equals(typeClass)) { return null; } - String value; - String propertyName = typeClass.getName(); - value = JSSecurityManager.getProperty(propertyName); + String name = typeClass.getName(); + String value = AccessController.doPrivileged( + (PrivilegedAction) () -> System.getProperty(name)); if (value == null) { - value = getProperties().getProperty(propertyName); + value = getProperties().getProperty(name); } if ("".equals(value)) { value = null; diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/JSSecurityManager.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/JSSecurityManager.java index 60549a77ea4..6614b088cf3 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/JSSecurityManager.java +++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/JSSecurityManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -73,33 +73,6 @@ final class JSSecurityManager { } } - static String getProperty(final String propertyName) { - String propertyValue; - if (hasSecurityManager()) { - if(Printer.debug) Printer.debug("using JDK 1.2 security to get property"); - try{ - PrivilegedAction action = new PrivilegedAction() { - public String run() { - try { - return System.getProperty(propertyName); - } catch (Throwable t) { - return null; - } - } - }; - propertyValue = AccessController.doPrivileged(action); - } catch( Exception e ) { - if(Printer.debug) Printer.debug("not using JDK 1.2 security to get properties"); - propertyValue = System.getProperty(propertyName); - } - } else { - if(Printer.debug) Printer.debug("not using JDK 1.2 security to get properties"); - propertyValue = System.getProperty(propertyName); - } - return propertyValue; - } - - /** Load properties from a file. This method tries to load properties from the filename give into the passed properties object. diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/Platform.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/Platform.java index 766e485f120..493aa7e0bd5 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/Platform.java +++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/Platform.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -74,17 +74,6 @@ final class Platform { // intel is little-endian. sparc is big-endian. private static boolean bigEndian; - // this is the value of the "java.home" system property. i am looking it up here - // for use when trying to load the soundbank, just so - // that all the privileged code is localized in this file.... - private static String javahome; - - // this is the value of the "java.class.path" system property - private static String classpath; - - - - static { if(Printer.trace)Printer.trace(">> Platform.java: static"); @@ -129,26 +118,6 @@ final class Platform { return signed8; } - - /** - * Obtain javahome. - * $$kk: 04.16.99: this is *bad*!! - */ - static String getJavahome() { - - return javahome; - } - - /** - * Obtain classpath. - * $$jb: 04.21.99: this is *bad* too!! - */ - static String getClasspath() { - - return classpath; - } - - // PRIVATE METHODS /** @@ -157,21 +126,13 @@ final class Platform { private static void loadLibraries() { if(Printer.trace)Printer.trace(">>Platform.loadLibraries"); - try { - // load the main library - AccessController.doPrivileged(new PrivilegedAction() { - @Override - public Void run() { - System.loadLibrary(libNameMain); - return null; - } - }); - // just for the heck of it... - loadedLibs |= LIB_MAIN; - } catch (SecurityException e) { - if(Printer.err)Printer.err("Security exception loading main native library. JavaSound requires access to these resources."); - throw(e); - } + // load the main library + AccessController.doPrivileged((PrivilegedAction) () -> { + System.loadLibrary(libNameMain); + return null; + }); + // just for the heck of it... + loadedLibs |= LIB_MAIN; // now try to load extra libs. They are defined at compile time in the Makefile // with the define EXTRA_SOUND_JNI_LIBS @@ -181,12 +142,9 @@ final class Platform { while (st.hasMoreTokens()) { final String lib = st.nextToken(); try { - AccessController.doPrivileged(new PrivilegedAction() { - @Override - public Void run() { - System.loadLibrary(lib); - return null; - } + AccessController.doPrivileged((PrivilegedAction) () -> { + System.loadLibrary(lib); + return null; }); if (lib.equals(libNameALSA)) { @@ -239,7 +197,5 @@ final class Platform { // $$fb 2002-03-06: implement check for endianness in native. Facilitates porting ! bigEndian = nIsBigEndian(); signed8 = nIsSigned8(); // Solaris on Sparc: signed, all others unsigned - javahome = JSSecurityManager.getProperty("java.home"); - classpath = JSSecurityManager.getProperty("java.class.path"); } } diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/RIFFReader.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/RIFFReader.java index 7969a5d4fce..9849fbcb961 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/RIFFReader.java +++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/RIFFReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,21 +39,20 @@ public final class RIFFReader extends InputStream { private long filepointer = 0; private final String fourcc; private String riff_type = null; - private long ckSize = 0; + private long ckSize = Integer.MAX_VALUE; private InputStream stream; - private long avail; + private long avail = Integer.MAX_VALUE; private RIFFReader lastiterator = null; public RIFFReader(InputStream stream) throws IOException { - if (stream instanceof RIFFReader) - root = ((RIFFReader)stream).root; - else + if (stream instanceof RIFFReader) { + root = ((RIFFReader) stream).root; + } else { root = this; + } this.stream = stream; - avail = Integer.MAX_VALUE; - ckSize = Integer.MAX_VALUE; // Check for RIFF null paddings, int b; @@ -76,10 +75,12 @@ public final class RIFFReader extends InputStream { readFully(fourcc, 1, 3); this.fourcc = new String(fourcc, "ascii"); ckSize = readUnsignedInt(); - - avail = this.ckSize; + avail = ckSize; if (getFormat().equals("RIFF") || getFormat().equals("LIST")) { + if (avail > Integer.MAX_VALUE) { + throw new RIFFInvalidDataException("Chunk size too big"); + } byte[] format = new byte[4]; readFully(format); this.riff_type = new String(format, "ascii"); @@ -118,19 +119,23 @@ public final class RIFFReader extends InputStream { } public int read() throws IOException { - if (avail == 0) + if (avail == 0) { return -1; + } int b = stream.read(); - if (b == -1) + if (b == -1) { + avail = 0; return -1; + } avail--; filepointer++; return b; } public int read(byte[] b, int offset, int len) throws IOException { - if (avail == 0) + if (avail == 0) { return -1; + } if (len > avail) { int rlen = stream.read(b, offset, (int)avail); if (rlen != -1) @@ -139,19 +144,21 @@ public final class RIFFReader extends InputStream { return rlen; } else { int ret = stream.read(b, offset, len); - if (ret == -1) + if (ret == -1) { + avail = 0; return -1; + } avail -= ret; filepointer += ret; return ret; } } - public final void readFully(byte b[]) throws IOException { + public void readFully(byte b[]) throws IOException { readFully(b, 0, b.length); } - public final void readFully(byte b[], int off, int len) throws IOException { + public void readFully(byte b[], int off, int len) throws IOException { if (len < 0) throw new IndexOutOfBoundsException(); while (len > 0) { @@ -165,7 +172,7 @@ public final class RIFFReader extends InputStream { } } - public final long skipBytes(long n) throws IOException { + public long skipBytes(long n) throws IOException { if (n < 0) return 0; long skipped = 0; @@ -191,8 +198,10 @@ public final class RIFFReader extends InputStream { return len; } else { long ret = stream.skip(n); - if (ret == -1) + if (ret == -1) { + avail = 0; return -1; + } avail -= ret; filepointer += ret; return ret; @@ -210,8 +219,13 @@ public final class RIFFReader extends InputStream { } // Read ASCII chars from stream - public String readString(int len) throws IOException { - byte[] buff = new byte[len]; + public String readString(final int len) throws IOException { + final byte[] buff; + try { + buff = new byte[len]; + } catch (final OutOfMemoryError oom) { + throw new IOException("Length too big", oom); + } readFully(buff); for (int i = 0; i < buff.length; i++) { if (buff[i] == 0) { diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/SF2Soundbank.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/SF2Soundbank.java index 83c8848b4f9..d45d50162bb 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/SF2Soundbank.java +++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/SF2Soundbank.java @@ -276,6 +276,9 @@ public final class SF2Soundbank implements Soundbank { count--; } + if (presets_bagNdx.isEmpty()) { + throw new RIFFInvalidDataException(); + } int offset = presets_bagNdx.get(0); // Offset should be 0 (but just case) for (int i = 0; i < offset; i++) { @@ -360,6 +363,9 @@ public final class SF2Soundbank implements Soundbank { count--; } + if (instruments_bagNdx.isEmpty()) { + throw new RIFFInvalidDataException(); + } int offset = instruments_bagNdx.get(0); // Offset should be 0 (but just case) for (int i = 0; i < offset; i++) { @@ -401,6 +407,9 @@ public final class SF2Soundbank implements Soundbank { modulator.amount = chunk.readShort(); modulator.amountSourceOperator = chunk.readUnsignedShort(); modulator.transportOperator = chunk.readUnsignedShort(); + if (i < 0 || i >= instruments_splits_gen.size()) { + throw new RIFFInvalidDataException(); + } SF2LayerRegion split = instruments_splits_gen.get(i); if (split != null) split.modulators.add(modulator); @@ -424,7 +433,8 @@ public final class SF2Soundbank implements Soundbank { sample.name = chunk.readString(20); long start = chunk.readUnsignedInt(); long end = chunk.readUnsignedInt(); - sample.data = sampleData.subbuffer(start * 2, end * 2, true); + if (sampleData != null) + sample.data = sampleData.subbuffer(start * 2, end * 2, true); if (sampleData24 != null) sample.data24 = sampleData24.subbuffer(start, end, true); /* @@ -462,6 +472,9 @@ public final class SF2Soundbank implements Soundbank { int sampleid = split.generators.get( SF2LayerRegion.GENERATOR_SAMPLEID); split.generators.remove(SF2LayerRegion.GENERATOR_SAMPLEID); + if (sampleid < 0 || sampleid >= samples.size()) { + throw new RIFFInvalidDataException(); + } split.sample = samples.get(sampleid); } else { globalsplit = split; @@ -488,6 +501,9 @@ public final class SF2Soundbank implements Soundbank { int instrumentid = split.generators.get( SF2InstrumentRegion.GENERATOR_INSTRUMENT); split.generators.remove(SF2LayerRegion.GENERATOR_INSTRUMENT); + if (instrumentid < 0 || instrumentid >= layers.size()) { + throw new RIFFInvalidDataException(); + } split.layer = layers.get(instrumentid); } else { globalsplit = split; diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftMidiAudioFileReader.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftMidiAudioFileReader.java index 48ae72fcb02..5089a87199a 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftMidiAudioFileReader.java +++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftMidiAudioFileReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,6 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package com.sun.media.sound; import java.io.File; @@ -39,14 +40,14 @@ import javax.sound.midi.Receiver; import javax.sound.midi.Sequence; import javax.sound.midi.Track; import javax.sound.sampled.AudioFileFormat; +import javax.sound.sampled.AudioFileFormat.Type; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.UnsupportedAudioFileException; -import javax.sound.sampled.AudioFileFormat.Type; import javax.sound.sampled.spi.AudioFileReader; /** - * MIDI File Audio Renderer/Reader + * MIDI File Audio Renderer/Reader. * * @author Karl Helgason */ @@ -109,6 +110,9 @@ public final class SoftMidiAudioFileReader extends AudioFileReader { if (divtype == Sequence.PPQ) { if (((MetaMessage) msg).getType() == 0x51) { byte[] data = ((MetaMessage) msg).getData(); + if (data.length < 3) { + throw new UnsupportedAudioFileException(); + } mpq = ((data[0] & 0xff) << 16) | ((data[1] & 0xff) << 8) | (data[2] & 0xff); } diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftSynthesizer.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftSynthesizer.java index 2c6dff99fea..e895ead074f 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftSynthesizer.java +++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftSynthesizer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 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 @@ -28,6 +28,7 @@ package com.sun.media.sound; import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; @@ -732,31 +733,28 @@ public final class SoftSynthesizer implements AudioSynthesizer, * Save generated soundbank to disk for faster future use. */ OutputStream out = AccessController - .doPrivileged(new PrivilegedAction() { - public OutputStream run() { - try { - File userhome = new File(System - .getProperty("user.home"), - ".gervill"); - if (!userhome.exists()) - userhome.mkdirs(); - File emg_soundbank_file = new File( - userhome, "soundbank-emg.sf2"); - if (emg_soundbank_file.exists()) - return null; - return new FileOutputStream( - emg_soundbank_file); - } catch (IOException e) { - } catch (SecurityException e) { + .doPrivileged((PrivilegedAction) () -> { + try { + File userhome = new File(System + .getProperty("user.home"), ".gervill"); + if (!userhome.exists()) { + userhome.mkdirs(); } - return null; + File emg_soundbank_file = new File( + userhome, "soundbank-emg.sf2"); + if (emg_soundbank_file.exists()) { + return null; + } + return new FileOutputStream(emg_soundbank_file); + } catch (final FileNotFoundException ignored) { } + return null; }); if (out != null) { try { ((SF2Soundbank) defaultSoundBank).save(out); out.close(); - } catch (IOException e) { + } catch (final IOException ignored) { } } } @@ -846,26 +844,24 @@ public final class SoftSynthesizer implements AudioSynthesizer, private Properties getStoredProperties() { return AccessController - .doPrivileged(new PrivilegedAction() { - public Properties run() { - Properties p = new Properties(); - String notePath = "/com/sun/media/sound/softsynthesizer"; - try { - Preferences prefroot = Preferences.userRoot(); - if (prefroot.nodeExists(notePath)) { - Preferences prefs = prefroot.node(notePath); - String[] prefs_keys = prefs.keys(); - for (String prefs_key : prefs_keys) { - String val = prefs.get(prefs_key, null); - if (val != null) - p.setProperty(prefs_key, val); + .doPrivileged((PrivilegedAction) () -> { + Properties p = new Properties(); + String notePath = "/com/sun/media/sound/softsynthesizer"; + try { + Preferences prefroot = Preferences.userRoot(); + if (prefroot.nodeExists(notePath)) { + Preferences prefs = prefroot.node(notePath); + String[] prefs_keys = prefs.keys(); + for (String prefs_key : prefs_keys) { + String val = prefs.get(prefs_key, null); + if (val != null) { + p.setProperty(prefs_key, val); } } - } catch (BackingStoreException e) { - } catch (SecurityException e) { } - return p; + } catch (final BackingStoreException ignored) { } + return p; }); } @@ -1044,7 +1040,6 @@ public final class SoftSynthesizer implements AudioSynthesizer, return; } synchronized (control_mutex) { - Throwable causeException = null; try { if (line != null) { // can throw IllegalArgumentException @@ -1117,24 +1112,17 @@ public final class SoftSynthesizer implements AudioSynthesizer, weakstream.sourceDataLine = sourceDataLine; } - } catch (LineUnavailableException e) { - causeException = e; - } catch (IllegalArgumentException e) { - causeException = e; - } catch (SecurityException e) { - causeException = e; - } - - if (causeException != null) { - if (isOpen()) + } catch (final LineUnavailableException | SecurityException + | IllegalArgumentException e) { + if (isOpen()) { close(); + } // am: need MidiUnavailableException(Throwable) ctor! MidiUnavailableException ex = new MidiUnavailableException( "Can not open line"); - ex.initCause(causeException); + ex.initCause(e); throw ex; } - } } diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/StandardMidiFileReader.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/StandardMidiFileReader.java index 1dbd72a262a..fd960395b1f 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/StandardMidiFileReader.java +++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/StandardMidiFileReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -25,27 +25,25 @@ package com.sun.media.sound; +import java.io.BufferedInputStream; import java.io.DataInputStream; +import java.io.EOFException; import java.io.File; import java.io.FileInputStream; -import java.io.InputStream; import java.io.IOException; -import java.io.EOFException; -import java.io.BufferedInputStream; +import java.io.InputStream; import java.net.URL; -import javax.sound.midi.MidiFileFormat; import javax.sound.midi.InvalidMidiDataException; import javax.sound.midi.MetaMessage; import javax.sound.midi.MidiEvent; +import javax.sound.midi.MidiFileFormat; import javax.sound.midi.MidiMessage; import javax.sound.midi.Sequence; import javax.sound.midi.SysexMessage; import javax.sound.midi.Track; import javax.sound.midi.spi.MidiFileReader; - - /** * MIDI file reader. * @@ -53,19 +51,23 @@ import javax.sound.midi.spi.MidiFileReader; * @author Jan Borgersen * @author Florian Bomers */ - public final class StandardMidiFileReader extends MidiFileReader { private static final int MThd_MAGIC = 0x4d546864; // 'MThd' private static final int bisBufferSize = 1024; // buffer size in buffered input streams - public MidiFileFormat getMidiFileFormat(InputStream stream) throws InvalidMidiDataException, IOException { + public MidiFileFormat getMidiFileFormat(InputStream stream) + throws InvalidMidiDataException, IOException { return getMidiFileFormatFromStream(stream, MidiFileFormat.UNKNOWN_LENGTH, null); } - // $$fb 2002-04-17: part of fix for 4635286: MidiSystem.getMidiFileFormat() returns format having invalid length - private MidiFileFormat getMidiFileFormatFromStream(InputStream stream, int fileLength, SMFParser smfParser) throws InvalidMidiDataException, IOException { + // $$fb 2002-04-17: part of fix for 4635286: MidiSystem.getMidiFileFormat() + // returns format having invalid length + private MidiFileFormat getMidiFileFormatFromStream(InputStream stream, + int fileLength, + SMFParser smfParser) + throws InvalidMidiDataException, IOException{ int maxReadLength = 16; int duration = MidiFileFormat.UNKNOWN_LENGTH; DataInputStream dis; @@ -230,7 +232,7 @@ public final class StandardMidiFileReader extends MidiFileReader { //============================================================================================================= /** - * State variables during parsing of a MIDI file + * State variables during parsing of a MIDI file. */ final class SMFParser { private static final int MTrk_MAGIC = 0x4d54726b; // 'MTrk' @@ -297,7 +299,11 @@ final class SMFParser { } } // now read track in a byte array - trackData = new byte[trackLength]; + try { + trackData = new byte[trackLength]; + } catch (final OutOfMemoryError oom) { + throw new IOException("Track length too big", oom); + } try { // $$fb 2003-08-20: fix for 4910986: MIDI file parser breaks up on http connection stream.readFully(trackData); @@ -386,8 +392,13 @@ final class SMFParser { // meta int metaType = readUnsigned(); int metaLength = (int) readVarInt(); + final byte[] metaData; + try { + metaData = new byte[metaLength]; + } catch (final OutOfMemoryError oom) { + throw new IOException("Meta length too big", oom); + } - byte[] metaData = new byte[metaLength]; read(metaData); MetaMessage metaMessage = new MetaMessage(); @@ -413,5 +424,4 @@ final class SMFParser { throw new EOFException("invalid MIDI file"); } } - } diff --git a/jdk/src/java.desktop/share/classes/java/awt/datatransfer/Clipboard.java b/jdk/src/java.desktop/share/classes/java/awt/datatransfer/Clipboard.java index 210c700941e..6211692d5c9 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/datatransfer/Clipboard.java +++ b/jdk/src/java.desktop/share/classes/java/awt/datatransfer/Clipboard.java @@ -25,7 +25,7 @@ package java.awt.datatransfer; -import java.awt.EventQueue; +import sun.datatransfer.DataFlavorUtil; import java.util.Objects; import java.util.Set; @@ -130,7 +130,8 @@ public class Clipboard { this.contents = contents; if (oldOwner != null && oldOwner != owner) { - EventQueue.invokeLater(() -> oldOwner.lostOwnership(Clipboard.this, oldContents)); + DataFlavorUtil.getDesktopService().invokeOnEventThread(() -> + oldOwner.lostOwnership(Clipboard.this, oldContents)); } fireFlavorsChanged(); } @@ -324,7 +325,7 @@ public class Clipboard { return; } flavorListeners.forEach(listener -> - EventQueue.invokeLater(() -> + DataFlavorUtil.getDesktopService().invokeOnEventThread(() -> listener.flavorsChanged(new FlavorEvent(Clipboard.this)))); } diff --git a/jdk/src/java.desktop/share/classes/java/awt/datatransfer/DataFlavor.java b/jdk/src/java.desktop/share/classes/java/awt/datatransfer/DataFlavor.java index 57132f2f53e..84b18fc332a 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/datatransfer/DataFlavor.java +++ b/jdk/src/java.desktop/share/classes/java/awt/datatransfer/DataFlavor.java @@ -25,7 +25,7 @@ package java.awt.datatransfer; -import sun.awt.datatransfer.DataTransferer; +import sun.datatransfer.DataFlavorUtil; import sun.reflect.misc.ReflectUtil; import java.io.ByteArrayInputStream; @@ -44,7 +44,6 @@ import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.util.Arrays; import java.util.Collections; -import java.util.Comparator; import java.util.Objects; import static sun.security.util.SecurityConstants.GET_CLASSLOADER_PERMISSION; @@ -582,12 +581,12 @@ public class DataFlavor implements Externalizable, Cloneable { } else { params += representationClass.getName(); } - if (DataTransferer.isFlavorCharsetTextType(this) && + if (DataFlavorUtil.isFlavorCharsetTextType(this) && (isRepresentationClassInputStream() || isRepresentationClassByteBuffer() || byte[].class.equals(representationClass))) { - params += ";charset=" + DataTransferer.getTextCharset(this); + params += ";charset=" + DataFlavorUtil.getTextCharset(this); } return params; } @@ -609,13 +608,8 @@ public class DataFlavor implements Externalizable, Cloneable { * @since 1.3 */ public static final DataFlavor getTextPlainUnicodeFlavor() { - String encoding = null; - DataTransferer transferer = DataTransferer.getInstance(); - if (transferer != null) { - encoding = transferer.getDefaultUnicodeEncoding(); - } return new DataFlavor( - "text/plain;charset="+encoding + "text/plain;charset=" + DataFlavorUtil.getDesktopService().getDefaultUnicodeEncoding() +";class=java.io.InputStream", "Plain Text"); } @@ -741,12 +735,8 @@ public class DataFlavor implements Externalizable, Cloneable { return null; } - if (textFlavorComparator == null) { - textFlavorComparator = new TextFlavorComparator(); - } - DataFlavor bestFlavor = Collections.max(Arrays.asList(availableFlavors), - textFlavorComparator); + DataFlavorUtil.getTextFlavorComparator()); if (!bestFlavor.isFlavorTextType()) { return null; @@ -755,46 +745,6 @@ public class DataFlavor implements Externalizable, Cloneable { return bestFlavor; } - private static Comparator textFlavorComparator; - - static class TextFlavorComparator - extends DataTransferer.DataFlavorComparator { - - /** - * Compares two DataFlavor objects. Returns a negative - * integer, zero, or a positive integer as the first - * DataFlavor is worse than, equal to, or better than the - * second. - *

    - * DataFlavors are ordered according to the rules outlined - * for selectBestTextFlavor. - * - * @param flavor1 the first DataFlavor to be compared - * @param flavor2 the second DataFlavor to be compared - * @return a negative integer, zero, or a positive integer as the first - * argument is worse, equal to, or better than the second - * @throws ClassCastException if either of the arguments is not an - * instance of DataFlavor - * @throws NullPointerException if either of the arguments is - * null - * - * @see #selectBestTextFlavor - */ - public int compare(DataFlavor flavor1, DataFlavor flavor2) { - if (flavor1.isFlavorTextType()) { - if (flavor2.isFlavorTextType()) { - return super.compare(flavor1, flavor2); - } else { - return 1; - } - } else if (flavor2.isFlavorTextType()) { - return -1; - } else { - return 0; - } - } - } - /** * Gets a Reader for a text flavor, decoded, if necessary, for the expected * charset (encoding). The supported representation classes are @@ -1015,13 +965,13 @@ public class DataFlavor implements Externalizable, Cloneable { } if ("text".equals(getPrimaryType())) { - if (DataTransferer.doesSubtypeSupportCharset(this) + if (DataFlavorUtil.doesSubtypeSupportCharset(this) && representationClass != null && !isStandardTextRepresentationClass()) { String thisCharset = - DataTransferer.canonicalName(this.getParameter("charset")); + DataFlavorUtil.canonicalName(this.getParameter("charset")); String thatCharset = - DataTransferer.canonicalName(that.getParameter("charset")); + DataFlavorUtil.canonicalName(that.getParameter("charset")); if (!Objects.equals(thisCharset, thatCharset)) { return false; } @@ -1088,10 +1038,10 @@ public class DataFlavor implements Externalizable, Cloneable { // subTypes is '*', regardless of the other subType. if ("text".equals(primaryType)) { - if (DataTransferer.doesSubtypeSupportCharset(this) + if (DataFlavorUtil.doesSubtypeSupportCharset(this) && representationClass != null && !isStandardTextRepresentationClass()) { - String charset = DataTransferer.canonicalName(getParameter("charset")); + String charset = DataFlavorUtil.canonicalName(getParameter("charset")); if (charset != null) { total += charset.hashCode(); } @@ -1280,9 +1230,8 @@ public class DataFlavor implements Externalizable, Cloneable { * Returns true if the representation class is Remote. * @return true if the representation class is Remote */ - public boolean isRepresentationClassRemote() { - return DataTransferer.isRemote(representationClass); + return DataFlavorUtil.RMI.isRemote(representationClass); } /** @@ -1356,8 +1305,8 @@ public class DataFlavor implements Externalizable, Cloneable { * @since 1.4 */ public boolean isFlavorTextType() { - return (DataTransferer.isFlavorCharsetTextType(this) || - DataTransferer.isFlavorNoncharsetTextType(this)); + return (DataFlavorUtil.isFlavorCharsetTextType(this) || + DataFlavorUtil.isFlavorNoncharsetTextType(this)); } /** diff --git a/jdk/src/java.desktop/share/classes/java/awt/datatransfer/SystemFlavorMap.java b/jdk/src/java.desktop/share/classes/java/awt/datatransfer/SystemFlavorMap.java index e799020110a..8bd47fe5f45 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/datatransfer/SystemFlavorMap.java +++ b/jdk/src/java.desktop/share/classes/java/awt/datatransfer/SystemFlavorMap.java @@ -25,22 +25,15 @@ package java.awt.datatransfer; -import java.awt.Toolkit; - -import java.io.BufferedInputStream; -import java.io.InputStream; -import java.lang.ref.SoftReference; +import sun.datatransfer.DataFlavorUtil; +import sun.datatransfer.DesktopDatatransferService; import java.io.BufferedReader; -import java.io.File; -import java.io.InputStreamReader; import java.io.IOException; - -import java.net.URL; -import java.net.MalformedURLException; - +import java.io.InputStream; +import java.io.InputStreamReader; +import java.lang.ref.SoftReference; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -48,12 +41,8 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.Properties; import java.util.Set; -import sun.awt.AppContext; -import sun.awt.datatransfer.DataTransferer; - /** * The SystemFlavorMap is a configurable map between "natives" (Strings), which * correspond to platform-specific data formats, and "flavors" (DataFlavors), @@ -73,13 +62,6 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { private static final Object FLAVOR_MAP_KEY = new Object(); - /** - * Copied from java.util.Properties. - */ - private static final String keyValueSeparators = "=: \t\r\n\f"; - private static final String strictKeyValueSeparators = "=:"; - private static final String whiteSpaceChars = " \t\r\n\f"; - /** * The list of valid, decoded text flavor representation classes, in order * from best to worst. @@ -198,16 +180,11 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { /** * Returns the default FlavorMap for this thread's ClassLoader. + * * @return the default FlavorMap for this thread's ClassLoader */ public static FlavorMap getDefaultFlavorMap() { - AppContext context = AppContext.getAppContext(); - FlavorMap fm = (FlavorMap) context.get(FLAVOR_MAP_KEY); - if (fm == null) { - fm = new SystemFlavorMap(); - context.put(FLAVOR_MAP_KEY, fm); - } - return fm; + return DataFlavorUtil.getDesktopService().getFlavorMap(SystemFlavorMap::new); } private SystemFlavorMap() { @@ -223,7 +200,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { } isMapInitialized = true; - InputStream is = SystemFlavorMap.class.getResourceAsStream("/sun/awt/datatransfer/flavormap.properties"); + InputStream is = SystemFlavorMap.class.getResourceAsStream("/sun/datatransfer/resources/flavormap.properties"); if (is == null) { throw new InternalError("Default flavor mapping not found"); } @@ -238,22 +215,25 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { line = line.substring(0, line.length() - 1) + reader.readLine().trim(); } int delimiterPosition = line.indexOf('='); - String key = line.substring(0, delimiterPosition).replace("\\ ", " "); + String key = line.substring(0, delimiterPosition).replaceAll("\\ ", " "); String[] values = line.substring(delimiterPosition + 1, line.length()).split(","); for (String value : values) { try { + value = loadConvert(value); MimeType mime = new MimeType(value); if ("text".equals(mime.getPrimaryType())) { String charset = mime.getParameter("charset"); - if (DataTransferer.doesSubtypeSupportCharset(mime.getSubType(), charset)) + if (DataFlavorUtil.doesSubtypeSupportCharset(mime.getSubType(), charset)) { // We need to store the charset and eoln // parameters, if any, so that the // DataTransferer will have this information // for conversion into the native format. - DataTransferer transferer = DataTransferer.getInstance(); - if (transferer != null) { - transferer.registerTextFlavorProperties(key, charset, + DesktopDatatransferService desktopService = + DataFlavorUtil.getDesktopService(); + if (desktopService.isDesktopPresent()) { + desktopService.registerTextFlavorProperties( + key, charset, mime.getParameter("eoln"), mime.getParameter("terminators")); } @@ -305,6 +285,63 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { } } + // Copied from java.util.Properties + private static String loadConvert(String theString) { + char aChar; + int len = theString.length(); + StringBuilder outBuffer = new StringBuilder(len); + + for (int x = 0; x < len; ) { + aChar = theString.charAt(x++); + if (aChar == '\\') { + aChar = theString.charAt(x++); + if (aChar == 'u') { + // Read the xxxx + int value = 0; + for (int i = 0; i < 4; i++) { + aChar = theString.charAt(x++); + switch (aChar) { + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': { + value = (value << 4) + aChar - '0'; + break; + } + case 'a': case 'b': case 'c': + case 'd': case 'e': case 'f': { + value = (value << 4) + 10 + aChar - 'a'; + break; + } + case 'A': case 'B': case 'C': + case 'D': case 'E': case 'F': { + value = (value << 4) + 10 + aChar - 'A'; + break; + } + default: { + throw new IllegalArgumentException( + "Malformed \\uxxxx encoding."); + } + } + } + outBuffer.append((char)value); + } else { + if (aChar == 't') { + aChar = '\t'; + } else if (aChar == 'r') { + aChar = '\r'; + } else if (aChar == 'n') { + aChar = '\n'; + } else if (aChar == 'f') { + aChar = '\f'; + } + outBuffer.append(aChar); + } + } else { + outBuffer.append(aChar); + } + } + return outBuffer.toString(); + } + /** * Stores the listed object under the specified hash key in map. Unlike a * standard map, the listed object will not replace any object already at @@ -332,10 +369,10 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { LinkedHashSet flavors = getNativeToFlavor().get(nat); if (nat != null && !disabledMappingGenerationKeys.contains(nat)) { - DataTransferer transferer = DataTransferer.getInstance(); - if (transferer != null) { + DesktopDatatransferService desktopService = DataFlavorUtil.getDesktopService(); + if (desktopService.isDesktopPresent()) { LinkedHashSet platformFlavors = - transferer.getPlatformMappingsForNative(nat); + desktopService.getPlatformMappingsForNative(nat); if (!platformFlavors.isEmpty()) { if (flavors != null) { // Prepending the platform-specific mappings ensures @@ -395,10 +432,10 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { LinkedHashSet natives = getFlavorToNative().get(flav); if (flav != null && !disabledMappingGenerationKeys.contains(flav)) { - DataTransferer transferer = DataTransferer.getInstance(); - if (transferer != null) { + DesktopDatatransferService desktopService = DataFlavorUtil.getDesktopService(); + if (desktopService.isDesktopPresent()) { LinkedHashSet platformNatives = - transferer.getPlatformMappingsForFlavor(flav); + desktopService.getPlatformMappingsForFlavor(flav); if (!platformNatives.isEmpty()) { if (natives != null) { // Prepend the platform-specific mappings to ensure @@ -474,7 +511,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { // In this case we shouldn't synthesize a native for this flavor, // since its mappings were explicitly specified. retval = flavorToNativeLookup(flav, false); - } else if (DataTransferer.isFlavorCharsetTextType(flav)) { + } else if (DataFlavorUtil.isFlavorCharsetTextType(flav)) { retval = new LinkedHashSet<>(0); // For text/* flavors, flavor-to-native mappings specified in @@ -502,7 +539,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { // addUnencodedNativeForFlavor(), so they have lower priority. retval.addAll(flavorToNativeLookup(flav, false)); } - } else if (DataTransferer.isFlavorNoncharsetTextType(flav)) { + } else if (DataFlavorUtil.isFlavorNoncharsetTextType(flav)) { retval = getTextTypeToNative().get(flav.mimeType.getBaseType()); if (retval == null || retval.isEmpty()) { @@ -602,7 +639,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { // on load from flavormap.properties. } - if (DataTransferer.doesSubtypeSupportCharset(subType, null)) { + if (DataFlavorUtil.doesSubtypeSupportCharset(subType, null)) { if (TEXT_PLAIN_BASE_TYPE.equals(baseType)) { returnValue.add(DataFlavor.stringFlavor); @@ -624,7 +661,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { } } - for (String charset : DataTransferer.standardEncodings()) { + for (String charset : DataFlavorUtil.standardEncodings()) { for (String encodedTextClass : ENCODED_TEXT_CLASSES) { final String mimeType = diff --git a/jdk/src/java.desktop/share/classes/java/awt/font/TextLayout.java b/jdk/src/java.desktop/share/classes/java/awt/font/TextLayout.java index 45da5af89c6..f86779c161b 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/font/TextLayout.java +++ b/jdk/src/java.desktop/share/classes/java/awt/font/TextLayout.java @@ -1811,7 +1811,7 @@ public final class TextLayout implements Cloneable { * should be logical or visual counterparts. They are not * checked for validity. */ - private final TextHitInfo getStrongHit(TextHitInfo hit1, TextHitInfo hit2) { + private TextHitInfo getStrongHit(TextHitInfo hit1, TextHitInfo hit2) { // right now we're using the following rule for strong hits: // A hit on a character with a lower level diff --git a/jdk/src/java.desktop/share/classes/java/beans/PropertyChangeSupport.java b/jdk/src/java.desktop/share/classes/java/beans/PropertyChangeSupport.java index 40e58ae1e5d..532fdea1edc 100644 --- a/jdk/src/java.desktop/share/classes/java/beans/PropertyChangeSupport.java +++ b/jdk/src/java.desktop/share/classes/java/beans/PropertyChangeSupport.java @@ -544,7 +544,7 @@ public class PropertyChangeSupport implements Serializable { /** * {@inheritDoc} */ - public final PropertyChangeListener extract(PropertyChangeListener listener) { + public PropertyChangeListener extract(PropertyChangeListener listener) { while (listener instanceof PropertyChangeListenerProxy) { listener = ((PropertyChangeListenerProxy) listener).getListener(); } diff --git a/jdk/src/java.desktop/share/classes/java/beans/VetoableChangeSupport.java b/jdk/src/java.desktop/share/classes/java/beans/VetoableChangeSupport.java index 14902cc6276..6f211378991 100644 --- a/jdk/src/java.desktop/share/classes/java/beans/VetoableChangeSupport.java +++ b/jdk/src/java.desktop/share/classes/java/beans/VetoableChangeSupport.java @@ -533,7 +533,7 @@ public class VetoableChangeSupport implements Serializable { /** * {@inheritDoc} */ - public final VetoableChangeListener extract(VetoableChangeListener listener) { + public VetoableChangeListener extract(VetoableChangeListener listener) { while (listener instanceof VetoableChangeListenerProxy) { listener = ((VetoableChangeListenerProxy) listener).getListener(); } diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/ControllerEventListener.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/ControllerEventListener.java index c9666bc2df8..dba4e80c54d 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/ControllerEventListener.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/ControllerEventListener.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -27,38 +27,35 @@ package javax.sound.midi; import java.util.EventListener; - /** - * The ControllerEventListener interface should be implemented - * by classes whose instances need to be notified when a Sequencer - * has processed a requested type of MIDI control-change event. - * To register a ControllerEventListener object to receive such - * notifications, invoke the + * The {@code ControllerEventListener} interface should be implemented by + * classes whose instances need to be notified when a {@link Sequencer} has + * processed a requested type of MIDI control-change event. To register a + * {@code ControllerEventListener} object to receive such notifications, invoke + * the * {@link Sequencer#addControllerEventListener(ControllerEventListener, int[]) - * addControllerEventListener} method of Sequencer, - * specifying the types of MIDI controllers about which you are interested in - * getting control-change notifications. - * - * @see MidiChannel#controlChange(int, int) + * addControllerEventListener} method of {@code Sequencer}, specifying the types + * of MIDI controllers about which you are interested in getting control-change + * notifications. * * @author Kara Kytle + * @see MidiChannel#controlChange(int, int) */ public interface ControllerEventListener extends EventListener { /** - * Invoked when a Sequencer has encountered and processed - * a control-change event of interest to this listener. The event passed - * in is a ShortMessage whose first data byte indicates - * the controller number and whose second data byte is the value to which - * the controller was set. - * - * @param event the control-change event that the sequencer encountered in - * the sequence it is processing + * Invoked when a {@link Sequencer} has encountered and processed a + * control-change event of interest to this listener. The event passed in is + * a {@code ShortMessage} whose first data byte indicates the controller + * number and whose second data byte is the value to which the controller + * was set. * + * @param event the control-change event that the sequencer encountered in + * the sequence it is processing * @see Sequencer#addControllerEventListener(ControllerEventListener, int[]) * @see MidiChannel#controlChange(int, int) * @see ShortMessage#getData1 * @see ShortMessage#getData2 */ - public void controlChange(ShortMessage event); + void controlChange(ShortMessage event); } diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/Instrument.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/Instrument.java index 3255aeff033..8bda9676df2 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/Instrument.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/Instrument.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -25,49 +25,41 @@ package javax.sound.midi; -import java.net.URL; - - - /** - * An instrument is a sound-synthesis algorithm with certain parameter - * settings, usually designed to emulate a specific real-world - * musical instrument or to achieve a specific sort of sound effect. - * Instruments are typically stored in collections called soundbanks. - * Before the instrument can be used to play notes, it must first be loaded - * onto a synthesizer, and then it must be selected for use on - * one or more channels, via a program-change command. MIDI notes - * that are subsequently received on those channels will be played using + * An instrument is a sound-synthesis algorithm with certain parameter settings, + * usually designed to emulate a specific real-world musical instrument or to + * achieve a specific sort of sound effect. Instruments are typically stored in + * collections called soundbanks. Before the instrument can be used to play + * notes, it must first be loaded onto a synthesizer, and then it must be + * selected for use on one or more channels, via a program-change command. MIDI + * notes that are subsequently received on those channels will be played using * the sound of the selected instrument. * + * @author Kara Kytle * @see Soundbank * @see Soundbank#getInstruments * @see Patch * @see Synthesizer#loadInstrument(Instrument) * @see MidiChannel#programChange(int, int) - * @author Kara Kytle */ - public abstract class Instrument extends SoundbankResource { - /** - * Instrument patch + * Instrument patch. */ private final Patch patch; - /** - * Constructs a new MIDI instrument from the specified Patch. - * When a subsequent request is made to load the - * instrument, the sound bank will search its contents for this instrument's Patch, - * and the instrument will be loaded into the synthesizer at the - * bank and program location indicated by the Patch object. - * @param soundbank sound bank containing the instrument - * @param patch the patch of this instrument - * @param name the name of this instrument - * @param dataClass the class used to represent the sample's data. + * Constructs a new MIDI instrument from the specified {@code Patch}. When a + * subsequent request is made to load the instrument, the sound bank will + * search its contents for this instrument's {@code Patch}, and the + * instrument will be loaded into the synthesizer at the bank and program + * location indicated by the {@code Patch} object. * + * @param soundbank sound bank containing the instrument + * @param patch the patch of this instrument + * @param name the name of this instrument + * @param dataClass the class used to represent the sample's data * @see Synthesizer#loadInstrument(Instrument) */ protected Instrument(Soundbank soundbank, Patch patch, String name, Class dataClass) { @@ -76,10 +68,10 @@ public abstract class Instrument extends SoundbankResource { this.patch = patch; } - /** - * Obtains the Patch object that indicates the bank and program + * Obtains the {@code Patch} object that indicates the bank and program * numbers where this instrument is to be stored in the synthesizer. + * * @return this instrument's patch */ public Patch getPatch() { diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/InvalidMidiDataException.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/InvalidMidiDataException.java index ed20121fab8..28a75deefc4 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/InvalidMidiDataException.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/InvalidMidiDataException.java @@ -25,25 +25,25 @@ package javax.sound.midi; - /** - * An InvalidMidiDataException indicates that inappropriate MIDI - * data was encountered. This often means that the data is invalid in and of - * itself, from the perspective of the MIDI specification. An example would - * be an undefined status byte. However, the exception might simply - * mean that the data was invalid in the context it was used, or that - * the object to which the data was given was unable to parse or use it. - * For example, a file reader might not be able to parse a Type 2 MIDI file, even - * though that format is defined in the MIDI specification. + * An {@code InvalidMidiDataException} indicates that inappropriate MIDI data + * was encountered. This often means that the data is invalid in and of itself, + * from the perspective of the MIDI specification. An example would be an + * undefined status byte. However, the exception might simply mean that the data + * was invalid in the context it was used, or that the object to which the data + * was given was unable to parse or use it. For example, a file reader might not + * be able to parse a Type 2 MIDI file, even though that format is defined in + * the MIDI specification. * * @author Kara Kytle */ public class InvalidMidiDataException extends Exception { + private static final long serialVersionUID = 2780771756789932067L; /** - * Constructs an InvalidMidiDataException with - * null for its error detail message. + * Constructs an {@code InvalidMidiDataException} with {@code null} for its + * error detail message. */ public InvalidMidiDataException() { @@ -51,10 +51,10 @@ public class InvalidMidiDataException extends Exception { } /** - * Constructs an InvalidMidiDataException with the - * specified detail message. + * Constructs an {@code InvalidMidiDataException} with the specified detail + * message. * - * @param message the string to display as an error detail message + * @param message the string to display as an error detail message */ public InvalidMidiDataException(String message) { diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/MetaEventListener.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/MetaEventListener.java index 94fe3d8044f..6f431bf22c9 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/MetaEventListener.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/MetaEventListener.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -27,24 +27,23 @@ package javax.sound.midi; import java.util.EventListener; - /** - * The MetaEventListener interface should be implemented - * by classes whose instances need to be notified when a {@link Sequencer} - * has processed a {@link MetaMessage}. - * To register a MetaEventListener object to receive such - * notifications, pass it as the argument to the - * {@link Sequencer#addMetaEventListener(MetaEventListener) addMetaEventListener} - * method of Sequencer. + * The {@code MetaEventListener} interface should be implemented by classes + * whose instances need to be notified when a {@link Sequencer} has processed a + * {@link MetaMessage}. To register a {@code MetaEventListener} object to + * receive such notifications, pass it as the argument to the + * {@link Sequencer#addMetaEventListener(MetaEventListener) + * addMetaEventListener} method of {@code Sequencer}. * * @author Kara Kytle */ public interface MetaEventListener extends EventListener { /** - * Invoked when a {@link Sequencer} has encountered and processed - * a MetaMessage in the {@link Sequence} it is processing. - * @param meta the meta-message that the sequencer encountered + * Invoked when a {@link Sequencer} has encountered and processed a + * {@code MetaMessage} in the {@code Sequence} it is processing. + * + * @param meta the meta-message that the sequencer encountered */ - public void meta(MetaMessage meta); + void meta(MetaMessage meta); } diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/MetaMessage.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/MetaMessage.java index 6378435acc7..2e73cc37ddf 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/MetaMessage.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/MetaMessage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -25,65 +25,54 @@ package javax.sound.midi; - /** - * A MetaMessage is a {@link MidiMessage} that is not meaningful to synthesizers, but - * that can be stored in a MIDI file and interpreted by a sequencer program. - * (See the discussion in the MidiMessage - * class description.) The Standard MIDI Files specification defines - * various types of meta-events, such as sequence number, lyric, cue point, - * and set tempo. There are also meta-events - * for such information as lyrics, copyrights, tempo indications, time and key - * signatures, markers, etc. For more information, see the Standard MIDI Files 1.0 - * specification, which is part of the Complete MIDI 1.0 Detailed Specification - * published by the MIDI Manufacturer's Association + * A {@code MetaMessage} is a {@link MidiMessage} that is not meaningful to + * synthesizers, but that can be stored in a MIDI file and interpreted by a + * sequencer program. (See the discussion in the {@code MidiMessage} class + * description.) The Standard MIDI Files specification defines various types of + * meta-events, such as sequence number, lyric, cue point, and set tempo. There + * are also meta-events for such information as lyrics, copyrights, tempo + * indications, time and key signatures, markers, etc. For more information, see + * the Standard MIDI Files 1.0 specification, which is part of the Complete MIDI + * 1.0 Detailed Specification published by the MIDI Manufacturer's Association * (http://www.midi.org). - * *

    - * When data is being transported using MIDI wire protocol, - * a {@link ShortMessage} with the status value 0xFF represents - * a system reset message. In MIDI files, this same status value denotes a MetaMessage. - * The types of meta-message are distinguished from each other by the first byte - * that follows the status byte 0xFF. The subsequent bytes are data - * bytes. As with system exclusive messages, there are an arbitrary number of - * data bytes, depending on the type of MetaMessage. - * - * @see MetaEventListener + * When data is being transported using MIDI wire protocol, a + * {@link ShortMessage} with the status value {@code 0xFF} represents a system + * reset message. In MIDI files, this same status value denotes a + * {@code MetaMessage}. The types of meta-message are distinguished from each + * other by the first byte that follows the status byte {@code 0xFF}. The + * subsequent bytes are data bytes. As with system exclusive messages, there are + * an arbitrary number of data bytes, depending on the type of + * {@code MetaMessage}. * * @author David Rivas * @author Kara Kytle + * @see MetaEventListener */ - public class MetaMessage extends MidiMessage { - - // Status byte defines - /** - * Status byte for MetaMessage (0xFF, or 255), which is used - * in MIDI files. It has the same value as SYSTEM_RESET, which - * is used in the real-time "MIDI wire" protocol. + * Status byte for {@code MetaMessage} (0xFF, or 255), which is used in MIDI + * files. It has the same value as SYSTEM_RESET, which is used in the + * real-time "MIDI wire" protocol. + * * @see MidiMessage#getStatus */ public static final int META = 0xFF; // 255 - // Instance variables - /** - * The length of the actual message in the data array. - * This is used to determine how many bytes of the data array - * is the message, and how many are the status byte, the - * type byte, and the variable-length-int describing the - * length of the message. + * The length of the actual message in the data array. This is used to + * determine how many bytes of the data array is the message, and how many + * are the status byte, the type byte, and the variable-length-int + * describing the length of the message. */ private int dataLength = 0; - /** - * Constructs a new MetaMessage. The contents of - * the message are not set here; use - * {@link #setMessage(int, byte[], int) setMessage} - * to set them subsequently. + * Constructs a new {@code MetaMessage}. The contents of the message are not + * set here; use {@link #setMessage(int, byte[], int) setMessage} to set + * them subsequently. */ public MetaMessage() { // Default meta message data: just the META status byte value @@ -91,17 +80,17 @@ public class MetaMessage extends MidiMessage { } /** - * Constructs a new {@code MetaMessage} and sets the message parameters. - * The contents of the message can be changed by using - * the {@code setMessage} method. + * Constructs a new {@code MetaMessage} and sets the message parameters. The + * contents of the message can be changed by using the {@code setMessage} + * method. * - * @param type meta-message type (must be less than 128) - * @param data the data bytes in the MIDI message - * @param length an amount of bytes in the {@code data} byte array; - * it should be non-negative and less than or equal to - * {@code data.length} - * @throws InvalidMidiDataException if the parameter values do not specify - * a valid MIDI meta message + * @param type meta-message type (must be less than 128) + * @param data the data bytes in the MIDI message + * @param length an amount of bytes in the {@code data} byte array; it + * should be non-negative and less than or equal to + * {@code data.length} + * @throws InvalidMidiDataException if the parameter values do not specify a + * valid MIDI meta message * @see #setMessage(int, byte[], int) * @see #getType() * @see #getData() @@ -113,12 +102,11 @@ public class MetaMessage extends MidiMessage { setMessage(type, data, length); // can throw InvalidMidiDataException } - /** - * Constructs a new MetaMessage. - * @param data an array of bytes containing the complete message. - * The message data may be changed using the setMessage - * method. + * Constructs a new {@code MetaMessage}. + * + * @param data an array of bytes containing the complete message. The + * message data may be changed using the {@code setMessage} method. * @see #setMessage */ protected MetaMessage(byte[] data) { @@ -133,24 +121,24 @@ public class MetaMessage extends MidiMessage { } } - /** - * Sets the message parameters for a MetaMessage. - * Since only one status byte value, 0xFF, is allowed for meta-messages, - * it does not need to be specified here. Calls to {@link MidiMessage#getStatus getStatus} return - * 0xFF for all meta-messages. + * Sets the message parameters for a {@code MetaMessage}. Since only one + * status byte value, {@code 0xFF}, is allowed for meta-messages, it does + * not need to be specified here. Calls to + * {@link MidiMessage#getStatus getStatus} return {@code 0xFF} for all + * meta-messages. *

    - * The type argument should be a valid value for the byte that - * follows the status byte in the MetaMessage. The data argument - * should contain all the subsequent bytes of the MetaMessage. In other words, - * the byte that specifies the type of MetaMessage is not considered a data byte. + * The {@code type} argument should be a valid value for the byte that + * follows the status byte in the {@code MetaMessage}. The {@code data} + * argument should contain all the subsequent bytes of the + * {@code MetaMessage}. In other words, the byte that specifies the type of + * {@code MetaMessage} is not considered a data byte. * - * @param type meta-message type (must be less than 128) - * @param data the data bytes in the MIDI message - * @param length the number of bytes in the data - * byte array - * @throws InvalidMidiDataException if the - * parameter values do not specify a valid MIDI meta message + * @param type meta-message type (must be less than 128) + * @param data the data bytes in the MIDI message + * @param length the number of bytes in the {@code data} byte array + * @throws InvalidMidiDataException if the parameter values do not specify a + * valid MIDI meta message */ public void setMessage(int type, byte[] data, int length) throws InvalidMidiDataException { @@ -172,10 +160,10 @@ public class MetaMessage extends MidiMessage { } } - /** - * Obtains the type of the MetaMessage. - * @return an integer representing the MetaMessage type + * Obtains the type of the {@code MetaMessage}. + * + * @return an integer representing the {@code MetaMessage} type */ public int getType() { if (length>=2) { @@ -184,16 +172,15 @@ public class MetaMessage extends MidiMessage { return 0; } - - /** - * Obtains a copy of the data for the meta message. The returned - * array of bytes does not include the status byte or the message - * length data. The length of the data for the meta message is - * the length of the array. Note that the length of the entire - * message includes the status byte and the meta message type - * byte, and therefore may be longer than the returned array. - * @return array containing the meta message data. + * Obtains a copy of the data for the meta message. The returned array of + * bytes does not include the status byte or the message length data. The + * length of the data for the meta message is the length of the array. Note + * that the length of the entire message includes the status byte and the + * meta message type byte, and therefore may be longer than the returned + * array. + * + * @return array containing the meta message data * @see MidiMessage#getLength */ public byte[] getData() { @@ -202,10 +189,10 @@ public class MetaMessage extends MidiMessage { return returnedArray; } - /** - * Creates a new object of the same class and with the same contents - * as this object. + * Creates a new object of the same class and with the same contents as this + * object. + * * @return a clone of this instance */ public Object clone() { @@ -240,5 +227,4 @@ public class MetaMessage extends MidiMessage { } data[off] = (byte) (value & mask); } - } diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiChannel.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiChannel.java index e2f37676304..6db7055ec83 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiChannel.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiChannel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -25,513 +25,450 @@ package javax.sound.midi; - /** - * A MidiChannel object represents a single MIDI channel. - * Generally, each MidiChannel method processes a like-named MIDI - * "channel voice" or "channel mode" message as defined by the MIDI specification. However, - * MidiChannel adds some "get" methods that retrieve the value - * most recently set by one of the standard MIDI channel messages. Similarly, - * methods for per-channel solo and mute have been added. + * A {@code MidiChannel} object represents a single MIDI channel. Generally, + * each {@code MidiChannel} method processes a like-named MIDI "channel voice" + * or "channel mode" message as defined by the MIDI specification. However, + * {@code MidiChannel} adds some "get" methods that retrieve the value most + * recently set by one of the standard MIDI channel messages. Similarly, methods + * for per-channel solo and mute have been added. *

    - * A {@link Synthesizer} object has a collection - * of MidiChannels, usually one for each of the 16 channels - * prescribed by the MIDI 1.0 specification. The Synthesizer - * generates sound when its MidiChannels receive - * noteOn messages. + * A {@link Synthesizer} object has a collection of {@code MidiChannels}, + * usually one for each of the 16 channels prescribed by the MIDI 1.0 + * specification. The {@code Synthesizer} generates sound when its + * {@code MidiChannels} receive {@code noteOn} messages. *

    * See the MIDI 1.0 Specification for more information about the prescribed - * behavior of the MIDI channel messages, which are not exhaustively - * documented here. The specification is titled MIDI Reference: - * The Complete MIDI 1.0 Detailed Specification, and is published by - * the MIDI Manufacturer's Association ( - * http://www.midi.org). + * behavior of the MIDI channel messages, which are not exhaustively documented + * here. The specification is titled + * {@code MIDI Reference: The Complete MIDI 1.0 Detailed Specification}, and is + * published by the MIDI Manufacturer's Association + * (http://www.midi.org). *

    * MIDI was originally a protocol for reporting the gestures of a keyboard - * musician. This genesis is visible in the MidiChannel API, which + * musician. This genesis is visible in the {@code MidiChannel} API, which * preserves such MIDI concepts as key number, key velocity, and key pressure. * It should be understood that the MIDI data does not necessarily originate * with a keyboard player (the source could be a different kind of musician, or - * software). Some devices might generate constant values for velocity - * and pressure, regardless of how the note was performed. - * Also, the MIDI specification often leaves it up to the - * synthesizer to use the data in the way the implementor sees fit. For - * example, velocity data need not always be mapped to volume and/or brightness. - * - * @see Synthesizer#getChannels + * software). Some devices might generate constant values for velocity and + * pressure, regardless of how the note was performed. Also, the MIDI + * specification often leaves it up to the synthesizer to use the data in the + * way the implementor sees fit. For example, velocity data need not always be + * mapped to volume and/or brightness. * * @author David Rivas * @author Kara Kytle + * @see Synthesizer#getChannels */ - public interface MidiChannel { /** - * Starts the specified note sounding. The key-down velocity - * usually controls the note's volume and/or brightness. - * If velocity is zero, this method instead acts like - * {@link #noteOff(int)}, terminating the note. - * - * @param noteNumber the MIDI note number, from 0 to 127 (60 = Middle C) - * @param velocity the speed with which the key was depressed + * Starts the specified note sounding. The key-down velocity usually + * controls the note's volume and/or brightness. If {@code velocity} is + * zero, this method instead acts like {@link #noteOff(int)}, terminating + * the note. * + * @param noteNumber the MIDI note number, from 0 to 127 (60 = Middle C) + * @param velocity the speed with which the key was depressed * @see #noteOff(int, int) */ - public void noteOn(int noteNumber, int velocity); + void noteOn(int noteNumber, int velocity); /** - * Turns the specified note off. The key-up velocity, if not ignored, can - * be used to affect how quickly the note decays. - * In any case, the note might not die away instantaneously; its decay - * rate is determined by the internals of the Instrument. - * If the Hold Pedal (a controller; see - * {@link #controlChange(int, int) controlChange}) - * is down, the effect of this method is deferred until the pedal is - * released. - * - * - * @param noteNumber the MIDI note number, from 0 to 127 (60 = Middle C) - * @param velocity the speed with which the key was released + * Turns the specified note off. The key-up velocity, if not ignored, can be + * used to affect how quickly the note decays. In any case, the note might + * not die away instantaneously; its decay rate is determined by the + * internals of the {@code Instrument}. If the Hold Pedal (a controller; see + * {@link #controlChange(int, int) controlChange}) is down, the effect of + * this method is deferred until the pedal is released. * + * @param noteNumber the MIDI note number, from 0 to 127 (60 = Middle C) + * @param velocity the speed with which the key was released * @see #noteOff(int) * @see #noteOn * @see #allNotesOff * @see #allSoundOff */ - public void noteOff(int noteNumber, int velocity); + void noteOff(int noteNumber, int velocity); /** * Turns the specified note off. * - * @param noteNumber the MIDI note number, from 0 to 127 (60 = Middle C) - * + * @param noteNumber the MIDI note number, from 0 to 127 (60 = Middle C) * @see #noteOff(int, int) */ - public void noteOff(int noteNumber); + void noteOff(int noteNumber); /** - * Reacts to a change in the specified note's key pressure. - * Polyphonic key pressure - * allows a keyboard player to press multiple keys simultaneously, each - * with a different amount of pressure. The pressure, if not ignored, - * is typically used to vary such features as the volume, brightness, - * or vibrato of the note. - * - * It is possible that the underlying synthesizer - * does not support this MIDI message. In order - * to verify that setPolyPressure - * was successful, use getPolyPressure. - * - * @param noteNumber the MIDI note number, from 0 to 127 (60 = Middle C) - * @param pressure value for the specified key, from 0 to 127 (127 = - * maximum pressure) + * Reacts to a change in the specified note's key pressure. Polyphonic key + * pressure allows a keyboard player to press multiple keys simultaneously, + * each with a different amount of pressure. The pressure, if not ignored, + * is typically used to vary such features as the volume, brightness, or + * vibrato of the note. + *

    + * It is possible that the underlying synthesizer does not support this MIDI + * message. In order to verify that {@code setPolyPressure} was successful, + * use {@code getPolyPressure}. * + * @param noteNumber the MIDI note number, from 0 to 127 (60 = Middle C) + * @param pressure value for the specified key, from 0 to 127 + * (127 = maximum pressure) * @see #getPolyPressure(int) */ - public void setPolyPressure(int noteNumber, int pressure); + void setPolyPressure(int noteNumber, int pressure); /** * Obtains the pressure with which the specified key is being depressed. + *

    + * If the device does not support setting poly pressure, this method always + * returns 0. Calling {@code setPolyPressure} will have no effect then. * - * @param noteNumber the MIDI note number, from 0 to 127 (60 = Middle C) - * - * If the device does not support setting poly pressure, - * this method always returns 0. Calling - * setPolyPressure will have no effect then. - * + * @param noteNumber the MIDI note number, from 0 to 127 (60 = Middle C) * @return the amount of pressure for that note, from 0 to 127 - * (127 = maximum pressure) - * + * (127 = maximum pressure) * @see #setPolyPressure(int, int) */ - public int getPolyPressure(int noteNumber); + int getPolyPressure(int noteNumber); /** - * Reacts to a change in the keyboard pressure. Channel - * pressure indicates how hard the keyboard player is depressing - * the entire keyboard. This can be the maximum or - * average of the per-key pressure-sensor values, as set by - * setPolyPressure. More commonly, it is a measurement of - * a single sensor on a device that doesn't implement polyphonic key - * pressure. Pressure can be used to control various aspects of the sound, - * as described under {@link #setPolyPressure(int, int) setPolyPressure}. + * Reacts to a change in the keyboard pressure. Channel pressure indicates + * how hard the keyboard player is depressing the entire keyboard. This can + * be the maximum or average of the per-key pressure-sensor values, as set + * by {@code setPolyPressure}. More commonly, it is a measurement of a + * single sensor on a device that doesn't implement polyphonic key pressure. + * Pressure can be used to control various aspects of the sound, as + * described under {@link #setPolyPressure(int, int) setPolyPressure}. + *

    + * It is possible that the underlying synthesizer does not support this MIDI + * message. In order to verify that {@code setChannelPressure} was + * successful, use {@code getChannelPressure}. * - * It is possible that the underlying synthesizer - * does not support this MIDI message. In order - * to verify that setChannelPressure - * was successful, use getChannelPressure. - * - * @param pressure the pressure with which the keyboard is being depressed, - * from 0 to 127 (127 = maximum pressure) + * @param pressure the pressure with which the keyboard is being depressed, + * from 0 to 127 (127 = maximum pressure) * @see #setPolyPressure(int, int) * @see #getChannelPressure */ - public void setChannelPressure(int pressure); + void setChannelPressure(int pressure); /** * Obtains the channel's keyboard pressure. - * If the device does not support setting channel pressure, - * this method always returns 0. Calling - * setChannelPressure will have no effect then. - * - * @return the amount of pressure for that note, - * from 0 to 127 (127 = maximum pressure) + *

    + * If the device does not support setting channel pressure, this method + * always returns 0. Calling {@code setChannelPressure} will have no effect + * then. * + * @return the amount of pressure for that note, from 0 to 127 + * (127 = maximum pressure) * @see #setChannelPressure(int) */ - public int getChannelPressure(); + int getChannelPressure(); /** - * Reacts to a change in the specified controller's value. A controller - * is some control other than a keyboard key, such as a - * switch, slider, pedal, wheel, or breath-pressure sensor. - * The MIDI 1.0 Specification provides standard numbers for typical - * controllers on MIDI devices, and describes the intended effect - * for some of the controllers. - * The way in which an - * Instrument reacts to a controller change may be - * specific to the Instrument. + * Reacts to a change in the specified controller's value. A controller is + * some control other than a keyboard key, such as a switch, slider, pedal, + * wheel, or breath-pressure sensor. The MIDI 1.0 Specification provides + * standard numbers for typical controllers on MIDI devices, and describes + * the intended effect for some of the controllers. The way in which an + * {@code Instrument} reacts to a controller change may be specific to the + * {@code Instrument}. *

    - * The MIDI 1.0 Specification defines both 7-bit controllers - * and 14-bit controllers. Continuous controllers, such - * as wheels and sliders, typically have 14 bits (two MIDI bytes), - * while discrete controllers, such as switches, typically have 7 bits - * (one MIDI byte). Refer to the specification to see the - * expected resolution for each type of control. + * The MIDI 1.0 Specification defines both 7-bit controllers and 14-bit + * controllers. Continuous controllers, such as wheels and sliders, + * typically have 14 bits (two MIDI bytes), while discrete controllers, such + * as switches, typically have 7 bits (one MIDI byte). Refer to the + * specification to see the expected resolution for each type of control. *

    - * Controllers 64 through 95 (0x40 - 0x5F) allow 7-bit precision. - * The value of a 7-bit controller is set completely by the - * value argument. An additional set of controllers - * provide 14-bit precision by using two controller numbers, one - * for the most significant 7 bits and another for the least significant - * 7 bits. Controller numbers 0 through 31 (0x00 - 0x1F) control the - * most significant 7 bits of 14-bit controllers; controller numbers - * 32 through 63 (0x20 - 0x3F) control the least significant 7 bits of - * these controllers. For example, controller number 7 (0x07) controls - * the upper 7 bits of the channel volume controller, and controller - * number 39 (0x27) controls the lower 7 bits. - * The value of a 14-bit controller is determined - * by the interaction of the two halves. When the most significant 7 bits - * of a controller are set (using controller numbers 0 through 31), the - * lower 7 bits are automatically set to 0. The corresponding controller - * number for the lower 7 bits may then be used to further modulate the - * controller value. - * - * It is possible that the underlying synthesizer - * does not support a specific controller message. In order - * to verify that a call to controlChange - * was successful, use getController. - * - * @param controller the controller number (0 to 127; see the MIDI - * 1.0 Specification for the interpretation) - * @param value the value to which the specified controller is changed (0 to 127) + * Controllers 64 through 95 (0x40 - 0x5F) allow 7-bit precision. The value + * of a 7-bit controller is set completely by the {@code value} argument. An + * additional set of controllers provide 14-bit precision by using two + * controller numbers, one for the most significant 7 bits and another for + * the least significant 7 bits. Controller numbers 0 through 31 + * (0x00 - 0x1F) control the most significant 7 bits of 14-bit controllers; + * controller numbers 32 through 63 (0x20 - 0x3F) control the least + * significant 7 bits of these controllers. For example, controller number 7 + * (0x07) controls the upper 7 bits of the channel volume controller, and + * controller number 39 (0x27) controls the lower 7 bits. The value of a + * 14-bit controller is determined by the interaction of the two halves. + * When the most significant 7 bits of a controller are set (using + * controller numbers 0 through 31), the lower 7 bits are automatically set + * to 0. The corresponding controller number for the lower 7 bits may then + * be used to further modulate the controller value. + *

    + * It is possible that the underlying synthesizer does not support a + * specific controller message. In order to verify that a call to + * {@code controlChange} was successful, use {@code getController}. * + * @param controller the controller number (0 to 127; see the MIDI 1.0 + * Specification for the interpretation) + * @param value the value to which the specified controller is changed + * (0 to 127) * @see #getController(int) */ - public void controlChange(int controller, int value); + void controlChange(int controller, int value); /** - * Obtains the current value of the specified controller. The return - * value is represented with 7 bits. For 14-bit controllers, the MSB and - * LSB controller value needs to be obtained separately. For example, - * the 14-bit value of the volume controller can be calculated by - * multiplying the value of controller 7 (0x07, channel volume MSB) - * with 128 and adding the - * value of controller 39 (0x27, channel volume LSB). - * - * If the device does not support setting a specific controller, - * this method returns 0 for that controller. - * Calling controlChange will have no effect then. - * - * @param controller the number of the controller whose value is desired. - * The allowed range is 0-127; see the MIDI - * 1.0 Specification for the interpretation. + * Obtains the current value of the specified controller. The return value + * is represented with 7 bits. For 14-bit controllers, the MSB and LSB + * controller value needs to be obtained separately. For example, the 14-bit + * value of the volume controller can be calculated by multiplying the value + * of controller 7 (0x07, channel volume MSB) with 128 and adding the value + * of controller 39 (0x27, channel volume LSB). + *

    + * If the device does not support setting a specific controller, this method + * returns 0 for that controller. Calling {@code controlChange} will have no + * effect then. * + * @param controller the number of the controller whose value is desired. + * The allowed range is 0-127; see the MIDI 1.0 Specification for + * the interpretation. * @return the current value of the specified controller (0 to 127) - * * @see #controlChange(int, int) */ - public int getController(int controller); + int getController(int controller); /** - * Changes a program (patch). This selects a specific - * instrument from the currently selected bank of instruments. + * Changes a program (patch). This selects a specific instrument from the + * currently selected bank of instruments. *

    - * The MIDI specification does not - * dictate whether notes that are already sounding should switch - * to the new instrument (timbre) or continue with their original timbre - * until terminated by a note-off. + * The MIDI specification does not dictate whether notes that are already + * sounding should switch to the new instrument (timbre) or continue with + * their original timbre until terminated by a note-off. *

    - * The program number is zero-based (expressed from 0 to 127). - * Note that MIDI hardware displays and literature about MIDI - * typically use the range 1 to 128 instead. - * - * It is possible that the underlying synthesizer - * does not support a specific program. In order - * to verify that a call to programChange - * was successful, use getProgram. - * - * @param program the program number to switch to (0 to 127) + * The program number is zero-based (expressed from 0 to 127). Note that + * MIDI hardware displays and literature about MIDI typically use the range + * 1 to 128 instead. + *

    + * It is possible that the underlying synthesizer does not support a + * specific program. In order to verify that a call to {@code programChange} + * was successful, use {@code getProgram}. * + * @param program the program number to switch to (0 to 127) * @see #programChange(int, int) * @see #getProgram() */ - public void programChange(int program); + void programChange(int program); /** * Changes the program using bank and program (patch) numbers. - * - * It is possible that the underlying synthesizer - * does not support a specific bank, or program. In order - * to verify that a call to programChange - * was successful, use getProgram and - * getController. - * Since banks are changed by way of control changes, - * you can verify the current bank with the following - * statement: + *

    + * It is possible that the underlying synthesizer does not support a + * specific bank, or program. In order to verify that a call to + * {@code programChange} was successful, use {@code getProgram} and + * {@code getController}. Since banks are changed by way of control changes, + * you can verify the current bank with the following statement: *

    -     *   int bank = (getController(0) * 128)
    -     *              + getController(32);
    +     *   int bank = (getController(0) * 128) + getController(32);
          * 
    * - * @param bank the bank number to switch to (0 to 16383) - * @param program the program (patch) to use in the specified bank (0 to 127) + * @param bank the bank number to switch to (0 to 16383) + * @param program the program (patch) to use in the specified bank + * (0 to 127) * @see #programChange(int) * @see #getProgram() */ - public void programChange(int bank, int program); + void programChange(int bank, int program); /** * Obtains the current program number for this channel. + * * @return the program number of the currently selected patch * @see Patch#getProgram * @see Synthesizer#loadInstrument * @see #programChange(int) */ - public int getProgram(); + int getProgram(); /** - * Changes the pitch offset for all notes on this channel. - * This affects all currently sounding notes as well as subsequent ones. - * (For pitch bend to cease, the value needs to be reset to the - * center position.) - *

    The MIDI specification - * stipulates that pitch bend be a 14-bit value, where zero - * is maximum downward bend, 16383 is maximum upward bend, and - * 8192 is the center (no pitch bend). The actual - * amount of pitch change is not specified; it can be changed by - * a pitch-bend sensitivity setting. However, the General MIDI - * specification says that the default range should be two semitones - * up and down from center. - * - * It is possible that the underlying synthesizer - * does not support this MIDI message. In order - * to verify that setPitchBend - * was successful, use getPitchBend. - * - * @param bend the amount of pitch change, as a nonnegative 14-bit value - * (8192 = no bend) + * Changes the pitch offset for all notes on this channel. This affects all + * currently sounding notes as well as subsequent ones. (For pitch bend to + * cease, the value needs to be reset to the center position.) + *

    + * The MIDI specification stipulates that pitch bend be a 14-bit value, + * where zero is maximum downward bend, 16383 is maximum upward bend, and + * 8192 is the center (no pitch bend). The actual amount of pitch change is + * not specified; it can be changed by a pitch-bend sensitivity setting. + * However, the General MIDI specification says that the default range + * should be two semitones up and down from center. + *

    + * It is possible that the underlying synthesizer does not support this MIDI + * message. In order to verify that {@code setPitchBend} was successful, use + * {@code getPitchBend}. * + * @param bend the amount of pitch change, as a nonnegative 14-bit value + * (8192 = no bend) * @see #getPitchBend */ - public void setPitchBend(int bend); + void setPitchBend(int bend); /** - * Obtains the upward or downward pitch offset for this channel. - * If the device does not support setting pitch bend, - * this method always returns 8192. Calling - * setPitchBend will have no effect then. + * Obtains the upward or downward pitch offset for this channel. If the + * device does not support setting pitch bend, this method always returns + * 8192. Calling {@code setPitchBend} will have no effect then. * * @return bend amount, as a nonnegative 14-bit value (8192 = no bend) - * * @see #setPitchBend(int) */ - public int getPitchBend(); + int getPitchBend(); /** * Resets all the implemented controllers to their default values. * * @see #controlChange(int, int) */ - public void resetAllControllers(); + void resetAllControllers(); /** - * Turns off all notes that are currently sounding on this channel. - * The notes might not die away instantaneously; their decay - * rate is determined by the internals of the Instrument. - * If the Hold Pedal controller (see - * {@link #controlChange(int, int) controlChange}) - * is down, the effect of this method is deferred until the pedal is - * released. + * Turns off all notes that are currently sounding on this channel. The + * notes might not die away instantaneously; their decay rate is determined + * by the internals of the {@code Instrument}. If the Hold Pedal controller + * (see {@link #controlChange(int, int) controlChange}) is down, the effect + * of this method is deferred until the pedal is released. * * @see #allSoundOff * @see #noteOff(int) */ - public void allNotesOff(); + void allNotesOff(); /** * Immediately turns off all sounding notes on this channel, ignoring the * state of the Hold Pedal and the internal decay rate of the current - * Instrument. + * {@code Instrument}. * * @see #allNotesOff */ - public void allSoundOff(); + void allSoundOff(); /** - * Turns local control on or off. The default is for local control - * to be on. The "on" setting means that if a device is capable - * of both synthesizing sound and transmitting MIDI messages, - * it will synthesize sound in response to the note-on and - * note-off messages that it itself transmits. It will also respond - * to messages received from other transmitting devices. - * The "off" setting means that the synthesizer will ignore its - * own transmitted MIDI messages, but not those received from other devices. - * - * It is possible that the underlying synthesizer - * does not support local control. In order - * to verify that a call to localControl - * was successful, check the return value. - * - * @param on true to turn local control on, false - * to turn local control off - * @return the new local-control value, or false - * if local control is not supported - * - */ - public boolean localControl(boolean on); - - /** - * Turns mono mode on or off. In mono mode, the channel synthesizes - * only one note at a time. In poly mode (identical to mono mode off), - * the channel can synthesize multiple notes simultaneously. - * The default is mono off (poly mode on). + * Turns local control on or off. The default is for local control to be on. + * The "on" setting means that if a device is capable of both synthesizing + * sound and transmitting MIDI messages, it will synthesize sound in + * response to the note-on and note-off messages that it itself transmits. + * It will also respond to messages received from other transmitting + * devices. The "off" setting means that the synthesizer will ignore its own + * transmitted MIDI messages, but not those received from other devices. *

    - * "Mono" is short for the word "monophonic," which in this context - * is opposed to the word "polyphonic" and refers to a single synthesizer - * voice per MIDI channel. It - * has nothing to do with how many audio channels there might be - * (as in "monophonic" versus "stereophonic" recordings). + * It is possible that the underlying synthesizer does not support local + * control. In order to verify that a call to {@code localControl} was + * successful, check the return value. * - * It is possible that the underlying synthesizer - * does not support mono mode. In order - * to verify that a call to setMono - * was successful, use getMono. - * - * @param on true to turn mono mode on, false to - * turn it off (which means turning poly mode on). + * @param on {@code true} to turn local control on, {@code false} to turn + * local control off + * @return the new local-control value, or false if local control is not + * supported + */ + boolean localControl(boolean on); + + /** + * Turns mono mode on or off. In mono mode, the channel synthesizes only one + * note at a time. In poly mode (identical to mono mode off), the channel + * can synthesize multiple notes simultaneously. The default is mono off + * (poly mode on). + *

    + * "Mono" is short for the word "monophonic," which in this context is + * opposed to the word "polyphonic" and refers to a single synthesizer voice + * per MIDI channel. It has nothing to do with how many audio channels there + * might be (as in "monophonic" versus "stereophonic" recordings). + *

    + * It is possible that the underlying synthesizer does not support mono + * mode. In order to verify that a call to {@code setMono} was successful, + * use {@code getMono}. * + * @param on {@code true} to turn mono mode on, {@code false} to turn it + * off (which means turning poly mode on) * @see #getMono * @see VoiceStatus */ - public void setMono(boolean on); + void setMono(boolean on); /** - * Obtains the current mono/poly mode. - * Synthesizers that do not allow changing mono/poly mode - * will always return the same value, regardless - * of calls to setMono. - * @return true if mono mode is on, otherwise - * false (meaning poly mode is on). + * Obtains the current mono/poly mode. Synthesizers that do not allow + * changing mono/poly mode will always return the same value, regardless of + * calls to {@code setMono}. * + * @return {@code true} if mono mode is on, otherwise {@code false} (meaning + * poly mode is on) * @see #setMono(boolean) */ - public boolean getMono(); + boolean getMono(); /** - * Turns omni mode on or off. In omni mode, the channel responds - * to messages sent on all channels. When omni is off, the channel - * responds only to messages sent on its channel number. - * The default is omni off. - * - * It is possible that the underlying synthesizer - * does not support omni mode. In order - * to verify that setOmni - * was successful, use getOmni. - * - * @param on true to turn omni mode on, false to - * turn it off. + * Turns omni mode on or off. In omni mode, the channel responds to messages + * sent on all channels. When omni is off, the channel responds only to + * messages sent on its channel number. The default is omni off. + *

    + * It is possible that the underlying synthesizer does not support omni + * mode. In order to verify that {@code setOmni} was successful, use + * {@code getOmni}. * + * @param on {@code true} to turn omni mode on, {@code false} to turn it + * off * @see #getOmni * @see VoiceStatus */ - public void setOmni(boolean on); + void setOmni(boolean on); /** - * Obtains the current omni mode. - * Synthesizers that do not allow changing the omni mode - * will always return the same value, regardless - * of calls to setOmni. - * @return true if omni mode is on, otherwise - * false (meaning omni mode is off). + * Obtains the current omni mode. Synthesizers that do not allow changing + * the omni mode will always return the same value, regardless of calls to + * {@code setOmni}. * + * @return {@code true} if omni mode is on, otherwise {@code false} (meaning + * omni mode is off) * @see #setOmni(boolean) */ - public boolean getOmni(); + boolean getOmni(); /** - * Sets the mute state for this channel. A value of - * true means the channel is to be muted, false - * means the channel can sound (if other channels are not soloed). + * Sets the mute state for this channel. A value of {@code true} means the + * channel is to be muted, {@code false} means the channel can sound (if + * other channels are not soloed). *

    - * Unlike {@link #allSoundOff()}, this method - * applies to only a specific channel, not to all channels. Further, it - * silences not only currently sounding notes, but also subsequently - * received notes. - * - * It is possible that the underlying synthesizer - * does not support muting channels. In order - * to verify that a call to setMute - * was successful, use getMute. - * - * @param mute the new mute state + * Unlike {@link #allSoundOff()}, this method applies to only a specific + * channel, not to all channels. Further, it silences not only currently + * sounding notes, but also subsequently received notes. + *

    + * It is possible that the underlying synthesizer does not support muting + * channels. In order to verify that a call to {@code setMute} was + * successful, use {@code getMute}. * + * @param mute the new mute state * @see #getMute * @see #setSolo(boolean) */ - public void setMute(boolean mute); + void setMute(boolean mute); /** - * Obtains the current mute state for this channel. - * If the underlying synthesizer does not support - * muting this channel, this method always returns - * false. - * - * @return true the channel is muted, - * or false if not + * Obtains the current mute state for this channel. If the underlying + * synthesizer does not support muting this channel, this method always + * returns {@code false}. * + * @return {@code true} the channel is muted, or {@code false} if not * @see #setMute(boolean) */ - public boolean getMute(); + boolean getMute(); /** - * Sets the solo state for this channel. - * If solo is true only this channel - * and other soloed channels will sound. If solo - * is false then only other soloed channels will - * sound, unless no channels are soloed, in which case all - * unmuted channels will sound. + * Sets the solo state for this channel. If {@code solo} is {@code true} + * only this channel and other soloed channels will sound. If {@code solo} + * is {@code false} then only other soloed channels will sound, unless no + * channels are soloed, in which case all unmuted channels will sound. + *

    + * It is possible that the underlying synthesizer does not support solo + * channels. In order to verify that a call to {@code setSolo} was + * successful, use {@code getSolo}. * - * It is possible that the underlying synthesizer - * does not support solo channels. In order - * to verify that a call to setSolo - * was successful, use getSolo. - * - * @param soloState new solo state for the channel + * @param soloState new solo state for the channel * @see #getSolo() */ - public void setSolo(boolean soloState); + void setSolo(boolean soloState); /** - * Obtains the current solo state for this channel. - * If the underlying synthesizer does not support - * solo on this channel, this method always returns - * false. - * - * @return true the channel is solo, - * or false if not + * Obtains the current solo state for this channel. If the underlying + * synthesizer does not support solo on this channel, this method always + * returns {@code false}. * + * @return {@code true} the channel is solo, or {@code false} if not * @see #setSolo(boolean) */ - public boolean getSolo(); + boolean getSolo(); } diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiDevice.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiDevice.java index f53d4ff3e2f..43c82932f6a 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiDevice.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiDevice.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -27,64 +27,52 @@ package javax.sound.midi; import java.util.List; - /** - * MidiDevice is the base interface for all MIDI devices. - * Common devices include synthesizers, sequencers, MIDI input ports, and MIDI - * output ports. - * - *

    A MidiDevice can be a transmitter or a receiver of - * MIDI events, or both. Therefore, it can provide {@link Transmitter} - * or {@link Receiver} instances (or both). Typically, MIDI IN ports - * provide transmitters, MIDI OUT ports and synthesizers provide - * receivers. A Sequencer typically provides transmitters for playback - * and receivers for recording. - * - *

    A MidiDevice can be opened and closed explicitly as - * well as implicitly. Explicit opening is accomplished by calling - * {@link #open}, explicit closing is done by calling {@link - * #close} on the MidiDevice instance. - * If an application opens a MidiDevice - * explicitly, it has to close it explicitly to free system resources - * and enable the application to exit cleanly. Implicit opening is - * done by calling {@link javax.sound.midi.MidiSystem#getReceiver - * MidiSystem.getReceiver} and {@link - * javax.sound.midi.MidiSystem#getTransmitter - * MidiSystem.getTransmitter}. The MidiDevice used by - * MidiSystem.getReceiver and - * MidiSystem.getTransmitter is implementation-dependant - * unless the properties javax.sound.midi.Receiver - * and javax.sound.midi.Transmitter are used (see the - * description of properties to select default providers in - * {@link javax.sound.midi.MidiSystem}). A MidiDevice - * that was opened implicitly, is closed implicitly by closing the - * Receiver or Transmitter that resulted in - * opening it. If more than one implicitly opening - * Receiver or Transmitter were obtained by - * the application, the device is closed after the last - * Receiver or Transmitter has been - * closed. On the other hand, calling getReceiver or - * getTransmitter on the device instance directly does - * not open the device implicitly. Closing these - * Transmitters and Receivers does not close - * the device implicitly. To use a device with Receivers - * or Transmitters obtained this way, the device has to - * be opened and closed explicitly. - * - *

    If implicit and explicit opening and closing are mixed on the - * same MidiDevice instance, the following rules apply: +/** + * {@code MidiDevice} is the base interface for all MIDI devices. Common devices + * include synthesizers, sequencers, MIDI input ports, and MIDI output ports. + *

    + * A {@code MidiDevice} can be a transmitter or a receiver of MIDI events, or + * both. Therefore, it can provide {@link Transmitter} or {@link Receiver} + * instances (or both). Typically, MIDI IN ports provide transmitters, MIDI OUT + * ports and synthesizers provide receivers. A Sequencer typically provides + * transmitters for playback and receivers for recording. + *

    + * A {@code MidiDevice} can be opened and closed explicitly as well as + * implicitly. Explicit opening is accomplished by calling {@link #open}, + * explicit closing is done by calling {@link #close} on the {@code MidiDevice} + * instance. If an application opens a {@code MidiDevice} explicitly, it has to + * close it explicitly to free system resources and enable the application to + * exit cleanly. Implicit opening is done by calling + * {@link MidiSystem#getReceiver} and {@link MidiSystem#getTransmitter}. The + * {@code MidiDevice} used by {@code MidiSystem.getReceiver} and + * {@code MidiSystem.getTransmitter} is implementation-dependant unless the + * properties {@code javax.sound.midi.Receiver} and + * {@code javax.sound.midi.Transmitter} are used (see the description of + * properties to select default providers in {@link MidiSystem}). A + * {@code MidiDevice} that was opened implicitly, is closed implicitly by + * closing the {@code Receiver} or {@code Transmitter} that resulted in opening + * it. If more than one implicitly opening {@code Receiver} or + * {@code Transmitter} were obtained by the application, the device is closed + * after the last {@code Receiver} or {@code Transmitter} has been closed. On + * the other hand, calling {@code getReceiver} or {@code getTransmitter} on the + * device instance directly does not open the device implicitly. Closing these + * {@code Transmitter}s and {@code Receiver}s does not close the device + * implicitly. To use a device with {@code Receiver}s or {@code Transmitter}s + * obtained this way, the device has to be opened and closed explicitly. + *

    + * If implicit and explicit opening and closing are mixed on the same + * {@code MidiDevice} instance, the following rules apply: * *

      - *
    • After an explicit open (either before or after implicit - * opens), the device will not be closed by implicit closing. The only - * way to close an explicitly opened device is an explicit close.
    • - * - *
    • An explicit close always closes the device, even if it also has - * been opened implicitly. A subsequent implicit close has no further - * effect.
    • + *
    • After an explicit open (either before or after implicit opens), the + * device will not be closed by implicit closing. The only way to close an + * explicitly opened device is an explicit close.
    • + *
    • An explicit close always closes the device, even if it also has been + * opened implicitly. A subsequent implicit close has no further effect.
    • *
    * - * To detect if a MidiDevice represents a hardware MIDI port, the - * following programming technique can be used: + * To detect if a MidiDevice represents a hardware MIDI port, the following + * programming technique can be used: * *
    {@code
      * MidiDevice device = ...;
    @@ -95,193 +83,171 @@ import java.util.List;
      * }
    * *

    - * A MidiDevice includes a {@link MidiDevice.Info} object - * to provide manufacturer information and so on. + * A {@code MidiDevice} includes a {@link Info} object to provide manufacturer + * information and so on. * + * @author Kara Kytle + * @author Florian Bomers * @see Synthesizer * @see Sequencer * @see Receiver * @see Transmitter - * - * @author Kara Kytle - * @author Florian Bomers */ - public interface MidiDevice extends AutoCloseable { - /** * Obtains information about the device, including its Java class and - * Strings containing its name, vendor, and description. + * {@code Strings} containing its name, vendor, and description. * * @return device info */ - public Info getDeviceInfo(); - + Info getDeviceInfo(); /** - * Opens the device, indicating that it should now acquire any - * system resources it requires and become operational. - * - *

    An application opening a device explicitly with this call - * has to close the device by calling {@link #close}. This is - * necessary to release system resources and allow applications to - * exit cleanly. - * + * Opens the device, indicating that it should now acquire any system + * resources it requires and become operational. *

    - * Note that some devices, once closed, cannot be reopened. Attempts - * to reopen such a device will always result in a MidiUnavailableException. - * - * @throws MidiUnavailableException thrown if the device cannot be - * opened due to resource restrictions. - * @throws SecurityException thrown if the device cannot be - * opened due to security restrictions. + * An application opening a device explicitly with this call has to close + * the device by calling {@link #close}. This is necessary to release system + * resources and allow applications to exit cleanly. + *

    + * Note that some devices, once closed, cannot be reopened. Attempts to + * reopen such a device will always result in a MidiUnavailableException. * + * @throws MidiUnavailableException thrown if the device cannot be opened + * due to resource restrictions + * @throws SecurityException thrown if the device cannot be opened due to + * security restrictions * @see #close * @see #isOpen */ - public void open() throws MidiUnavailableException; - + void open() throws MidiUnavailableException; /** - * Closes the device, indicating that the device should now release - * any system resources it is using. - * - *

    All Receiver and Transmitter instances - * open from this device are closed. This includes instances retrieved - * via MidiSystem. + * Closes the device, indicating that the device should now release any + * system resources it is using. + *

    + * All {@code Receiver} and {@code Transmitter} instances open from this + * device are closed. This includes instances retrieved via + * {@code MidiSystem}. * * @see #open * @see #isOpen */ - public void close(); - + void close(); /** * Reports whether the device is open. * - * @return true if the device is open, otherwise - * false + * @return {@code true} if the device is open, otherwise {@code false} * @see #open * @see #close */ - public boolean isOpen(); - + boolean isOpen(); /** - * Obtains the current time-stamp of the device, in microseconds. - * If a device supports time-stamps, it should start counting at - * 0 when the device is opened and continue incrementing its - * time-stamp in microseconds until the device is closed. - * If it does not support time-stamps, it should always return - * -1. - * @return the current time-stamp of the device in microseconds, - * or -1 if time-stamping is not supported by the device. - */ - public long getMicrosecondPosition(); - - - /** - * Obtains the maximum number of MIDI IN connections available on this - * MIDI device for receiving MIDI data. - * @return maximum number of MIDI IN connections, - * or -1 if an unlimited number of connections is available. - */ - public int getMaxReceivers(); - - - /** - * Obtains the maximum number of MIDI OUT connections available on this - * MIDI device for transmitting MIDI data. - * @return maximum number of MIDI OUT connections, - * or -1 if an unlimited number of connections is available. - */ - public int getMaxTransmitters(); - - - /** - * Obtains a MIDI IN receiver through which the MIDI device may receive - * MIDI data. The returned receiver must be closed when the application - * has finished using it. + * Obtains the current time-stamp of the device, in microseconds. If a + * device supports time-stamps, it should start counting at 0 when the + * device is opened and continue incrementing its time-stamp in microseconds + * until the device is closed. If it does not support time-stamps, it should + * always return -1. * - *

    Usually the returned receiver implements - * the {@code MidiDeviceReceiver} interface. + * @return the current time-stamp of the device in microseconds, or -1 if + * time-stamping is not supported by the device + */ + long getMicrosecondPosition(); + + /** + * Obtains the maximum number of MIDI IN connections available on this MIDI + * device for receiving MIDI data. * - *

    Obtaining a Receiver with this method does not - * open the device. To be able to use the device, it has to be - * opened explicitly by calling {@link #open}. Also, closing the - * Receiver does not close the device. It has to be - * closed explicitly by calling {@link #close}. + * @return maximum number of MIDI IN connections, or -1 if an unlimited + * number of connections is available + */ + int getMaxReceivers(); + + /** + * Obtains the maximum number of MIDI OUT connections available on this MIDI + * device for transmitting MIDI data. * - * @return a receiver for the device. + * @return maximum number of MIDI OUT connections, or -1 if an unlimited + * number of connections is available + */ + int getMaxTransmitters(); + + /** + * Obtains a MIDI IN receiver through which the MIDI device may receive MIDI + * data. The returned receiver must be closed when the application has + * finished using it. + *

    + * Usually the returned receiver implements the {@code MidiDeviceReceiver} + * interface. + *

    + * Obtaining a {@code Receiver} with this method does not open the device. + * To be able to use the device, it has to be opened explicitly by calling + * {@link #open}. Also, closing the {@code Receiver} does not close the + * device. It has to be closed explicitly by calling {@link #close}. + * + * @return a receiver for the device * @throws MidiUnavailableException thrown if a receiver is not available - * due to resource restrictions + * due to resource restrictions * @see Receiver#close() */ - public Receiver getReceiver() throws MidiUnavailableException; - + Receiver getReceiver() throws MidiUnavailableException; /** - * Returns all currently active, non-closed receivers - * connected with this MidiDevice. - * A receiver can be removed - * from the device by closing it. - * - *

    Usually the returned receivers implement - * the {@code MidiDeviceReceiver} interface. + * Returns all currently active, non-closed receivers connected with this + * MidiDevice. A receiver can be removed from the device by closing it. + *

    + * Usually the returned receivers implement the {@code MidiDeviceReceiver} + * interface. * * @return an unmodifiable list of the open receivers * @since 1.5 */ List getReceivers(); - /** * Obtains a MIDI OUT connection from which the MIDI device will transmit - * MIDI data The returned transmitter must be closed when the application + * MIDI data. The returned transmitter must be closed when the application * has finished using it. + *

    + * Usually the returned transmitter implements the + * {@code MidiDeviceTransmitter} interface. + *

    + * Obtaining a {@code Transmitter} with this method does not open the + * device. To be able to use the device, it has to be opened explicitly by + * calling {@link #open}. Also, closing the {@code Transmitter} does not + * close the device. It has to be closed explicitly by calling + * {@link #close}. * - *

    Usually the returned transmitter implements - * the {@code MidiDeviceTransmitter} interface. - * - *

    Obtaining a Transmitter with this method does not - * open the device. To be able to use the device, it has to be - * opened explicitly by calling {@link #open}. Also, closing the - * Transmitter does not close the device. It has to be - * closed explicitly by calling {@link #close}. - * - * @return a MIDI OUT transmitter for the device. + * @return a MIDI OUT transmitter for the device * @throws MidiUnavailableException thrown if a transmitter is not available - * due to resource restrictions + * due to resource restrictions * @see Transmitter#close() */ - public Transmitter getTransmitter() throws MidiUnavailableException; - + Transmitter getTransmitter() throws MidiUnavailableException; /** - * Returns all currently active, non-closed transmitters - * connected with this MidiDevice. - * A transmitter can be removed - * from the device by closing it. - * - *

    Usually the returned transmitters implement - * the {@code MidiDeviceTransmitter} interface. + * Returns all currently active, non-closed transmitters connected with this + * MidiDevice. A transmitter can be removed from the device by closing it. + *

    + * Usually the returned transmitters implement the + * {@code MidiDeviceTransmitter} interface. * * @return an unmodifiable list of the open transmitters * @since 1.5 */ List getTransmitters(); - - /** - * A MidiDevice.Info object contains assorted - * data about a {@link MidiDevice}, including its - * name, the company who created it, and descriptive text. + * A {@code MidiDevice.Info} object contains assorted data about a + * {@link MidiDevice}, including its name, the company who created it, and + * descriptive text. * * @see MidiDevice#getDeviceInfo */ - public static class Info { + class Info { /** * The device's name. @@ -303,16 +269,16 @@ public interface MidiDevice extends AutoCloseable { */ private String version; - /** * Constructs a device info object. * - * @param name the name of the device - * @param vendor the name of the company who provides the device - * @param description a description of the device - * @param version version information for the device + * @param name the name of the device + * @param vendor the name of the company who provides the device + * @param description a description of the device + * @param version version information for the device */ - protected Info(String name, String vendor, String description, String version) { + protected Info(String name, String vendor, String description, + String version) { this.name = name; this.vendor = vendor; @@ -320,20 +286,18 @@ public interface MidiDevice extends AutoCloseable { this.version = version; } - /** - * Reports whether two objects are equal. - * Returns true if the objects are identical. - * @param obj the reference object with which to compare this - * object - * @return true if this object is the same as the - * obj argument; false otherwise + * Reports whether two objects are equal. Returns {@code true} if the + * objects are identical. + * + * @param obj the reference object with which to compare this object + * @return {@code true} if this object is the same as the {@code obj} + * argument; {@code false} otherwise */ public final boolean equals(Object obj) { return super.equals(obj); } - /** * Finalizes the hashcode method. */ @@ -341,7 +305,6 @@ public interface MidiDevice extends AutoCloseable { return super.hashCode(); } - /** * Obtains the name of the device. * @@ -351,43 +314,40 @@ public interface MidiDevice extends AutoCloseable { return name; } - /** * Obtains the name of the company who supplies the device. + * * @return device the vendor's name */ public final String getVendor() { return vendor; } - /** * Obtains the description of the device. + * * @return a description of the device */ public final String getDescription() { return description; } - /** * Obtains the version of the device. + * * @return textual version information for the device. */ public final String getVersion() { return version; } - /** * Provides a string representation of the device information. - + * * @return a description of the info object */ public final String toString() { return name; } } // class Info - - } diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiDeviceReceiver.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiDeviceReceiver.java index 550c7a4ccb8..569850836e1 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiDeviceReceiver.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiDeviceReceiver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -26,16 +26,18 @@ package javax.sound.midi; /** - *

    {@code MidiDeviceReceiver} is a {@code Receiver} which represents - * a MIDI input connector of a {@code MidiDevice} - * (see {@link MidiDevice#getReceiver()}). + * {@code MidiDeviceReceiver} is a {@code Receiver} which represents a MIDI + * input connector of a {@code MidiDevice} (see + * {@link MidiDevice#getReceiver()}). * * @since 1.7 */ public interface MidiDeviceReceiver extends Receiver { + /** * Obtains a MidiDevice object which is an owner of this Receiver. + * * @return a MidiDevice object which is an owner of this Receiver */ - public MidiDevice getMidiDevice(); + MidiDevice getMidiDevice(); } diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiDeviceTransmitter.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiDeviceTransmitter.java index 730628c5e8d..aaf7aba72d3 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiDeviceTransmitter.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiDeviceTransmitter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -25,11 +25,10 @@ package javax.sound.midi; - /** - *

    {@code MidiDeviceTransmitter} is a {@code Transmitter} which represents - * a MIDI input connector of a {@code MidiDevice} - * (see {@link MidiDevice#getTransmitter()}). + * {@code MidiDeviceTransmitter} is a {@code Transmitter} which represents a + * MIDI input connector of a {@code MidiDevice} (see + * {@link MidiDevice#getTransmitter()}). * * @since 1.7 */ @@ -37,7 +36,8 @@ public interface MidiDeviceTransmitter extends Transmitter { /** * Obtains a MidiDevice object which is an owner of this Transmitter. + * * @return a MidiDevice object which is an owner of this Transmitter */ - public MidiDevice getMidiDevice(); + MidiDevice getMidiDevice(); } diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiEvent.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiEvent.java index b5f4c5ca08d..caf6e7936ad 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiEvent.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -26,41 +26,35 @@ package javax.sound.midi; /** - * MIDI events contain a MIDI message and a corresponding time-stamp - * expressed in ticks, and can represent the MIDI event information - * stored in a MIDI file or a {@link Sequence} object. The - * duration of a tick is specified by the timing information contained - * in the MIDI file or Sequence object. + * MIDI events contain a MIDI message and a corresponding time-stamp expressed + * in ticks, and can represent the MIDI event information stored in a MIDI file + * or a {@link Sequence} object. The duration of a tick is specified by the + * timing information contained in the MIDI file or {@code Sequence} object. *

    - * In Java Sound, MidiEvent objects are typically contained in a - * {@link Track}, and Tracks are likewise - * contained in a Sequence. - * + * In Java Sound, {@code MidiEvent} objects are typically contained in a + * {@link Track}, and {@code Tracks} are likewise contained in a + * {@code Sequence}. * * @author David Rivas * @author Kara Kytle */ public class MidiEvent { - - // Instance variables - /** * The MIDI message for this event. */ private final MidiMessage message; - /** * The tick value for this event. */ private long tick; - /** - * Constructs a new MidiEvent. - * @param message the MIDI message contained in the event - * @param tick the time-stamp for the event, in MIDI ticks + * Constructs a new {@code MidiEvent}. + * + * @param message the MIDI message contained in the event + * @param tick the time-stamp for the event, in MIDI ticks */ public MidiEvent(MidiMessage message, long tick) { @@ -70,24 +64,25 @@ public class MidiEvent { /** * Obtains the MIDI message contained in the event. + * * @return the MIDI message */ public MidiMessage getMessage() { return message; } - /** - * Sets the time-stamp for the event, in MIDI ticks - * @param tick the new time-stamp, in MIDI ticks + * Sets the time-stamp for the event, in MIDI ticks. + * + * @param tick the new time-stamp, in MIDI ticks */ public void setTick(long tick) { this.tick = tick; } - /** - * Obtains the time-stamp for the event, in MIDI ticks + * Obtains the time-stamp for the event, in MIDI ticks. + * * @return the time-stamp for the event, in MIDI ticks */ public long getTick() { diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiFileFormat.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiFileFormat.java index c34bb6d1900..474881571c4 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiFileFormat.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiFileFormat.java @@ -25,29 +25,23 @@ package javax.sound.midi; -import java.io.InputStream; -import java.io.IOException; import java.util.Collections; import java.util.HashMap; import java.util.Map; - /** - * A MidiFileFormat object encapsulates a MIDI file's - * type, as well as its length and timing information. - * - *

    A MidiFileFormat object can - * include a set of properties. A property is a pair of key and value: - * the key is of type String, the associated property - * value is an arbitrary object. - * Properties specify additional informational - * meta data (like a author, or copyright). - * Properties are optional information, and file reader and file - * writer implementations are not required to provide or - * recognize properties. - * - *

    The following table lists some common properties that should - * be used in implementations: + * A {@code MidiFileFormat} object encapsulates a MIDI file's type, as well as + * its length and timing information. + *

    + * A {@code MidiFileFormat} object can include a set of properties. A property + * is a pair of key and value: the key is of type {@code String}, the associated + * property value is an arbitrary object. Properties specify additional + * informational meta data (like a author, or copyright). Properties are + * optional information, and file reader and file writer implementations are not + * required to provide or recognize properties. + *

    + * The following table lists some common properties that should be used in + * implementations: * * @@ -83,24 +77,21 @@ import java.util.Map; * *
    MIDI File Format Properties
    * - * @see MidiSystem#getMidiFileFormat(java.io.File) - * @see Sequencer#setSequence(java.io.InputStream stream) - * * @author Kara Kytle * @author Florian Bomers + * @see MidiSystem#getMidiFileFormat(java.io.File) + * @see Sequencer#setSequence(java.io.InputStream stream) */ - public class MidiFileFormat { - /** * Represents unknown length. + * * @see #getByteLength * @see #getMicrosecondLength */ public static final int UNKNOWN_LENGTH = -1; - /** * The type of MIDI file. */ @@ -132,19 +123,22 @@ public class MidiFileFormat { */ protected long microsecondLength; - - /** The set of properties */ + /** + * The set of properties. + */ private HashMap properties; - /** - * Constructs a MidiFileFormat. + * Constructs a {@code MidiFileFormat}. * - * @param type the MIDI file type (0, 1, or 2) - * @param divisionType the timing division type (PPQ or one of the SMPTE types) - * @param resolution the timing resolution - * @param bytes the length of the MIDI file in bytes, or UNKNOWN_LENGTH if not known - * @param microseconds the duration of the file in microseconds, or UNKNOWN_LENGTH if not known + * @param type the MIDI file type (0, 1, or 2) + * @param divisionType the timing division type (PPQ or one of the SMPTE + * types) + * @param resolution the timing resolution + * @param bytes the length of the MIDI file in bytes, or UNKNOWN_LENGTH if + * not known + * @param microseconds the duration of the file in microseconds, or + * UNKNOWN_LENGTH if not known * @see #UNKNOWN_LENGTH * @see Sequence#PPQ * @see Sequence#SMPTE_24 @@ -162,21 +156,18 @@ public class MidiFileFormat { this.properties = null; } - /** - * Construct a MidiFileFormat with a set of properties. - * - * @param type the MIDI file type (0, 1, or 2) - * @param divisionType the timing division type - * (PPQ or one of the SMPTE types) - * @param resolution the timing resolution - * @param bytes the length of the MIDI file in bytes, - * or UNKNOWN_LENGTH if not known - * @param microseconds the duration of the file in microseconds, - * or UNKNOWN_LENGTH if not known - * @param properties a Map<String,Object> object - * with properties + * Construct a {@code MidiFileFormat} with a set of properties. * + * @param type the MIDI file type (0, 1, or 2) + * @param divisionType the timing division type (PPQ or one of the SMPTE + * types) + * @param resolution the timing resolution + * @param bytes the length of the MIDI file in bytes, or UNKNOWN_LENGTH if + * not known + * @param microseconds the duration of the file in microseconds, or + * UNKNOWN_LENGTH if not known + * @param properties a {@code Map} object with properties * @see #UNKNOWN_LENGTH * @see Sequence#PPQ * @see Sequence#SMPTE_24 @@ -192,10 +183,9 @@ public class MidiFileFormat { this.properties = new HashMap(properties); } - - /** * Obtains the MIDI file type. + * * @return the file's type (0, 1, or 2) */ public int getType() { @@ -206,7 +196,6 @@ public class MidiFileFormat { * Obtains the timing division type for the MIDI file. * * @return the division type (PPQ or one of the SMPTE types) - * * @see Sequence#Sequence(float, int) * @see Sequence#PPQ * @see Sequence#SMPTE_24 @@ -219,11 +208,10 @@ public class MidiFileFormat { return divisionType; } - /** - * Obtains the timing resolution for the MIDI file. - * If the division type is PPQ, the resolution is specified in ticks per beat. - * For SMTPE timing, the resolution is specified in ticks per frame. + * Obtains the timing resolution for the MIDI file. If the division type is + * PPQ, the resolution is specified in ticks per beat. For SMTPE timing, the + * resolution is specified in ticks per frame. * * @return the number of ticks per beat (PPQ) or per frame (SMPTE) * @see #getDivisionType @@ -233,9 +221,9 @@ public class MidiFileFormat { return resolution; } - /** * Obtains the length of the MIDI file, expressed in 8-bit bytes. + * * @return the number of bytes in the file, or UNKNOWN_LENGTH if not known * @see #UNKNOWN_LENGTH */ @@ -245,7 +233,9 @@ public class MidiFileFormat { /** * Obtains the length of the MIDI file, expressed in microseconds. - * @return the file's duration in microseconds, or UNKNOWN_LENGTH if not known + * + * @return the file's duration in microseconds, or UNKNOWN_LENGTH if not + * known * @see Sequence#getMicrosecondLength() * @see #getByteLength * @see #UNKNOWN_LENGTH @@ -255,14 +245,11 @@ public class MidiFileFormat { } /** - * Obtain an unmodifiable map of properties. - * The concept of properties is further explained in - * the {@link MidiFileFormat class description}. - * - * @return a Map<String,Object> object containing - * all properties. If no properties are recognized, an empty map is - * returned. + * Obtain an unmodifiable map of properties. The concept of properties is + * further explained in the {@link MidiFileFormat class description}. * + * @return a {@code Map} object containing all properties. If + * no properties are recognized, an empty map is returned. * @see #getProperty(String) * @since 1.5 */ @@ -277,20 +264,16 @@ public class MidiFileFormat { return Collections.unmodifiableMap(ret); } - /** - * Obtain the property value specified by the key. - * The concept of properties is further explained in - * the {@link MidiFileFormat class description}. - * - *

    If the specified property is not defined for a - * particular file format, this method returns - * null. - * - * @param key the key of the desired property - * @return the value of the property with the specified key, - * or null if the property does not exist. + * Obtain the property value specified by the key. The concept of properties + * is further explained in the {@link MidiFileFormat class description}. + *

    + * If the specified property is not defined for a particular file format, + * this method returns {@code null}. * + * @param key the key of the desired property + * @return the value of the property with the specified key, or {@code null} + * if the property does not exist * @see #properties() * @since 1.5 */ @@ -300,6 +283,4 @@ public class MidiFileFormat { } return properties.get(key); } - - } diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiMessage.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiMessage.java index 728d654cea8..0633c32f72b 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiMessage.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiMessage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -26,83 +26,76 @@ package javax.sound.midi; /** - * MidiMessage is the base class for MIDI messages. They include - * not only the standard MIDI messages that a synthesizer can respond to, but also - * "meta-events" that can be used by sequencer programs. There are meta-events + * {@code MidiMessage} is the base class for MIDI messages. They include not + * only the standard MIDI messages that a synthesizer can respond to, but also + * "meta-events" that can be used by sequencer programs. There are meta-events * for such information as lyrics, copyrights, tempo indications, time and key - * signatures, markers, etc. For more information, see the Standard MIDI Files 1.0 - * specification, which is part of the Complete MIDI 1.0 Detailed Specification - * published by the MIDI Manufacturer's Association + * signatures, markers, etc. For more information, see the Standard MIDI Files + * 1.0 specification, which is part of the Complete MIDI 1.0 Detailed + * Specification published by the MIDI Manufacturer's Association * (http://www.midi.org). *

    - * The base MidiMessage class provides access to three types of + * The base {@code MidiMessage} class provides access to three types of * information about a MIDI message: *

      *
    • The messages's status byte
    • - *
    • The total length of the message in bytes (the status byte plus any data bytes)
    • + *
    • The total length of the message in bytes (the status byte plus any data + * bytes)
    • *
    • A byte array containing the complete message
    • *
    * - * MidiMessage includes methods to get, but not set, these values. + * {@code MidiMessage} includes methods to get, but not set, these values. * Setting them is a subclass responsibility. *

    - * - * The MIDI standard expresses MIDI data in bytes. However, because - * JavaTM uses signed bytes, the Java Sound API uses integers - * instead of bytes when expressing MIDI data. For example, the - * {@link #getStatus()} method of - * MidiMessage returns MIDI status bytes as integers. If you are - * processing MIDI data that originated outside Java Sound and now - * is encoded as signed bytes, the bytes can - * can be converted to integers using this conversion: + * The MIDI standard expresses MIDI data in + * bytes. However, because JavaTM uses signed bytes, the Java Sound + * API uses integers instead of bytes when expressing MIDI data. For example, + * the {@link #getStatus()} method of {@code MidiMessage} returns MIDI status + * bytes as integers. If you are processing MIDI data that originated outside + * Java Sound and now is encoded as signed bytes, the bytes can can be + * converted to integers using this conversion: + * *

    {@code int i = (int)(byte & 0xFF)}
    *

    - * If you simply need to pass a known MIDI byte value as a method parameter, - * it can be expressed directly as an integer, using (for example) decimal or - * hexadecimal notation. For instance, to pass the "active sensing" status byte + * If you simply need to pass a known MIDI byte value as a method parameter, it + * can be expressed directly as an integer, using (for example) decimal or + * hexadecimal notation. For instance, to pass the "active sensing" status byte * as the first argument to ShortMessage's - * {@link ShortMessage#setMessage(int) setMessage(int)} - * method, you can express it as 254 or 0xFE. - * - * @see Track - * @see Sequence - * @see Receiver + * {@link ShortMessage#setMessage(int) setMessage(int)} method, you can express + * it as 254 or 0xFE. * * @author David Rivas * @author Kara Kytle + * @see Track + * @see Sequence + * @see Receiver */ - public abstract class MidiMessage implements Cloneable { - // Instance variables - /** - * The MIDI message data. The first byte is the status - * byte for the message; subsequent bytes up to the length - * of the message are data bytes for this message. + * The MIDI message data. The first byte is the status byte for the message; + * subsequent bytes up to the length of the message are data bytes for this + * message. + * * @see #getLength */ protected byte[] data; - /** - * The number of bytes in the MIDI message, including the - * status byte and any data bytes. + * The number of bytes in the MIDI message, including the status byte and + * any data bytes. + * * @see #getLength */ protected int length = 0; - /** - * Constructs a new MidiMessage. This protected - * constructor is called by concrete subclasses, which should - * ensure that the data array specifies a complete, valid MIDI - * message. - * - * @param data an array of bytes containing the complete message. - * The message data may be changed using the setMessage - * method. + * Constructs a new {@code MidiMessage}. This protected constructor is + * called by concrete subclasses, which should ensure that the data array + * specifies a complete, valid MIDI message. * + * @param data an array of bytes containing the complete message. The + * message data may be changed using the {@code setMessage} method. * @see #setMessage */ protected MidiMessage(byte[] data) { @@ -112,20 +105,21 @@ public abstract class MidiMessage implements Cloneable { } } - /** - * Sets the data for the MIDI message. This protected - * method is called by concrete subclasses, which should - * ensure that the data array specifies a complete, valid MIDI - * message. + * Sets the data for the MIDI message. This protected method is called by + * concrete subclasses, which should ensure that the data array specifies a + * complete, valid MIDI message. * - * @param data the data bytes in the MIDI message - * @param length the number of bytes in the data byte array - * @throws InvalidMidiDataException if the parameter values do not specify a valid MIDI meta message + * @param data the data bytes in the MIDI message + * @param length the number of bytes in the data byte array + * @throws InvalidMidiDataException if the parameter values do not specify a + * valid MIDI meta message */ - protected void setMessage(byte[] data, int length) throws InvalidMidiDataException { + protected void setMessage(byte[] data, int length) + throws InvalidMidiDataException { if (length < 0 || (length > 0 && length > data.length)) { - throw new IndexOutOfBoundsException("length out of bounds: "+length); + throw new IndexOutOfBoundsException( + "length out of bounds: " + length); } this.length = length; @@ -135,16 +129,14 @@ public abstract class MidiMessage implements Cloneable { System.arraycopy(data, 0, this.data, 0, length); } - /** - * Obtains the MIDI message data. The first byte of the returned byte - * array is the status byte of the message. Any subsequent bytes up to - * the length of the message are data bytes. The byte array may have a - * length which is greater than that of the actual message; the total - * length of the message in bytes is reported by the {@link #getLength} - * method. + * Obtains the MIDI message data. The first byte of the returned byte array + * is the status byte of the message. Any subsequent bytes up to the length + * of the message are data bytes. The byte array may have a length which is + * greater than that of the actual message; the total length of the message + * in bytes is reported by the {@link #getLength} method. * - * @return the byte array containing the complete MidiMessage data + * @return the byte array containing the complete {@code MidiMessage} data */ public byte[] getMessage() { byte[] returnedArray = new byte[length]; @@ -152,12 +144,11 @@ public abstract class MidiMessage implements Cloneable { return returnedArray; } - /** - * Obtains the status byte for the MIDI message. The status "byte" is + * Obtains the status byte for the MIDI message. The status "byte" is * represented as an integer; see the - * discussion in the - * MidiMessage class description. + * discussion in the {@code MidiMessage} + * class description. * * @return the integer representation of this event's status byte */ @@ -168,13 +159,11 @@ public abstract class MidiMessage implements Cloneable { return 0; } - /** - * Obtains the total length of the MIDI message in bytes. A - * MIDI message consists of one status byte and zero or more - * data bytes. The return value ranges from 1 for system real-time messages, - * to 2 or 3 for channel messages, to any value for meta and system - * exclusive messages. + * Obtains the total length of the MIDI message in bytes. A MIDI message + * consists of one status byte and zero or more data bytes. The return value + * ranges from 1 for system real-time messages, to 2 or 3 for channel + * messages, to any value for meta and system exclusive messages. * * @return the length of the message in bytes */ @@ -182,11 +171,11 @@ public abstract class MidiMessage implements Cloneable { return length; } - /** - * Creates a new object of the same class and with the same contents - * as this object. - * @return a clone of this instance. + * Creates a new object of the same class and with the same contents as this + * object. + * + * @return a clone of this instance */ public abstract Object clone(); } diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiSystem.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiSystem.java index 635dc54ce7a..9f790fd0f01 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiSystem.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiSystem.java @@ -25,59 +25,52 @@ package javax.sound.midi; -import java.io.FileInputStream; import java.io.File; +import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.io.IOException; - +import java.net.URL; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Properties; import java.util.Set; -import java.net.URL; - -import javax.sound.midi.spi.MidiFileWriter; -import javax.sound.midi.spi.MidiFileReader; -import javax.sound.midi.spi.SoundbankReader; import javax.sound.midi.spi.MidiDeviceProvider; +import javax.sound.midi.spi.MidiFileReader; +import javax.sound.midi.spi.MidiFileWriter; +import javax.sound.midi.spi.SoundbankReader; -import com.sun.media.sound.JDK13Services; -import com.sun.media.sound.ReferenceCountingDevice; import com.sun.media.sound.AutoConnectSequencer; +import com.sun.media.sound.JDK13Services; import com.sun.media.sound.MidiDeviceReceiverEnvelope; import com.sun.media.sound.MidiDeviceTransmitterEnvelope; - +import com.sun.media.sound.ReferenceCountingDevice; /** - * The MidiSystem class provides access to the installed MIDI - * system resources, including devices such as synthesizers, sequencers, and - * MIDI input and output ports. A typical simple MIDI application might - * begin by invoking one or more MidiSystem methods to learn - * what devices are installed and to obtain the ones needed in that - * application. + * The {@code MidiSystem} class provides access to the installed MIDI system + * resources, including devices such as synthesizers, sequencers, and MIDI input + * and output ports. A typical simple MIDI application might begin by invoking + * one or more {@code MidiSystem} methods to learn what devices are installed + * and to obtain the ones needed in that application. *

    - * The class also has methods for reading files, streams, and URLs that - * contain standard MIDI file data or soundbanks. You can query the - * MidiSystem for the format of a specified MIDI file. + * The class also has methods for reading files, streams, and URLs that contain + * standard MIDI file data or soundbanks. You can query the {@code MidiSystem} + * for the format of a specified MIDI file. *

    - * You cannot instantiate a MidiSystem; all the methods are - * static. - * - *

    Properties can be used to specify default MIDI devices. - * Both system properties and a properties file are considered. - * The sound.properties properties file is read from - * an implementation-specific location (typically it is the lib - * directory in the Java installation directory). - * If a property exists both as a system property and in the - * properties file, the system property takes precedence. If none is - * specified, a suitable default is chosen among the available devices. - * The syntax of the properties file is specified in - * {@link java.util.Properties#load(InputStream) Properties.load}. The - * following table lists the available property keys and which methods - * consider them: + * You cannot instantiate a {@code MidiSystem}; all the methods are static. + *

    + * Properties can be used to specify default MIDI devices. Both system + * properties and a properties file are considered. The "sound.properties" + * properties file is read from an implementation-specific location (typically + * it is the {@code lib} directory in the Java installation directory). If a + * property exists both as a system property and in the properties file, the + * system property takes precedence. If none is specified, a suitable default is + * chosen among the available devices. The syntax of the properties file is + * specified in {@link Properties#load(InputStream) Properties.load}. The + * following table lists the available property keys and which methods consider + * them: * * * @@ -87,80 +80,64 @@ import com.sun.media.sound.MidiDeviceTransmitterEnvelope; * * * - * + * * * * * - * + * * * * * - * + * * * * * - * + * * * * *
    MIDI System Property Keys
    Affected Method
    javax.sound.midi.Receiver{@code javax.sound.midi.Receiver}{@link Receiver}{@link #getReceiver}
    javax.sound.midi.Sequencer{@code javax.sound.midi.Sequencer}{@link Sequencer}{@link #getSequencer}
    javax.sound.midi.Synthesizer{@code javax.sound.midi.Synthesizer}{@link Synthesizer}{@link #getSynthesizer}
    javax.sound.midi.Transmitter{@code javax.sound.midi.Transmitter}{@link Transmitter}{@link #getTransmitter}
    * - * The property value consists of the provider class name - * and the device name, separated by the hash mark ("#"). - * The provider class name is the fully-qualified - * name of a concrete {@link javax.sound.midi.spi.MidiDeviceProvider - * MIDI device provider} class. The device name is matched against - * the String returned by the getName - * method of MidiDevice.Info. - * Either the class name, or the device name may be omitted. - * If only the class name is specified, the trailing hash mark - * is optional. - * - *

    If the provider class is specified, and it can be - * successfully retrieved from the installed providers, - * the list of - * MidiDevice.Info objects is retrieved - * from the provider. Otherwise, or when these devices - * do not provide a subsequent match, the list is retrieved - * from {@link #getMidiDeviceInfo} to contain - * all available MidiDevice.Info objects. - * - *

    If a device name is specified, the resulting list of - * MidiDevice.Info objects is searched: - * the first one with a matching name, and whose - * MidiDevice implements the - * respective interface, will be returned. - * If no matching MidiDevice.Info object - * is found, or the device name is not specified, - * the first suitable device from the resulting - * list will be returned. For Sequencer and Synthesizer, - * a device is suitable if it implements the respective - * interface; whereas for Receiver and Transmitter, a device is - * suitable if it - * implements neither Sequencer nor Synthesizer and provides - * at least one Receiver or Transmitter, respectively. - * - * For example, the property javax.sound.midi.Receiver - * with a value - * "com.sun.media.sound.MidiProvider#SunMIDI1" - * will have the following consequences when - * getReceiver is called: - * if the class com.sun.media.sound.MidiProvider exists - * in the list of installed MIDI device providers, - * the first Receiver device with name - * "SunMIDI1" will be returned. If it cannot - * be found, the first Receiver from that provider - * will be returned, regardless of name. - * If there is none, the first Receiver with name - * "SunMIDI1" in the list of all devices - * (as returned by getMidiDeviceInfo) will be returned, - * or, if not found, the first Receiver that can - * be found in the list of all devices is returned. - * If that fails, too, a MidiUnavailableException - * is thrown. + * The property value consists of the provider class name and the device name, + * separated by the hash mark ("#"). The provider class name is the + * fully-qualified name of a concrete + * {@link MidiDeviceProvider MIDI device provider} class. The device name is + * matched against the {@code String} returned by the {@code getName} method of + * {@code MidiDevice.Info}. Either the class name, or the device name may be + * omitted. If only the class name is specified, the trailing hash mark is + * optional. + *

    + * If the provider class is specified, and it can be successfully retrieved from + * the installed providers, the list of {@code MidiDevice.Info} objects is + * retrieved from the provider. Otherwise, or when these devices do not provide + * a subsequent match, the list is retrieved from {@link #getMidiDeviceInfo} to + * contain all available {@code MidiDevice.Info} objects. + *

    + * If a device name is specified, the resulting list of {@code MidiDevice.Info} + * objects is searched: the first one with a matching name, and whose + * {@code MidiDevice} implements the respective interface, will be returned. If + * no matching {@code MidiDevice.Info} object is found, or the device name is + * not specified, the first suitable device from the resulting list will be + * returned. For Sequencer and Synthesizer, a device is suitable if it + * implements the respective interface; whereas for Receiver and Transmitter, a + * device is suitable if it implements neither Sequencer nor Synthesizer and + * provides at least one Receiver or Transmitter, respectively. + *

    + * For example, the property {@code javax.sound.midi.Receiver} with a value + * {@code "com.sun.media.sound.MidiProvider#SunMIDI1"} will have the following + * consequences when {@code getReceiver} is called: if the class + * {@code com.sun.media.sound.MidiProvider} exists in the list of installed MIDI + * device providers, the first {@code Receiver} device with name + * {@code "SunMIDI1"} will be returned. If it cannot be found, the first + * {@code Receiver} from that provider will be returned, regardless of name. If + * there is none, the first {@code Receiver} with name {@code "SunMIDI1"} in the + * list of all devices (as returned by {@code getMidiDeviceInfo}) will be + * returned, or, if not found, the first {@code Receiver} that can be found in + * the list of all devices is returned. If that fails, too, a + * {@code MidiUnavailableException} is thrown. * * @author Kara Kytle * @author Florian Bomers @@ -174,17 +151,15 @@ public class MidiSystem { private MidiSystem() { } - /** - * Obtains an array of information objects representing - * the set of all MIDI devices available on the system. - * A returned information object can then be used to obtain the - * corresponding device object, by invoking + * Obtains an array of information objects representing the set of all MIDI + * devices available on the system. A returned information object can then + * be used to obtain the corresponding device object, by invoking * {@link #getMidiDevice(MidiDevice.Info) getMidiDevice}. * - * @return an array of MidiDevice.Info objects, one - * for each installed MIDI device. If no such devices are installed, - * an array of length 0 is returned. + * @return an array of {@code MidiDevice.Info} objects, one for each + * installed MIDI device. If no such devices are installed, an array + * of length 0 is returned. */ public static MidiDevice.Info[] getMidiDeviceInfo() { List allInfos = new ArrayList<>(); @@ -201,16 +176,15 @@ public class MidiSystem { return infosArray; } - /** * Obtains the requested MIDI device. * - * @param info a device information object representing the desired device. + * @param info a device information object representing the desired device * @return the requested device * @throws MidiUnavailableException if the requested device is not available - * due to resource restrictions - * @throws IllegalArgumentException if the info object does not represent - * a MIDI device installed on the system + * due to resource restrictions + * @throws IllegalArgumentException if the info object does not represent a + * MIDI device installed on the system * @see #getMidiDeviceInfo */ public static MidiDevice getMidiDevice(MidiDevice.Info info) throws MidiUnavailableException { @@ -226,44 +200,38 @@ public class MidiSystem { throw new IllegalArgumentException("Requested device not installed: " + info); } - /** - * Obtains a MIDI receiver from an external MIDI port - * or other default device. - * The returned receiver always implements - * the {@code MidiDeviceReceiver} interface. - * - *

    If the system property - * javax.sound.midi.Receiver - * is defined or it is defined in the file "sound.properties", - * it is used to identify the device that provides the default receiver. - * For details, refer to the {@link MidiSystem class description}. - * - * If a suitable MIDI port is not available, the Receiver is - * retrieved from an installed synthesizer. - * - *

    If a native receiver provided by the default device does not implement - * the {@code MidiDeviceReceiver} interface, it will be wrapped in a - * wrapper class that implements the {@code MidiDeviceReceiver} interface. - * The corresponding {@code Receiver} method calls will be forwarded - * to the native receiver. - * - *

    If this method returns successfully, the {@link - * javax.sound.midi.MidiDevice MidiDevice} the - * Receiver belongs to is opened implicitly, if it is - * not already open. It is possible to close an implicitly opened - * device by calling {@link javax.sound.midi.Receiver#close close} - * on the returned Receiver. All open Receiver - * instances have to be closed in order to release system resources - * hold by the MidiDevice. For a - * detailed description of open/close behaviour see the class - * description of {@link javax.sound.midi.MidiDevice MidiDevice}. - * + * Obtains a MIDI receiver from an external MIDI port or other default + * device. The returned receiver always implements the + * {@code MidiDeviceReceiver} interface. + *

    + * If the system property {@code javax.sound.midi.Receiver} is defined or it + * is defined in the file "sound.properties", it is used to identify the + * device that provides the default receiver. For details, refer to the + * {@link MidiSystem class description}. + *

    + * If a suitable MIDI port is not available, the Receiver is retrieved from + * an installed synthesizer. + *

    + * If a native receiver provided by the default device does not implement + * the {@code MidiDeviceReceiver} interface, it will be wrapped in a wrapper + * class that implements the {@code MidiDeviceReceiver} interface. The + * corresponding {@code Receiver} method calls will be forwarded to the + * native receiver. + *

    + * If this method returns successfully, the {@link MidiDevice MidiDevice} + * the {@code Receiver} belongs to is opened implicitly, if it is not + * already open. It is possible to close an implicitly opened device by + * calling {@link Receiver#close close} on the returned {@code Receiver}. + * All open {@code Receiver} instances have to be closed in order to release + * system resources hold by the {@code MidiDevice}. For a detailed + * description of open/close behaviour see the class description of + * {@link MidiDevice MidiDevice}. * * @return the default MIDI receiver - * @throws MidiUnavailableException if the default receiver is not - * available due to resource restrictions, - * or no device providing receivers is installed in the system + * @throws MidiUnavailableException if the default receiver is not available + * due to resource restrictions, or no device providing receivers is + * installed in the system */ public static Receiver getReceiver() throws MidiUnavailableException { // may throw MidiUnavailableException @@ -280,41 +248,35 @@ public class MidiSystem { return receiver; } - /** - * Obtains a MIDI transmitter from an external MIDI port - * or other default source. - * The returned transmitter always implements - * the {@code MidiDeviceTransmitter} interface. - * - *

    If the system property - * javax.sound.midi.Transmitter - * is defined or it is defined in the file "sound.properties", - * it is used to identify the device that provides the default transmitter. - * For details, refer to the {@link MidiSystem class description}. - * - *

    If a native transmitter provided by the default device does not implement + * Obtains a MIDI transmitter from an external MIDI port or other default + * source. The returned transmitter always implements the + * {@code MidiDeviceTransmitter} interface. + *

    + * If the system property {@code javax.sound.midi.Transmitter} is defined or + * it is defined in the file "sound.properties", it is used to identify the + * device that provides the default transmitter. For details, refer to the + * {@link MidiSystem class description}. + *

    + * If a native transmitter provided by the default device does not implement * the {@code MidiDeviceTransmitter} interface, it will be wrapped in a - * wrapper class that implements the {@code MidiDeviceTransmitter} interface. - * The corresponding {@code Transmitter} method calls will be forwarded - * to the native transmitter. - * - *

    If this method returns successfully, the {@link - * javax.sound.midi.MidiDevice MidiDevice} the - * Transmitter belongs to is opened implicitly, if it - * is not already open. It is possible to close an implicitly - * opened device by calling {@link - * javax.sound.midi.Transmitter#close close} on the returned - * Transmitter. All open Transmitter - * instances have to be closed in order to release system resources - * hold by the MidiDevice. For a detailed description - * of open/close behaviour see the class description of {@link - * javax.sound.midi.MidiDevice MidiDevice}. + * wrapper class that implements the {@code MidiDeviceTransmitter} + * interface. The corresponding {@code Transmitter} method calls will be + * forwarded to the native transmitter. + *

    + * If this method returns successfully, the {@link MidiDevice MidiDevice} + * the {@code Transmitter} belongs to is opened implicitly, if it is not + * already open. It is possible to close an implicitly opened device by + * calling {@link Transmitter#close close} on the returned + * {@code Transmitter}. All open {@code Transmitter} instances have to be + * closed in order to release system resources hold by the + * {@code MidiDevice}. For a detailed description of open/close behaviour + * see the class description of {@link MidiDevice MidiDevice}. * * @return the default MIDI transmitter * @throws MidiUnavailableException if the default transmitter is not - * available due to resource restrictions, - * or no device providing transmitters is installed in the system + * available due to resource restrictions, or no device providing + * transmitters is installed in the system */ public static Transmitter getTransmitter() throws MidiUnavailableException { // may throw MidiUnavailableException @@ -331,59 +293,48 @@ public class MidiSystem { return transmitter; } - /** * Obtains the default synthesizer. - * - *

    If the system property - * javax.sound.midi.Synthesizer - * is defined or it is defined in the file "sound.properties", - * it is used to identify the default synthesizer. - * For details, refer to the {@link MidiSystem class description}. + *

    + * If the system property {@code javax.sound.midi.Synthesizer} is defined or + * it is defined in the file "sound.properties", it is used to identify the + * default synthesizer. For details, refer to the + * {@link MidiSystem class description}. * * @return the default synthesizer - * @throws MidiUnavailableException if the synthesizer is not - * available due to resource restrictions, - * or no synthesizer is installed in the system + * @throws MidiUnavailableException if the synthesizer is not available due + * to resource restrictions, or no synthesizer is installed in the + * system */ public static Synthesizer getSynthesizer() throws MidiUnavailableException { // may throw MidiUnavailableException return (Synthesizer) getDefaultDeviceWrapper(Synthesizer.class); } - /** - * Obtains the default Sequencer, connected to - * a default device. - * The returned Sequencer instance is - * connected to the default Synthesizer, - * as returned by {@link #getSynthesizer}. - * If there is no Synthesizer - * available, or the default Synthesizer - * cannot be opened, the sequencer is connected - * to the default Receiver, as returned - * by {@link #getReceiver}. - * The connection is made by retrieving a Transmitter - * instance from the Sequencer and setting its - * Receiver. - * Closing and re-opening the sequencer will restore the - * connection to the default device. - * - *

    This method is equivalent to calling - * getSequencer(true). - * - *

    If the system property - * javax.sound.midi.Sequencer - * is defined or it is defined in the file "sound.properties", - * it is used to identify the default sequencer. - * For details, refer to the {@link MidiSystem class description}. + * Obtains the default {@code Sequencer}, connected to a default device. The + * returned {@code Sequencer} instance is connected to the default + * {@code Synthesizer}, as returned by {@link #getSynthesizer}. If there is + * no {@code Synthesizer} available, or the default {@code Synthesizer} + * cannot be opened, the {@code sequencer} is connected to the default + * {@code Receiver}, as returned by {@link #getReceiver}. The connection is + * made by retrieving a {@code Transmitter} instance from the + * {@code Sequencer} and setting its {@code Receiver}. Closing and + * re-opening the sequencer will restore the connection to the default + * device. + *

    + * This method is equivalent to calling {@code getSequencer(true)}. + *

    + * If the system property {@code javax.sound.midi.Sequencer} is defined or + * it is defined in the file "sound.properties", it is used to identify the + * default sequencer. For details, refer to the + * {@link MidiSystem class description}. * * @return the default sequencer, connected to a default Receiver - * @throws MidiUnavailableException if the sequencer is not - * available due to resource restrictions, - * or there is no Receiver available by any - * installed MidiDevice, - * or no sequencer is installed in the system. + * @throws MidiUnavailableException if the sequencer is not available due to + * resource restrictions, or there is no {@code Receiver} available + * by any installed {@code MidiDevice}, or no sequencer is installed + * in the system * @see #getSequencer(boolean) * @see #getSynthesizer * @see #getReceiver @@ -392,49 +343,37 @@ public class MidiSystem { return getSequencer(true); } - - /** - * Obtains the default Sequencer, optionally - * connected to a default device. - * - *

    If connected is true, the returned - * Sequencer instance is - * connected to the default Synthesizer, - * as returned by {@link #getSynthesizer}. - * If there is no Synthesizer - * available, or the default Synthesizer - * cannot be opened, the sequencer is connected - * to the default Receiver, as returned - * by {@link #getReceiver}. - * The connection is made by retrieving a Transmitter - * instance from the Sequencer and setting its - * Receiver. - * Closing and re-opening the sequencer will restore the + * Obtains the default {@code Sequencer}, optionally connected to a default + * device. + *

    + * If {@code connected} is true, the returned {@code Sequencer} instance is + * connected to the default {@code Synthesizer}, as returned by + * {@link #getSynthesizer}. If there is no {@code Synthesizer} available, or + * the default {@code Synthesizer} cannot be opened, the {@code sequencer} + * is connected to the default {@code Receiver}, as returned by + * {@link #getReceiver}. The connection is made by retrieving a + * {@code Transmitter} instance from the {@code Sequencer} and setting its + * {@code Receiver}. Closing and re-opening the sequencer will restore the * connection to the default device. + *

    + * If {@code connected} is false, the returned {@code Sequencer} instance is + * not connected, it has no open {@code Transmitters}. In order to play the + * sequencer on a MIDI device, or a {@code Synthesizer}, it is necessary to + * get a {@code Transmitter} and set its {@code Receiver}. + *

    + * If the system property {@code javax.sound.midi.Sequencer} is defined or + * it is defined in the file "sound.properties", it is used to identify the + * default sequencer. For details, refer to the + * {@link MidiSystem class description}. * - *

    If connected is false, the returned - * Sequencer instance is not connected, it - * has no open Transmitters. In order to - * play the sequencer on a MIDI device, or a Synthesizer, - * it is necessary to get a Transmitter and set its - * Receiver. - * - *

    If the system property - * javax.sound.midi.Sequencer - * is defined or it is defined in the file "sound.properties", - * it is used to identify the default sequencer. - * For details, refer to the {@link MidiSystem class description}. - * - * @param connected whether or not the returned {@code Sequencer} - * is connected to the default {@code Synthesizer} + * @param connected whether or not the returned {@code Sequencer} is + * connected to the default {@code Synthesizer} * @return the default sequencer - * @throws MidiUnavailableException if the sequencer is not - * available due to resource restrictions, - * or no sequencer is installed in the system, - * or if connected is true, and there is - * no Receiver available by any installed - * MidiDevice + * @throws MidiUnavailableException if the sequencer is not available due to + * resource restrictions, or no sequencer is installed in the + * system, or if {@code connected} is true, and there is no + * {@code Receiver} available by any installed {@code MidiDevice} * @see #getSynthesizer * @see #getReceiver * @since 1.5 @@ -501,23 +440,20 @@ public class MidiSystem { return seq; } - - - /** - * Constructs a MIDI sound bank by reading it from the specified stream. - * The stream must point to - * a valid MIDI soundbank file. In general, MIDI soundbank providers may - * need to read some data from the stream before determining whether they - * support it. These parsers must - * be able to mark the stream, read enough data to determine whether they - * support the stream, and, if not, reset the stream's read pointer to - * its original position. If the input stream does not support this, - * this method may fail with an IOException. - * @param stream the source of the sound bank data. + * Constructs a MIDI sound bank by reading it from the specified stream. The + * stream must point to a valid MIDI soundbank file. In general, MIDI + * soundbank providers may need to read some data from the stream before + * determining whether they support it. These parsers must be able to mark + * the stream, read enough data to determine whether they support the + * stream, and, if not, reset the stream's read pointer to its original + * position. If the input stream does not support this, this method may fail + * with an {@code IOException}. + * + * @param stream the source of the sound bank data * @return the sound bank - * @throws InvalidMidiDataException if the stream does not point to - * valid MIDI soundbank data recognized by the system + * @throws InvalidMidiDataException if the stream does not point to valid + * MIDI soundbank data recognized by the system * @throws IOException if an I/O error occurred when loading the soundbank * @see InputStream#markSupported * @see InputStream#mark @@ -542,15 +478,14 @@ public class MidiSystem { } - /** - * Constructs a Soundbank by reading it from the specified URL. - * The URL must point to a valid MIDI soundbank file. + * Constructs a {@code Soundbank} by reading it from the specified URL. The + * URL must point to a valid MIDI soundbank file. * - * @param url the source of the sound bank data + * @param url the source of the sound bank data * @return the sound bank * @throws InvalidMidiDataException if the URL does not point to valid MIDI - * soundbank data recognized by the system + * soundbank data recognized by the system * @throws IOException if an I/O error occurred when loading the soundbank */ public static Soundbank getSoundbank(URL url) @@ -573,16 +508,14 @@ public class MidiSystem { } - /** - * Constructs a Soundbank by reading it from the specified - * File. - * The File must point to a valid MIDI soundbank file. + * Constructs a {@code Soundbank} by reading it from the specified + * {@code File}. The {@code File} must point to a valid MIDI soundbank file. * - * @param file the source of the sound bank data + * @param file the source of the sound bank data * @return the sound bank - * @throws InvalidMidiDataException if the File does not - * point to valid MIDI soundbank data recognized by the system + * @throws InvalidMidiDataException if the {@code File} does not point to + * valid MIDI soundbank data recognized by the system * @throws IOException if an I/O error occurred when loading the soundbank */ public static Soundbank getSoundbank(File file) @@ -604,35 +537,33 @@ public class MidiSystem { throw new InvalidMidiDataException("cannot get soundbank from stream"); } - - /** * Obtains the MIDI file format of the data in the specified input stream. * The stream must point to valid MIDI file data for a file type recognized * by the system. *

    * This method and/or the code it invokes may need to read some data from - * the stream to determine whether its data format is supported. The - * implementation may therefore - * need to mark the stream, read enough data to determine whether it is in - * a supported format, and reset the stream's read pointer to its original - * position. If the input stream does not permit this set of operations, - * this method may fail with an IOException. + * the stream to determine whether its data format is supported. The + * implementation may therefore need to mark the stream, read enough data to + * determine whether it is in a supported format, and reset the stream's + * read pointer to its original position. If the input stream does not + * permit this set of operations, this method may fail with an + * {@code IOException}. *

    * This operation can only succeed for files of a type which can be parsed - * by an installed file reader. It may fail with an InvalidMidiDataException - * even for valid files if no compatible file reader is installed. It - * will also fail with an InvalidMidiDataException if a compatible file reader - * is installed, but encounters errors while determining the file format. + * by an installed file reader. It may fail with an + * {@code InvalidMidiDataException} even for valid files if no compatible + * file reader is installed. It will also fail with an + * {@code InvalidMidiDataException} if a compatible file reader is + * installed, but encounters errors while determining the file format. * - * @param stream the input stream from which file format information - * should be extracted - * @return an MidiFileFormat object describing the MIDI file - * format + * @param stream the input stream from which file format information should + * be extracted + * @return an {@code MidiFileFormat} object describing the MIDI file format * @throws InvalidMidiDataException if the stream does not point to valid - * MIDI file data recognized by the system + * MIDI file data recognized by the system * @throws IOException if an I/O exception occurs while accessing the - * stream + * stream * @see #getMidiFileFormat(URL) * @see #getMidiFileFormat(File) * @see InputStream#markSupported @@ -661,26 +592,24 @@ public class MidiSystem { } } - /** - * Obtains the MIDI file format of the data in the specified URL. The URL - * must point to valid MIDI file data for a file type recognized - * by the system. + * Obtains the MIDI file format of the data in the specified URL. The URL + * must point to valid MIDI file data for a file type recognized by the + * system. *

    * This operation can only succeed for files of a type which can be parsed - * by an installed file reader. It may fail with an InvalidMidiDataException - * even for valid files if no compatible file reader is installed. It - * will also fail with an InvalidMidiDataException if a compatible file reader - * is installed, but encounters errors while determining the file format. + * by an installed file reader. It may fail with an + * {@code InvalidMidiDataException} even for valid files if no compatible + * file reader is installed. It will also fail with an + * {@code InvalidMidiDataException} if a compatible file reader is + * installed, but encounters errors while determining the file format. * - * @param url the URL from which file format information should be - * extracted - * @return a MidiFileFormat object describing the MIDI file - * format + * @param url the URL from which file format information should be + * extracted + * @return a {@code MidiFileFormat} object describing the MIDI file format * @throws InvalidMidiDataException if the URL does not point to valid MIDI - * file data recognized by the system + * file data recognized by the system * @throws IOException if an I/O exception occurs while accessing the URL - * * @see #getMidiFileFormat(InputStream) * @see #getMidiFileFormat(File) */ @@ -707,26 +636,24 @@ public class MidiSystem { } } - /** - * Obtains the MIDI file format of the specified File. The - * File must point to valid MIDI file data for a file type + * Obtains the MIDI file format of the specified {@code File}. The + * {@code File} must point to valid MIDI file data for a file type * recognized by the system. *

    * This operation can only succeed for files of a type which can be parsed - * by an installed file reader. It may fail with an InvalidMidiDataException - * even for valid files if no compatible file reader is installed. It - * will also fail with an InvalidMidiDataException if a compatible file reader - * is installed, but encounters errors while determining the file format. + * by an installed file reader. It may fail with an + * {@code InvalidMidiDataException} even for valid files if no compatible + * file reader is installed. It will also fail with an + * {@code InvalidMidiDataException} if a compatible file reader is + * installed, but encounters errors while determining the file format. * - * @param file the File from which file format information - * should be extracted - * @return a MidiFileFormat object describing the MIDI file - * format - * @throws InvalidMidiDataException if the File does not point - * to valid MIDI file data recognized by the system + * @param file the {@code File} from which file format information should + * be extracted + * @return a {@code MidiFileFormat} object describing the MIDI file format + * @throws InvalidMidiDataException if the {@code File} does not point to + * valid MIDI file data recognized by the system * @throws IOException if an I/O exception occurs while accessing the file - * * @see #getMidiFileFormat(InputStream) * @see #getMidiFileFormat(URL) */ @@ -753,35 +680,33 @@ public class MidiSystem { } } - /** - * Obtains a MIDI sequence from the specified input stream. The stream must - * point to valid MIDI file data for a file type recognized - * by the system. + * Obtains a MIDI sequence from the specified input stream. The stream must + * point to valid MIDI file data for a file type recognized by the system. *

    - * This method and/or the code it invokes may need to read some data - * from the stream to determine whether - * its data format is supported. The implementation may therefore - * need to mark the stream, read enough data to determine whether it is in - * a supported format, and reset the stream's read pointer to its original - * position. If the input stream does not permit this set of operations, - * this method may fail with an IOException. + * This method and/or the code it invokes may need to read some data from + * the stream to determine whether its data format is supported. The + * implementation may therefore need to mark the stream, read enough data to + * determine whether it is in a supported format, and reset the stream's + * read pointer to its original position. If the input stream does not + * permit this set of operations, this method may fail with an + * {@code IOException}. *

    * This operation can only succeed for files of a type which can be parsed - * by an installed file reader. It may fail with an InvalidMidiDataException - * even for valid files if no compatible file reader is installed. It - * will also fail with an InvalidMidiDataException if a compatible file reader - * is installed, but encounters errors while constructing the Sequence + * by an installed file reader. It may fail with an + * {@code InvalidMidiDataException} even for valid files if no compatible + * file reader is installed. It will also fail with an + * {@code InvalidMidiDataException} if a compatible file reader is + * installed, but encounters errors while constructing the {@code Sequence} * object from the file data. * - * @param stream the input stream from which the Sequence - * should be constructed - * @return a Sequence object based on the MIDI file data - * contained in the input stream - * @throws InvalidMidiDataException if the stream does not point to - * valid MIDI file data recognized by the system - * @throws IOException if an I/O exception occurs while accessing the - * stream + * @param stream the input stream from which the {@code Sequence} should be + * constructed + * @return a {@code Sequence} object based on the MIDI file data contained + * in the input stream + * @throws InvalidMidiDataException if the stream does not point to valid + * MIDI file data recognized by the system + * @throws IOException if an I/O exception occurs while accessing the stream * @see InputStream#markSupported * @see InputStream#mark */ @@ -808,25 +733,23 @@ public class MidiSystem { } } - /** - * Obtains a MIDI sequence from the specified URL. The URL must - * point to valid MIDI file data for a file type recognized - * by the system. + * Obtains a MIDI sequence from the specified URL. The URL must point to + * valid MIDI file data for a file type recognized by the system. *

    * This operation can only succeed for files of a type which can be parsed - * by an installed file reader. It may fail with an InvalidMidiDataException - * even for valid files if no compatible file reader is installed. It - * will also fail with an InvalidMidiDataException if a compatible file reader - * is installed, but encounters errors while constructing the Sequence + * by an installed file reader. It may fail with an + * {@code InvalidMidiDataException} even for valid files if no compatible + * file reader is installed. It will also fail with an + * {@code InvalidMidiDataException} if a compatible file reader is + * installed, but encounters errors while constructing the {@code Sequence} * object from the file data. * - * @param url the URL from which the Sequence should be - * constructed - * @return a Sequence object based on the MIDI file data - * pointed to by the URL + * @param url the URL from which the {@code Sequence} should be constructed + * @return a {@code Sequence} object based on the MIDI file data pointed to + * by the URL * @throws InvalidMidiDataException if the URL does not point to valid MIDI - * file data recognized by the system + * file data recognized by the system * @throws IOException if an I/O exception occurs while accessing the URL */ public static Sequence getSequence(URL url) @@ -852,25 +775,25 @@ public class MidiSystem { } } - /** - * Obtains a MIDI sequence from the specified File. - * The File must point to valid MIDI file data - * for a file type recognized by the system. + * Obtains a MIDI sequence from the specified {@code File}. The {@code File} + * must point to valid MIDI file data for a file type recognized by the + * system. *

    * This operation can only succeed for files of a type which can be parsed - * by an installed file reader. It may fail with an InvalidMidiDataException - * even for valid files if no compatible file reader is installed. It - * will also fail with an InvalidMidiDataException if a compatible file reader - * is installed, but encounters errors while constructing the Sequence + * by an installed file reader. It may fail with an + * {@code InvalidMidiDataException} even for valid files if no compatible + * file reader is installed. It will also fail with an + * {@code InvalidMidiDataException} if a compatible file reader is + * installed, but encounters errors while constructing the {@code Sequence} * object from the file data. * - * @param file the File from which the Sequence - * should be constructed - * @return a Sequence object based on the MIDI file data - * pointed to by the File + * @param file the {@code File} from which the {@code Sequence} should be + * constructed + * @return a {@code Sequence} object based on the MIDI file data pointed to + * by the File * @throws InvalidMidiDataException if the File does not point to valid MIDI - * file data recognized by the system + * file data recognized by the system * @throws IOException if an I/O exception occurs */ public static Sequence getSequence(File file) @@ -896,12 +819,12 @@ public class MidiSystem { } } - /** * Obtains the set of MIDI file types for which file writing support is * provided by the system. - * @return array of unique file types. If no file types are supported, - * an array of length 0 is returned. + * + * @return array of unique file types. If no file types are supported, an + * array of length 0 is returned. */ public static int[] getMidiFileTypes() { @@ -927,13 +850,13 @@ public class MidiSystem { return resultTypes; } - /** * Indicates whether file writing support for the specified MIDI file type * is provided by the system. - * @param fileType the file type for which write capabilities are queried - * @return true if the file type is supported, - * otherwise false + * + * @param fileType the file type for which write capabilities are queried + * @return {@code true} if the file type is supported, otherwise + * {@code false} */ public static boolean isFileTypeSupported(int fileType) { @@ -948,14 +871,13 @@ public class MidiSystem { return false; } - /** * Obtains the set of MIDI file types that the system can write from the * sequence specified. - * @param sequence the sequence for which MIDI file type support - * is queried - * @return the set of unique supported file types. If no file types are supported, - * returns an array of length 0. + * + * @param sequence the sequence for which MIDI file type support is queried + * @return the set of unique supported file types. If no file types are + * supported, returns an array of length 0. */ public static int[] getMidiFileTypes(Sequence sequence) { @@ -981,15 +903,14 @@ public class MidiSystem { return resultTypes; } - /** * Indicates whether a MIDI file of the file type specified can be written * from the sequence indicated. - * @param fileType the file type for which write capabilities - * are queried - * @param sequence the sequence for which file writing support is queried - * @return true if the file type is supported for this - * sequence, otherwise false + * + * @param fileType the file type for which write capabilities are queried + * @param sequence the sequence for which file writing support is queried + * @return {@code true} if the file type is supported for this sequence, + * otherwise {@code false} */ public static boolean isFileTypeSupported(int fileType, Sequence sequence) { @@ -1004,19 +925,20 @@ public class MidiSystem { return false; } - /** * Writes a stream of bytes representing a file of the MIDI file type * indicated to the output stream provided. - * @param in sequence containing MIDI data to be written to the file - * @param fileType the file type of the file to be written to the output stream - * @param out stream to which the file data should be written + * + * @param in sequence containing MIDI data to be written to the file + * @param fileType the file type of the file to be written to the output + * stream + * @param out stream to which the file data should be written * @return the number of bytes written to the output stream * @throws IOException if an I/O exception occurs * @throws IllegalArgumentException if the file format is not supported by - * the system + * the system * @see #isFileTypeSupported(int, Sequence) - * @see #getMidiFileTypes(Sequence) + * @see #getMidiFileTypes(Sequence) */ public static int write(Sequence in, int fileType, OutputStream out) throws IOException { @@ -1038,19 +960,19 @@ public class MidiSystem { return bytesWritten; } - /** * Writes a stream of bytes representing a file of the MIDI file type * indicated to the external file provided. - * @param in sequence containing MIDI data to be written to the file - * @param type the file type of the file to be written to the output stream - * @param out external file to which the file data should be written + * + * @param in sequence containing MIDI data to be written to the file + * @param type the file type of the file to be written to the output stream + * @param out external file to which the file data should be written * @return the number of bytes written to the file * @throws IOException if an I/O exception occurs - * @throws IllegalArgumentException if the file type is not supported by - * the system + * @throws IllegalArgumentException if the file type is not supported by the + * system * @see #isFileTypeSupported(int, Sequence) - * @see #getMidiFileTypes(Sequence) + * @see #getMidiFileTypes(Sequence) */ public static int write(Sequence in, int type, File out) throws IOException { @@ -1072,8 +994,6 @@ public class MidiSystem { return bytesWritten; } - - // HELPER METHODS @SuppressWarnings("unchecked") private static List getMidiDeviceProviders() { @@ -1095,19 +1015,16 @@ public class MidiSystem { return (List) getProviders(MidiFileReader.class); } - - /** Attempts to locate and return a default MidiDevice of the specified - * type. - * + /** + * Attempts to locate and return a default MidiDevice of the specified type. * This method wraps {@link #getDefaultDevice}. It catches the - * IllegalArgumentException thrown by - * getDefaultDevice and instead throws a - * MidiUnavailableException, with the catched + * {@code IllegalArgumentException} thrown by {@code getDefaultDevice} and + * instead throws a {@code MidiUnavailableException}, with the catched * exception chained. * - * @param deviceClass The requested device type, one of Synthesizer.class, - * Sequencer.class, Receiver.class or Transmitter.class. - * @throws MidiUnavalableException on failure. + * @param deviceClass The requested device type, one of Synthesizer.class, + * Sequencer.class, Receiver.class or Transmitter.class + * @throws MidiUnavailableException on failure */ private static MidiDevice getDefaultDeviceWrapper(Class deviceClass) throws MidiUnavailableException{ @@ -1120,13 +1037,12 @@ public class MidiSystem { } } - - /** Attempts to locate and return a default MidiDevice of the specified - * type. + /** + * Attempts to locate and return a default MidiDevice of the specified type. * - * @param deviceClass The requested device type, one of Synthesizer.class, - * Sequencer.class, Receiver.class or Transmitter.class. - * @throws IllegalArgumentException on failure. + * @param deviceClass The requested device type, one of Synthesizer.class, + * Sequencer.class, Receiver.class or Transmitter.class + * @throws IllegalArgumentException on failure */ private static MidiDevice getDefaultDevice(Class deviceClass) { List providers = getMidiDeviceProviders(); @@ -1169,16 +1085,15 @@ public class MidiSystem { throw new IllegalArgumentException("Requested device not installed"); } - - - /** Return a MidiDeviceProcider of a given class from the list of - MidiDeviceProviders. - - @param providerClassName The class name of the provider to be returned. - @param provider The list of MidiDeviceProviders that is searched. - @return A MidiDeviceProvider of the requested class, or null if none - is found. - */ + /** + * Return a MidiDeviceProvider of a given class from the list of + * MidiDeviceProviders. + * + * @param providerClassName The class name of the provider to be returned + * @param providers The list of MidiDeviceProviders that is searched + * @return A MidiDeviceProvider of the requested class, or null if none is + * found + */ private static MidiDeviceProvider getNamedProvider(String providerClassName, List providers) { for(int i = 0; i < providers.size(); i++) { @@ -1190,15 +1105,15 @@ public class MidiSystem { return null; } - - /** Return a MidiDevice with a given name from a given MidiDeviceProvider. - @param deviceName The name of the MidiDevice to be returned. - @param provider The MidiDeviceProvider to check for MidiDevices. - @param deviceClass The requested device type, one of Synthesizer.class, - Sequencer.class, Receiver.class or Transmitter.class. - - @return A MidiDevice matching the requirements, or null if none is found. - */ + /** + * Return a MidiDevice with a given name from a given MidiDeviceProvider. + * + * @param deviceName The name of the MidiDevice to be returned + * @param provider The MidiDeviceProvider to check for MidiDevices + * @param deviceClass The requested device type, one of Synthesizer.class, + * Sequencer.class, Receiver.class or Transmitter.class + * @return A MidiDevice matching the requirements, or null if none is found + */ private static MidiDevice getNamedDevice(String deviceName, MidiDeviceProvider provider, Class deviceClass) { @@ -1222,14 +1137,14 @@ public class MidiSystem { return null; } - - /** Return a MidiDevice with a given name from a given MidiDeviceProvider. - @param deviceName The name of the MidiDevice to be returned. - @param provider The MidiDeviceProvider to check for MidiDevices. - @param deviceClass The requested device type, one of Synthesizer.class, - Sequencer.class, Receiver.class or Transmitter.class. - - @return A MidiDevice matching the requirements, or null if none is found. + /** + * Return a MidiDevice with a given name from a given MidiDeviceProvider. + * + * @param deviceName The name of the MidiDevice to be returned + * @param provider The MidiDeviceProvider to check for MidiDevices + * @param deviceClass The requested device type, one of Synthesizer.class, + * Sequencer.class, Receiver.class or Transmitter.class + * @return A MidiDevice matching the requirements, or null if none is found */ private static MidiDevice getNamedDevice(String deviceName, MidiDeviceProvider provider, @@ -1249,16 +1164,16 @@ public class MidiSystem { return null; } - - /** Return a MidiDevice with a given name from a list of - MidiDeviceProviders. - @param deviceName The name of the MidiDevice to be returned. - @param providers The List of MidiDeviceProviders to check for - MidiDevices. - @param deviceClass The requested device type, one of Synthesizer.class, - Sequencer.class, Receiver.class or Transmitter.class. - @return A Mixer matching the requirements, or null if none is found. - */ + /** + * Return a MidiDevice with a given name from a list of MidiDeviceProviders. + * + * @param deviceName The name of the MidiDevice to be returned + * @param providers The List of MidiDeviceProviders to check for + * MidiDevices + * @param deviceClass The requested device type, one of Synthesizer.class, + * Sequencer.class, Receiver.class or Transmitter.class + * @return A Mixer matching the requirements, or null if none is found + */ private static MidiDevice getNamedDevice(String deviceName, List providers, Class deviceClass) { @@ -1282,15 +1197,15 @@ public class MidiSystem { return null; } - - /** Return a MidiDevice with a given name from a list of - MidiDeviceProviders. - @param deviceName The name of the MidiDevice to be returned. - @param providers The List of MidiDeviceProviders to check for - MidiDevices. - @param deviceClass The requested device type, one of Synthesizer.class, - Sequencer.class, Receiver.class or Transmitter.class. - @return A Mixer matching the requirements, or null if none is found. + /** + * Return a MidiDevice with a given name from a list of MidiDeviceProviders. + * + * @param deviceName The name of the MidiDevice to be returned + * @param providers The List of MidiDeviceProviders to check for + * MidiDevices + * @param deviceClass The requested device type, one of Synthesizer.class, + * Sequencer.class, Receiver.class or Transmitter.class + * @return A Mixer matching the requirements, or null if none is found */ private static MidiDevice getNamedDevice(String deviceName, List providers, @@ -1310,14 +1225,15 @@ public class MidiSystem { return null; } - - /** From a given MidiDeviceProvider, return the first appropriate device. - @param provider The MidiDeviceProvider to check for MidiDevices. - @param deviceClass The requested device type, one of Synthesizer.class, - Sequencer.class, Receiver.class or Transmitter.class. - @return A MidiDevice is considered appropriate, or null if no - appropriate device is found. - */ + /** + * From a given MidiDeviceProvider, return the first appropriate device. + * + * @param provider The MidiDeviceProvider to check for MidiDevices + * @param deviceClass The requested device type, one of Synthesizer.class, + * Sequencer.class, Receiver.class or Transmitter.class + * @return A MidiDevice is considered appropriate, or null if no appropriate + * device is found + */ private static MidiDevice getFirstDevice(MidiDeviceProvider provider, Class deviceClass) { MidiDevice device; @@ -1340,13 +1256,14 @@ public class MidiSystem { return null; } - - /** From a given MidiDeviceProvider, return the first appropriate device. - @param provider The MidiDeviceProvider to check for MidiDevices. - @param deviceClass The requested device type, one of Synthesizer.class, - Sequencer.class, Receiver.class or Transmitter.class. - @return A MidiDevice is considered appropriate, or null if no - appropriate device is found. + /** + * From a given MidiDeviceProvider, return the first appropriate device. + * + * @param provider The MidiDeviceProvider to check for MidiDevices + * @param deviceClass The requested device type, one of Synthesizer.class, + * Sequencer.class, Receiver.class or Transmitter.class + * @return A MidiDevice is considered appropriate, or null if no appropriate + * device is found */ private static MidiDevice getFirstDevice(MidiDeviceProvider provider, Class deviceClass, @@ -1363,15 +1280,16 @@ public class MidiSystem { return null; } - - /** From a List of MidiDeviceProviders, return the first appropriate - MidiDevice. - @param providers The List of MidiDeviceProviders to search. - @param deviceClass The requested device type, one of Synthesizer.class, - Sequencer.class, Receiver.class or Transmitter.class. - @return A MidiDevice that is considered appropriate, or null - if none is found. - */ + /** + * From a List of MidiDeviceProviders, return the first appropriate + * MidiDevice. + * + * @param providers The List of MidiDeviceProviders to search + * @param deviceClass The requested device type, one of Synthesizer.class, + * Sequencer.class, Receiver.class or Transmitter.class + * @return A MidiDevice that is considered appropriate, or null if none is + * found + */ private static MidiDevice getFirstDevice(List providers, Class deviceClass) { MidiDevice device; @@ -1394,14 +1312,15 @@ public class MidiSystem { return null; } - - /** From a List of MidiDeviceProviders, return the first appropriate - MidiDevice. - @param providers The List of MidiDeviceProviders to search. - @param deviceClass The requested device type, one of Synthesizer.class, - Sequencer.class, Receiver.class or Transmitter.class. - @return A MidiDevice that is considered appropriate, or null - if none is found. + /** + * From a List of MidiDeviceProviders, return the first appropriate + * MidiDevice. + * + * @param providers The List of MidiDeviceProviders to search + * @param deviceClass The requested device type, one of Synthesizer.class, + * Sequencer.class, Receiver.class or Transmitter.class + * @return A MidiDevice that is considered appropriate, or null if none is + * found */ private static MidiDevice getFirstDevice(List providers, Class deviceClass, @@ -1419,28 +1338,29 @@ public class MidiSystem { return null; } - - /** Checks if a MidiDevice is appropriate. - If deviceClass is Synthesizer or Sequencer, a device implementing - the respective interface is considered appropriate. If deviceClass - is Receiver or Transmitter, a device is considered appropriate if - it implements neither Synthesizer nor Transmitter, and if it can - provide at least one Receiver or Transmitter, respectively. - - @param device the MidiDevice to test - @param allowSynthesizer if true, Synthesizers are considered - appropriate. Otherwise only pure MidiDevices are considered - appropriate (unless allowSequencer is true). This flag only has an - effect for deviceClass Receiver and Transmitter. For other device - classes (Sequencer and Synthesizer), this flag has no effect. - @param allowSequencer if true, Sequencers are considered - appropriate. Otherwise only pure MidiDevices are considered - appropriate (unless allowSynthesizer is true). This flag only has an - effect for deviceClass Receiver and Transmitter. For other device - classes (Sequencer and Synthesizer), this flag has no effect. - @return true if the device is considered appropriate according to the - rules given above, false otherwise. - */ + /** + * Checks if a MidiDevice is appropriate. If deviceClass is Synthesizer or + * Sequencer, a device implementing the respective interface is considered + * appropriate. If deviceClass is Receiver or Transmitter, a device is + * considered appropriate if it implements neither Synthesizer nor + * Transmitter, and if it can provide at least one Receiver or Transmitter, + * respectively. + * + * @param device the MidiDevice to test + * @param allowSynthesizer if true, Synthesizers are considered + * appropriate. Otherwise only pure MidiDevices are considered + * appropriate (unless allowSequencer is true). This flag only has + * an effect for deviceClass Receiver and Transmitter. For other + * device classes (Sequencer and Synthesizer), this flag has no + * effect. + * @param allowSequencer if true, Sequencers are considered appropriate. + * Otherwise only pure MidiDevices are considered appropriate + * (unless allowSynthesizer is true). This flag only has an effect + * for deviceClass Receiver and Transmitter. For other device + * classes (Sequencer and Synthesizer), this flag has no effect. + * @return true if the device is considered appropriate according to the + * rules given above, false otherwise + */ private static boolean isAppropriateDevice(MidiDevice device, Class deviceClass, boolean allowSynthesizer, @@ -1473,12 +1393,12 @@ public class MidiSystem { return false; } - /** - * Obtains the set of services currently installed on the system - * using the SPI mechanism in 1.3. - * @return a List of instances of providers for the requested service. - * If no providers are available, a List of length 0 will be returned. + * Obtains the set of services currently installed on the system using the + * SPI mechanism in 1.3. + * + * @return a List of instances of providers for the requested service. If no + * providers are available, a List of length 0 will be returned. */ private static List getProviders(Class providerClass) { return JDK13Services.getProviders(providerClass); diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiUnavailableException.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiUnavailableException.java index 85ace347d8b..b52fac8d813 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiUnavailableException.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiUnavailableException.java @@ -25,39 +25,37 @@ package javax.sound.midi; - /** - * A MidiUnavailableException is thrown when a requested MIDI - * component cannot be opened or created because it is unavailable. This often - * occurs when a device is in use by another application. More generally, it - * can occur when there is a finite number of a certain kind of resource that can - * be used for some purpose, and all of them are already in use (perhaps all by - * this application). For an example of the latter case, see the + * A {@code MidiUnavailableException} is thrown when a requested MIDI component + * cannot be opened or created because it is unavailable. This often occurs when + * a device is in use by another application. More generally, it can occur when + * there is a finite number of a certain kind of resource that can be used for + * some purpose, and all of them are already in use (perhaps all by this + * application). For an example of the latter case, see the * {@link Transmitter#setReceiver(Receiver) setReceiver} method of - * Transmitter. + * {@code Transmitter}. * * @author Kara Kytle */ public class MidiUnavailableException extends Exception { + private static final long serialVersionUID = 6093809578628944323L; /** - * Constructs a MidiUnavailableException that has - * null as its error detail message. + * Constructs a {@code MidiUnavailableException} that has {@code null} as + * its error detail message. */ public MidiUnavailableException() { - super(); } /** - * Constructs a MidiUnavailableException with the - * specified detail message. + * Constructs a {@code MidiUnavailableException} with the specified detail + * message. * - * @param message the string to display as an error detail message + * @param message the string to display as an error detail message */ - public MidiUnavailableException(String message) { - + public MidiUnavailableException(final String message) { super(message); } } diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/Patch.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/Patch.java index d8bc7cf1b4a..f1e438200b9 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/Patch.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/Patch.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -25,88 +25,77 @@ package javax.sound.midi; - /** - * A Patch object represents a location, on a MIDI - * synthesizer, into which a single instrument is stored (loaded). - * Every Instrument object has its own Patch - * object that specifies the memory location - * into which that instrument should be loaded. The - * location is specified abstractly by a bank index and a program number (not by - * any scheme that directly refers to a specific address or offset in RAM). - * This is a hierarchical indexing scheme: MIDI provides for up to 16384 banks, - * each of which contains up to 128 program locations. For example, a - * minimal sort of synthesizer might have only one bank of instruments, and - * only 32 instruments (programs) in that bank. + * A {@code Patch} object represents a location, on a MIDI synthesizer, into + * which a single instrument is stored (loaded). Every {@code Instrument} object + * has its own {@code Patch} object that specifies the memory location into + * which that instrument should be loaded. The location is specified abstractly + * by a bank index and a program number (not by any scheme that directly refers + * to a specific address or offset in RAM). This is a hierarchical indexing + * scheme: MIDI provides for up to 16384 banks, each of which contains up to 128 + * program locations. For example, a minimal sort of synthesizer might have only + * one bank of instruments, and only 32 instruments (programs) in that bank. *

    - * To select what instrument should play the notes on a particular MIDI - * channel, two kinds of MIDI message are used that specify a patch location: - * a bank-select command, and a program-change channel command. The Java Sound + * To select what instrument should play the notes on a particular MIDI channel, + * two kinds of MIDI message are used that specify a patch location: a + * bank-select command, and a program-change channel command. The Java Sound * equivalent is the - * {@link MidiChannel#programChange(int, int) programChange(int, int)} - * method of MidiChannel. + * {@link MidiChannel#programChange(int, int) programChange(int, int)} method of + * {@code MidiChannel}. * + * @author Kara Kytle * @see Instrument * @see Instrument#getPatch() * @see MidiChannel#programChange(int, int) * @see Synthesizer#loadInstruments(Soundbank, Patch[]) * @see Soundbank * @see Sequence#getPatchList() - * - * @author Kara Kytle */ - public class Patch { - /** - * Bank index + * Bank index. */ private final int bank; - /** - * Program change number + * Program change number. */ private final int program; - /** * Constructs a new patch object from the specified bank and program * numbers. - * @param bank the bank index (in the range from 0 to 16383) - * @param program the program index (in the range from 0 to 127) + * + * @param bank the bank index (in the range from 0 to 16383) + * @param program the program index (in the range from 0 to 127) */ public Patch(int bank, int program) { - this.bank = bank; this.program = program; } - /** - * Returns the number of the bank that contains the instrument - * whose location this Patch specifies. + * Returns the number of the bank that contains the instrument whose + * location this {@code Patch} specifies. + * * @return the bank number, whose range is from 0 to 16383 * @see MidiChannel#programChange(int, int) */ public int getBank() { - return bank; } - /** - * Returns the index, within - * a bank, of the instrument whose location this Patch specifies. - * @return the instrument's program number, whose range is from 0 to 127 + * Returns the index, within a bank, of the instrument whose location this + * {@code Patch} specifies. * + * @return the instrument's program number, whose range is from 0 to 127 * @see MidiChannel#getProgram * @see MidiChannel#programChange(int) * @see MidiChannel#programChange(int, int) */ public int getProgram() { - return program; } } diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/Receiver.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/Receiver.java index 9df0a5d7153..55e038cfa86 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/Receiver.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/Receiver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -25,50 +25,46 @@ package javax.sound.midi; - /** - * A Receiver receives {@link MidiEvent} objects and - * typically does something useful in response, such as interpreting them to - * generate sound or raw MIDI output. Common MIDI receivers include - * synthesizers and MIDI Out ports. + * A {@code Receiver} receives {@link MidiEvent} objects and typically does + * something useful in response, such as interpreting them to generate sound or + * raw MIDI output. Common MIDI receivers include synthesizers and MIDI Out + * ports. * + * @author Kara Kytle * @see MidiDevice * @see Synthesizer * @see Transmitter - * - * @author Kara Kytle */ public interface Receiver extends AutoCloseable { - //$$fb 2002-04-12: fix for 4662090: Contradiction in Receiver specification + /** - * Sends a MIDI message and time-stamp to this receiver. - * If time-stamping is not supported by this receiver, the time-stamp - * value should be -1. - * @param message the MIDI message to send - * @param timeStamp the time-stamp for the message, in microseconds. + * Sends a MIDI message and time-stamp to this receiver. If time-stamping is + * not supported by this receiver, the time-stamp value should be -1. + * + * @param message the MIDI message to send + * @param timeStamp the time-stamp for the message, in microseconds * @throws IllegalStateException if the receiver is closed */ - public void send(MidiMessage message, long timeStamp); + void send(MidiMessage message, long timeStamp); /** - * Indicates that the application has finished using the receiver, and - * that limited resources it requires may be released or made available. - * - *

    If the creation of this Receiver resulted in - * implicitly opening the underlying device, the device is - * implicitly closed by this method. This is true unless the device is - * kept open by other Receiver or Transmitter - * instances that opened the device implicitly, and unless the device - * has been opened explicitly. If the device this - * Receiver is retrieved from is closed explicitly by - * calling {@link MidiDevice#close MidiDevice.close}, the - * Receiver is closed, too. For a detailed - * description of open/close behaviour see the class description - * of {@link javax.sound.midi.MidiDevice MidiDevice}. + * Indicates that the application has finished using the receiver, and that + * limited resources it requires may be released or made available. + *

    + * If the creation of this {@code Receiver} resulted in implicitly opening + * the underlying device, the device is implicitly closed by this method. + * This is true unless the device is kept open by other {@code Receiver} or + * {@code Transmitter} instances that opened the device implicitly, and + * unless the device has been opened explicitly. If the device this + * {@code Receiver} is retrieved from is closed explicitly by calling + * {@link MidiDevice#close MidiDevice.close}, the {@code Receiver} is + * closed, too. For a detailed description of open/close behaviour see the + * class description of {@link MidiDevice MidiDevice}. * * @see javax.sound.midi.MidiSystem#getReceiver */ - public void close(); + void close(); } diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/Sequence.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/Sequence.java index 14cb66110ed..3dd0ca5801c 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/Sequence.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/Sequence.java @@ -26,72 +26,77 @@ package javax.sound.midi; import java.util.Vector; -import com.sun.media.sound.MidiUtils; - /** - * A Sequence is a data structure containing musical - * information (often an entire song or composition) that can be played - * back by a {@link Sequencer} object. Specifically, the - * Sequence contains timing - * information and one or more tracks. Each {@link Track track} consists of a - * series of MIDI events (such as note-ons, note-offs, program changes, and meta-events). - * The sequence's timing information specifies the type of unit that is used - * to time-stamp the events in the sequence. + * A {@code Sequence} is a data structure containing musical information (often + * an entire song or composition) that can be played back by a {@link Sequencer} + * object. Specifically, the {@code Sequence} contains timing information and + * one or more tracks. Each {@link Track track} consists of a series of MIDI + * events (such as note-ons, note-offs, program changes, and meta-events). The + * sequence's timing information specifies the type of unit that is used to + * time-stamp the events in the sequence. *

    - * A Sequence can be created from a MIDI file by reading the file - * into an input stream and invoking one of the getSequence methods of - * {@link MidiSystem}. A sequence can also be built from scratch by adding new - * Tracks to an empty Sequence, and adding - * {@link MidiEvent} objects to these Tracks. + * A {@code Sequence} can be created from a MIDI file by reading the file into + * an input stream and invoking one of the {@code getSequence} methods of + * {@link MidiSystem}. A sequence can also be built from scratch by adding new + * {@code Tracks} to an empty {@code Sequence}, and adding {@link MidiEvent} + * objects to these {@code Tracks}. * + * @author Kara Kytle * @see Sequencer#setSequence(java.io.InputStream stream) * @see Sequencer#setSequence(Sequence sequence) * @see Track#add(MidiEvent) * @see MidiFileFormat - * - * @author Kara Kytle */ public class Sequence { - // Timing types /** - * The tempo-based timing type, for which the resolution is expressed in pulses (ticks) per quarter note. + * The tempo-based timing type, for which the resolution is expressed in + * pulses (ticks) per quarter note. + * * @see #Sequence(float, int) */ public static final float PPQ = 0.0f; /** - * The SMPTE-based timing type with 24 frames per second (resolution is expressed in ticks per frame). + * The SMPTE-based timing type with 24 frames per second (resolution is + * expressed in ticks per frame). + * * @see #Sequence(float, int) */ public static final float SMPTE_24 = 24.0f; /** - * The SMPTE-based timing type with 25 frames per second (resolution is expressed in ticks per frame). + * The SMPTE-based timing type with 25 frames per second (resolution is + * expressed in ticks per frame). + * * @see #Sequence(float, int) */ public static final float SMPTE_25 = 25.0f; /** - * The SMPTE-based timing type with 29.97 frames per second (resolution is expressed in ticks per frame). + * The SMPTE-based timing type with 29.97 frames per second (resolution is + * expressed in ticks per frame). + * * @see #Sequence(float, int) */ public static final float SMPTE_30DROP = 29.97f; /** - * The SMPTE-based timing type with 30 frames per second (resolution is expressed in ticks per frame). + * The SMPTE-based timing type with 30 frames per second (resolution is + * expressed in ticks per frame). + * * @see #Sequence(float, int) */ public static final float SMPTE_30 = 30.0f; - // Variables /** * The timing division type of the sequence. + * * @see #PPQ * @see #SMPTE_24 * @see #SMPTE_25 @@ -103,33 +108,33 @@ public class Sequence { /** * The timing resolution of the sequence. + * * @see #getResolution */ protected int resolution; /** * The MIDI tracks in this sequence. + * * @see #getTracks */ protected Vector tracks = new Vector(); - /** - * Constructs a new MIDI sequence with the specified timing division - * type and timing resolution. The division type must be one of the - * recognized MIDI timing types. For tempo-based timing, - * divisionType is PPQ (pulses per quarter note) and - * the resolution is specified in ticks per beat. For SMTPE timing, - * divisionType specifies the number of frames per - * second and the resolution is specified in ticks per frame. - * The sequence will contain no initial tracks. Tracks may be - * added to or removed from the sequence using {@link #createTrack} - * and {@link #deleteTrack}. - * - * @param divisionType the timing division type (PPQ or one of the SMPTE types) - * @param resolution the timing resolution - * @throws InvalidMidiDataException if divisionType is not valid + * Constructs a new MIDI sequence with the specified timing division type + * and timing resolution. The division type must be one of the recognized + * MIDI timing types. For tempo-based timing, {@code divisionType} is PPQ + * (pulses per quarter note) and the resolution is specified in ticks per + * beat. For SMTPE timing, {@code divisionType} specifies the number of + * frames per second and the resolution is specified in ticks per frame. The + * sequence will contain no initial tracks. Tracks may be added to or + * removed from the sequence using {@link #createTrack} and + * {@link #deleteTrack}. * + * @param divisionType the timing division type (PPQ or one of the SMPTE + * types) + * @param resolution the timing resolution + * @throws InvalidMidiDataException if {@code divisionType} is not valid * @see #PPQ * @see #SMPTE_24 * @see #SMPTE_25 @@ -156,27 +161,25 @@ public class Sequence { this.resolution = resolution; } - /** - * Constructs a new MIDI sequence with the specified timing division - * type, timing resolution, and number of tracks. The division type must be one of the - * recognized MIDI timing types. For tempo-based timing, - * divisionType is PPQ (pulses per quarter note) and - * the resolution is specified in ticks per beat. For SMTPE timing, - * divisionType specifies the number of frames per - * second and the resolution is specified in ticks per frame. - * The sequence will be initialized with the number of tracks specified by - * numTracks. These tracks are initially empty (i.e. - * they contain only the meta-event End of Track). - * The tracks may be retrieved for editing using the {@link #getTracks} - * method. Additional tracks may be added, or existing tracks removed, - * using {@link #createTrack} and {@link #deleteTrack}. - * - * @param divisionType the timing division type (PPQ or one of the SMPTE types) - * @param resolution the timing resolution - * @param numTracks the initial number of tracks in the sequence. - * @throws InvalidMidiDataException if divisionType is not valid + * Constructs a new MIDI sequence with the specified timing division type, + * timing resolution, and number of tracks. The division type must be one of + * the recognized MIDI timing types. For tempo-based timing, + * {@code divisionType} is PPQ (pulses per quarter note) and the resolution + * is specified in ticks per beat. For SMTPE timing, {@code divisionType} + * specifies the number of frames per second and the resolution is specified + * in ticks per frame. The sequence will be initialized with the number of + * tracks specified by {@code numTracks}. These tracks are initially empty + * (i.e. they contain only the meta-event End of Track). The tracks may be + * retrieved for editing using the {@link #getTracks} method. Additional + * tracks may be added, or existing tracks removed, using + * {@link #createTrack} and {@link #deleteTrack}. * + * @param divisionType the timing division type (PPQ or one of the SMPTE + * types) + * @param resolution the timing resolution + * @param numTracks the initial number of tracks in the sequence + * @throws InvalidMidiDataException if {@code divisionType} is not valid * @see #PPQ * @see #SMPTE_24 * @see #SMPTE_25 @@ -206,11 +209,10 @@ public class Sequence { } } - /** * Obtains the timing division type for this sequence. - * @return the division type (PPQ or one of the SMPTE types) * + * @return the division type (PPQ or one of the SMPTE types) * @see #PPQ * @see #SMPTE_24 * @see #SMPTE_25 @@ -223,11 +225,10 @@ public class Sequence { return divisionType; } - /** - * Obtains the timing resolution for this sequence. - * If the sequence's division type is PPQ, the resolution is specified in ticks per beat. - * For SMTPE timing, the resolution is specified in ticks per frame. + * Obtains the timing resolution for this sequence. If the sequence's + * division type is PPQ, the resolution is specified in ticks per beat. For + * SMTPE timing, the resolution is specified in ticks per frame. * * @return the number of ticks per beat (PPQ) or per frame (SMPTE) * @see #getDivisionType @@ -238,13 +239,13 @@ public class Sequence { return resolution; } - /** - * Creates a new, initially empty track as part of this sequence. - * The track initially contains the meta-event End of Track. - * The newly created track is returned. All tracks in the sequence - * may be retrieved using {@link #getTracks}. Tracks may be - * removed from the sequence using {@link #deleteTrack}. + * Creates a new, initially empty track as part of this sequence. The track + * initially contains the meta-event End of Track. The newly created track + * is returned. All tracks in the sequence may be retrieved using + * {@link #getTracks}. Tracks may be removed from the sequence using + * {@link #deleteTrack}. + * * @return the newly created track */ public Track createTrack() { @@ -255,13 +256,12 @@ public class Sequence { return track; } - /** * Removes the specified track from the sequence. - * @param track the track to remove - * @return true if the track existed in the track and was removed, - * otherwise false. * + * @param track the track to remove + * @return {@code true} if the track existed in the track and was removed, + * otherwise {@code false} * @see #createTrack * @see #getTracks */ @@ -273,12 +273,11 @@ public class Sequence { } } - /** - * Obtains an array containing all the tracks in this sequence. - * If the sequence contains no tracks, an array of length 0 is returned. - * @return the array of tracks + * Obtains an array containing all the tracks in this sequence. If the + * sequence contains no tracks, an array of length 0 is returned. * + * @return the array of tracks * @see #createTrack * @see #deleteTrack */ @@ -287,22 +286,20 @@ public class Sequence { return tracks.toArray(new Track[tracks.size()]); } - /** * Obtains the duration of this sequence, expressed in microseconds. - * @return this sequence's duration in microseconds. + * + * @return this sequence's duration in microseconds */ public long getMicrosecondLength() { return com.sun.media.sound.MidiUtils.tick2microsecond(this, getTickLength(), null); } - /** * Obtains the duration of this sequence, expressed in MIDI ticks. * * @return this sequence's length in ticks - * * @see #getMicrosecondLength */ public long getTickLength() { @@ -321,15 +318,12 @@ public class Sequence { } } - /** - * Obtains a list of patches referenced in this sequence. - * This patch list may be used to load the required - * {@link Instrument} objects - * into a {@link Synthesizer}. - * - * @return an array of {@link Patch} objects used in this sequence + * Obtains a list of patches referenced in this sequence. This patch list + * may be used to load the required {@link Instrument} objects into a + * {@link Synthesizer}. * + * @return an array of {@link Patch} objects used in this sequence * @see Synthesizer#loadInstruments(Soundbank, Patch[]) */ public Patch[] getPatchList() { diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/Sequencer.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/Sequencer.java index b587d29b544..17d6a9dc197 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/Sequencer.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/Sequencer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -25,19 +25,18 @@ package javax.sound.midi; -import java.io.InputStream; import java.io.IOException; - +import java.io.InputStream; /** * A hardware or software device that plays back a MIDI - * {@link Sequence sequence} is known as a sequencer. - * A MIDI sequence contains lists of time-stamped MIDI data, such as - * might be read from a standard MIDI file. Most - * sequencers also provide functions for creating and editing sequences. + * {@link Sequence sequence} is known as a sequencer. A MIDI sequence + * contains lists of time-stamped MIDI data, such as might be read from a + * standard MIDI file. Most sequencers also provide functions for creating and + * editing sequences. *

    - * The Sequencer interface includes methods for the following - * basic MIDI sequencer operations: + * The {@code Sequencer} interface includes methods for the following basic MIDI + * sequencer operations: *

      *
    • obtaining a sequence from MIDI file data
    • *
    • starting and stopping playback
    • @@ -48,729 +47,635 @@ import java.io.IOException; *
    • controlling the timing of another device
    • *
    * In addition, the following operations are supported, either directly, or - * indirectly through objects that the Sequencer has access to: + * indirectly through objects that the {@code Sequencer} has access to: *
      *
    • editing the data by adding or deleting individual MIDI events or entire * tracks
    • *
    • muting or soloing individual tracks in the sequence
    • - *
    • notifying listener objects about any meta-events or - * control-change events encountered while playing back the sequence.
    • + *
    • notifying listener objects about any meta-events or control-change events + * encountered while playing back the sequence.
    • *
    * - * @see Sequencer.SyncMode + * @author Kara Kytle + * @author Florian Bomers + * @see SyncMode * @see #addMetaEventListener * @see ControllerEventListener * @see Receiver * @see Transmitter * @see MidiDevice - * - * @author Kara Kytle - * @author Florian Bomers */ public interface Sequencer extends MidiDevice { - /** - * A value indicating that looping should continue - * indefinitely rather than complete after a specific - * number of loops. + * A value indicating that looping should continue indefinitely rather than + * complete after a specific number of loops. * * @see #setLoopCount * @since 1.5 */ - public static final int LOOP_CONTINUOUSLY = -1; - - + int LOOP_CONTINUOUSLY = -1; /** * Sets the current sequence on which the sequencer operates. + *

    + * This method can be called even if the {@code Sequencer} is closed. * - *

    This method can be called even if the - * Sequencer is closed. - * - * @param sequence the sequence to be loaded. - * @throws InvalidMidiDataException if the sequence contains invalid - * MIDI data, or is not supported. + * @param sequence the sequence to be loaded + * @throws InvalidMidiDataException if the sequence contains invalid MIDI + * data, or is not supported */ - public void setSequence(Sequence sequence) throws InvalidMidiDataException; - + void setSequence(Sequence sequence) throws InvalidMidiDataException; /** - * Sets the current sequence on which the sequencer operates. - * The stream must point to MIDI file data. + * Sets the current sequence on which the sequencer operates. The stream + * must point to MIDI file data. + *

    + * This method can be called even if the {@code Sequencer} is closed. * - *

    This method can be called even if the - * Sequencer is closed. - * - * @param stream stream containing MIDI file data. - * @throws IOException if an I/O exception occurs during reading of the stream. - * @throws InvalidMidiDataException if invalid data is encountered - * in the stream, or the stream is not supported. + * @param stream stream containing MIDI file data + * @throws IOException if an I/O exception occurs during reading of the + * stream + * @throws InvalidMidiDataException if invalid data is encountered in the + * stream, or the stream is not supported */ - public void setSequence(InputStream stream) throws IOException, InvalidMidiDataException; - + void setSequence(InputStream stream) + throws IOException, InvalidMidiDataException; /** * Obtains the sequence on which the Sequencer is currently operating. + *

    + * This method can be called even if the {@code Sequencer} is closed. * - *

    This method can be called even if the - * Sequencer is closed. - * - * @return the current sequence, or null if no sequence is currently set. + * @return the current sequence, or {@code null} if no sequence is currently + * set */ - public Sequence getSequence(); - + Sequence getSequence(); /** - * Starts playback of the MIDI data in the currently - * loaded sequence. - * Playback will begin from the current position. - * If the playback position reaches the loop end point, - * and the loop count is greater than 0, playback will - * resume at the loop start point for the number of - * repetitions set with setLoopCount. - * After that, or if the loop count is 0, playback will - * continue to play to the end of the sequence. - * - *

    The implementation ensures that the synthesizer - * is brought to a consistent state when jumping - * to the loop start point by sending appropriate - * controllers, pitch bend, and program change events. - * - * @throws IllegalStateException if the Sequencer is - * closed. + * Starts playback of the MIDI data in the currently loaded sequence. + * Playback will begin from the current position. If the playback position + * reaches the loop end point, and the loop count is greater than 0, + * playback will resume at the loop start point for the number of + * repetitions set with {@code setLoopCount}. After that, or if the loop + * count is 0, playback will continue to play to the end of the sequence. + *

    + * The implementation ensures that the synthesizer is brought to a + * consistent state when jumping to the loop start point by sending + * appropriate controllers, pitch bend, and program change events. * + * @throws IllegalStateException if the {@code Sequencer} is closed * @see #setLoopStartPoint * @see #setLoopEndPoint * @see #setLoopCount * @see #stop */ - public void start(); - + void start(); /** - * Stops recording, if active, and playback of the currently loaded sequence, - * if any. - * - * @throws IllegalStateException if the Sequencer is - * closed. + * Stops recording, if active, and playback of the currently loaded + * sequence, if any. * + * @throws IllegalStateException if the {@code Sequencer} is closed * @see #start * @see #isRunning */ - public void stop(); - + void stop(); /** - * Indicates whether the Sequencer is currently running. The default is false. - * The Sequencer starts running when either {@link #start} or {@link #startRecording} - * is called. isRunning then returns true until playback of the - * sequence completes or {@link #stop} is called. - * @return true if the Sequencer is running, otherwise false + * Indicates whether the Sequencer is currently running. The default is + * {@code false}. The Sequencer starts running when either{@link #start} or + * {@link #startRecording} is called. {@code isRunning} then returns + * {@code true} until playback of the sequence completes or {@link #stop} is + * called. + * + * @return {@code true} if the Sequencer is running, otherwise {@code false} */ - public boolean isRunning(); - + boolean isRunning(); /** - * Starts recording and playback of MIDI data. Data is recorded to all enabled tracks, - * on the channel(s) for which they were enabled. Recording begins at the current position - * of the sequencer. Any events already in the track are overwritten for the duration - * of the recording session. Events from the currently loaded sequence, - * if any, are delivered to the sequencer's transmitter(s) along with messages - * received during recording. + * Starts recording and playback of MIDI data. Data is recorded to all + * enabled tracks, on the channel(s) for which they were enabled. Recording + * begins at the current position of the sequencer. Any events already in + * the track are overwritten for the duration of the recording session. + * Events from the currently loaded sequence, if any, are delivered to the + * sequencer's transmitter(s) along with messages received during recording. *

    - * Note that tracks are not by default enabled for recording. In order to record MIDI data, - * at least one track must be specifically enabled for recording. + * Note that tracks are not by default enabled for recording. In order to + * record MIDI data, at least one track must be specifically enabled for + * recording. * - * @throws IllegalStateException if the Sequencer is - * closed. - * - * @see #startRecording + * @throws IllegalStateException if the {@code Sequencer} is closed * @see #recordEnable * @see #recordDisable */ - public void startRecording(); - + void startRecording(); /** - * Stops recording, if active. Playback of the current sequence continues. - * - * @throws IllegalStateException if the Sequencer is - * closed. + * Stops recording, if active. Playback of the current sequence continues. * + * @throws IllegalStateException if the {@code Sequencer} is closed * @see #startRecording * @see #isRecording */ - public void stopRecording(); - + void stopRecording(); /** - * Indicates whether the Sequencer is currently recording. The default is false. - * The Sequencer begins recording when {@link #startRecording} is called, - * and then returns true until {@link #stop} or {@link #stopRecording} - * is called. - * @return true if the Sequencer is recording, otherwise false + * Indicates whether the Sequencer is currently recording. The default is + * {@code false}. The Sequencer begins recording when + * {@link #startRecording} is called, and then returns {@code true} until + * {@link #stop} or {@link #stopRecording} is called. + * + * @return {@code true} if the Sequencer is recording, otherwise + * {@code false} */ - public boolean isRecording(); - + boolean isRecording(); /** - * Prepares the specified track for recording events received on a particular channel. - * Once enabled, a track will receive events when recording is active. - * @param track the track to which events will be recorded - * @param channel the channel on which events will be received. If -1 is specified - * for the channel value, the track will receive data from all channels. - * @throws IllegalArgumentException thrown if the track is not part of the current - * sequence. + * Prepares the specified track for recording events received on a + * particular channel. Once enabled, a track will receive events when + * recording is active. + * + * @param track the track to which events will be recorded + * @param channel the channel on which events will be received. If -1 is + * specified for the channel value, the track will receive data from + * all channels. + * @throws IllegalArgumentException thrown if the track is not part of the + * current sequence */ - public void recordEnable(Track track, int channel); - + void recordEnable(Track track, int channel); /** - * Disables recording to the specified track. Events will no longer be recorded - * into this track. - * @param track the track to disable for recording, or null to disable - * recording for all tracks. + * Disables recording to the specified track. Events will no longer be + * recorded into this track. + * + * @param track the track to disable for recording, or {@code null} to + * disable recording for all tracks */ - public void recordDisable(Track track); - + void recordDisable(Track track); /** - * Obtains the current tempo, expressed in beats per minute. The - * actual tempo of playback is the product of the returned value - * and the tempo factor. + * Obtains the current tempo, expressed in beats per minute. The actual + * tempo of playback is the product of the returned value and the tempo + * factor. * * @return the current tempo in beats per minute - * * @see #getTempoFactor * @see #setTempoInBPM(float) * @see #getTempoInMPQ */ - public float getTempoInBPM(); - + float getTempoInBPM(); /** - * Sets the tempo in beats per minute. The actual tempo of playback - * is the product of the specified value and the tempo factor. + * Sets the tempo in beats per minute. The actual tempo of playback is the + * product of the specified value and the tempo factor. * - * @param bpm desired new tempo in beats per minute + * @param bpm desired new tempo in beats per minute * @see #getTempoFactor * @see #setTempoInMPQ(float) * @see #getTempoInBPM */ - public void setTempoInBPM(float bpm); - + void setTempoInBPM(float bpm); /** - * Obtains the current tempo, expressed in microseconds per quarter - * note. The actual tempo of playback is the product of the returned - * value and the tempo factor. + * Obtains the current tempo, expressed in microseconds per quarter note. + * The actual tempo of playback is the product of the returned value and the + * tempo factor. * * @return the current tempo in microseconds per quarter note * @see #getTempoFactor * @see #setTempoInMPQ(float) * @see #getTempoInBPM */ - public float getTempoInMPQ(); - + float getTempoInMPQ(); /** - * Sets the tempo in microseconds per quarter note. The actual tempo - * of playback is the product of the specified value and the tempo - * factor. + * Sets the tempo in microseconds per quarter note. The actual tempo of + * playback is the product of the specified value and the tempo factor. * - * @param mpq desired new tempo in microseconds per quarter note. + * @param mpq desired new tempo in microseconds per quarter note * @see #getTempoFactor * @see #setTempoInBPM(float) * @see #getTempoInMPQ */ - public void setTempoInMPQ(float mpq); - + void setTempoInMPQ(float mpq); /** - * Scales the sequencer's actual playback tempo by the factor provided. - * The default is 1.0. A value of 1.0 represents the natural rate (the - * tempo specified in the sequence), 2.0 means twice as fast, etc. - * The tempo factor does not affect the values returned by - * {@link #getTempoInMPQ} and {@link #getTempoInBPM}. - * Those values indicate the tempo prior to scaling. + * Scales the sequencer's actual playback tempo by the factor provided. The + * default is 1.0. A value of 1.0 represents the natural rate (the tempo + * specified in the sequence), 2.0 means twice as fast, etc. The tempo + * factor does not affect the values returned by {@link #getTempoInMPQ} and + * {@link #getTempoInBPM}. Those values indicate the tempo prior to scaling. *

    * Note that the tempo factor cannot be adjusted when external - * synchronization is used. In that situation, - * setTempoFactor always sets the tempo factor to 1.0. + * synchronization is used. In that situation, {@code setTempoFactor} always + * sets the tempo factor to 1.0. * - * @param factor the requested tempo scalar + * @param factor the requested tempo scalar * @see #getTempoFactor */ - public void setTempoFactor(float factor); - + void setTempoFactor(float factor); /** - * Returns the current tempo factor for the sequencer. The default is - * 1.0. + * Returns the current tempo factor for the sequencer. The default is 1.0. * - * @return tempo factor. + * @return tempo factor * @see #setTempoFactor(float) */ - public float getTempoFactor(); - + float getTempoFactor(); /** - * Obtains the length of the current sequence, expressed in MIDI ticks, - * or 0 if no sequence is set. + * Obtains the length of the current sequence, expressed in MIDI ticks, or 0 + * if no sequence is set. + * * @return length of the sequence in ticks */ - public long getTickLength(); - + long getTickLength(); /** - * Obtains the current position in the sequence, expressed in MIDI - * ticks. (The duration of a tick in seconds is determined both by - * the tempo and by the timing resolution stored in the - * {@link Sequence}.) + * Obtains the current position in the sequence, expressed in MIDI ticks. + * (The duration of a tick in seconds is determined both by the tempo and by + * the timing resolution stored in the {@link Sequence}.) * * @return current tick * @see #setTickPosition */ - public long getTickPosition(); - + long getTickPosition(); /** - * Sets the current sequencer position in MIDI ticks - * @param tick the desired tick position + * Sets the current sequencer position in MIDI ticks. + * + * @param tick the desired tick position * @see #getTickPosition */ - public void setTickPosition(long tick); - + void setTickPosition(long tick); /** - * Obtains the length of the current sequence, expressed in microseconds, - * or 0 if no sequence is set. - * @return length of the sequence in microseconds. + * Obtains the length of the current sequence, expressed in microseconds, or + * 0 if no sequence is set. + * + * @return length of the sequence in microseconds */ - public long getMicrosecondLength(); - + long getMicrosecondLength(); /** - * Obtains the current position in the sequence, expressed in - * microseconds. + * Obtains the current position in the sequence, expressed in microseconds. + * * @return the current position in microseconds * @see #setMicrosecondPosition */ - public long getMicrosecondPosition(); - + long getMicrosecondPosition(); /** - * Sets the current position in the sequence, expressed in microseconds - * @param microseconds desired position in microseconds + * Sets the current position in the sequence, expressed in microseconds. + * + * @param microseconds desired position in microseconds * @see #getMicrosecondPosition */ - public void setMicrosecondPosition(long microseconds); - + void setMicrosecondPosition(long microseconds); /** - * Sets the source of timing information used by this sequencer. - * The sequencer synchronizes to the master, which is the internal clock, - * MIDI clock, or MIDI time code, depending on the value of - * sync. The sync argument must be one - * of the supported modes, as returned by - * {@link #getMasterSyncModes}. - * - * @param sync the desired master synchronization mode + * Sets the source of timing information used by this sequencer. The + * sequencer synchronizes to the master, which is the internal clock, MIDI + * clock, or MIDI time code, depending on the value of {@code sync}. The + * {@code sync} argument must be one of the supported modes, as returned by + * {@link #getMasterSyncModes}. * + * @param sync the desired master synchronization mode * @see SyncMode#INTERNAL_CLOCK * @see SyncMode#MIDI_SYNC * @see SyncMode#MIDI_TIME_CODE * @see #getMasterSyncMode */ - public void setMasterSyncMode(SyncMode sync); - + void setMasterSyncMode(SyncMode sync); /** * Obtains the current master synchronization mode for this sequencer. * * @return the current master synchronization mode - * - * @see #setMasterSyncMode(Sequencer.SyncMode) + * @see #setMasterSyncMode(SyncMode) * @see #getMasterSyncModes */ - public SyncMode getMasterSyncMode(); - + SyncMode getMasterSyncMode(); /** * Obtains the set of master synchronization modes supported by this * sequencer. * * @return the available master synchronization modes - * * @see SyncMode#INTERNAL_CLOCK * @see SyncMode#MIDI_SYNC * @see SyncMode#MIDI_TIME_CODE * @see #getMasterSyncMode - * @see #setMasterSyncMode(Sequencer.SyncMode) + * @see #setMasterSyncMode(SyncMode) */ - public SyncMode[] getMasterSyncModes(); - + SyncMode[] getMasterSyncModes(); /** - * Sets the slave synchronization mode for the sequencer. - * This indicates the type of timing information sent by the sequencer - * to its receiver. The sync argument must be one - * of the supported modes, as returned by - * {@link #getSlaveSyncModes}. - * - * @param sync the desired slave synchronization mode + * Sets the slave synchronization mode for the sequencer. This indicates the + * type of timing information sent by the sequencer to its receiver. The + * {@code sync} argument must be one of the supported modes, as returned by + * {@link #getSlaveSyncModes}. * + * @param sync the desired slave synchronization mode * @see SyncMode#MIDI_SYNC * @see SyncMode#MIDI_TIME_CODE * @see SyncMode#NO_SYNC * @see #getSlaveSyncModes */ - public void setSlaveSyncMode(SyncMode sync); - + void setSlaveSyncMode(SyncMode sync); /** * Obtains the current slave synchronization mode for this sequencer. * * @return the current slave synchronization mode - * - * @see #setSlaveSyncMode(Sequencer.SyncMode) + * @see #setSlaveSyncMode(SyncMode) * @see #getSlaveSyncModes */ - public SyncMode getSlaveSyncMode(); - + SyncMode getSlaveSyncMode(); /** - * Obtains the set of slave synchronization modes supported by the sequencer. + * Obtains the set of slave synchronization modes supported by the + * sequencer. * * @return the available slave synchronization modes - * * @see SyncMode#MIDI_SYNC * @see SyncMode#MIDI_TIME_CODE * @see SyncMode#NO_SYNC */ - public SyncMode[] getSlaveSyncModes(); - + SyncMode[] getSlaveSyncModes(); /** - * Sets the mute state for a track. This method may fail for a number - * of reasons. For example, the track number specified may not be valid - * for the current sequence, or the sequencer may not support this functionality. - * An application which needs to verify whether this operation succeeded should - * follow this call with a call to {@link #getTrackMute}. + * Sets the mute state for a track. This method may fail for a number of + * reasons. For example, the track number specified may not be valid for the + * current sequence, or the sequencer may not support this functionality. An + * application which needs to verify whether this operation succeeded should + * follow this call with a call to {@link #getTrackMute}. * - * @param track the track number. Tracks in the current sequence are numbered - * from 0 to the number of tracks in the sequence minus 1. - * @param mute the new mute state for the track. true implies the - * track should be muted, false implies the track should be unmuted. + * @param track the track number. Tracks in the current sequence are + * numbered from 0 to the number of tracks in the sequence minus 1. + * @param mute the new mute state for the track. {@code true} implies the + * track should be muted, {@code false} implies the track should be + * unmuted. * @see #getSequence */ - public void setTrackMute(int track, boolean mute); - + void setTrackMute(int track, boolean mute); /** - * Obtains the current mute state for a track. The default mute - * state for all tracks which have not been muted is false. In any - * case where the specified track has not been muted, this method should - * return false. This applies if the sequencer does not support muting - * of tracks, and if the specified track index is not valid. + * Obtains the current mute state for a track. The default mute state for + * all tracks which have not been muted is false. In any case where the + * specified track has not been muted, this method should return false. This + * applies if the sequencer does not support muting of tracks, and if the + * specified track index is not valid. * - * @param track the track number. Tracks in the current sequence are numbered - * from 0 to the number of tracks in the sequence minus 1. - * @return true if muted, false if not. + * @param track the track number. Tracks in the current sequence are + * numbered from 0 to the number of tracks in the sequence minus 1. + * @return {@code true} if muted, {@code false} if not */ - public boolean getTrackMute(int track); + boolean getTrackMute(int track); /** - * Sets the solo state for a track. If solo is true - * only this track and other solo'd tracks will sound. If solo - * is false then only other solo'd tracks will sound, unless no - * tracks are solo'd in which case all un-muted tracks will sound. + * Sets the solo state for a track. If {@code solo} is {@code true} only + * this track and other solo'd tracks will sound. If {@code solo} is + * {@code false} then only other solo'd tracks will sound, unless no tracks + * are solo'd in which case all un-muted tracks will sound. *

    - * This method may fail for a number - * of reasons. For example, the track number specified may not be valid - * for the current sequence, or the sequencer may not support this functionality. - * An application which needs to verify whether this operation succeeded should - * follow this call with a call to {@link #getTrackSolo}. + * This method may fail for a number of reasons. For example, the track + * number specified may not be valid for the current sequence, or the + * sequencer may not support this functionality. An application which needs + * to verify whether this operation succeeded should follow this call with a + * call to {@link #getTrackSolo}. * - * @param track the track number. Tracks in the current sequence are numbered - * from 0 to the number of tracks in the sequence minus 1. - * @param solo the new solo state for the track. true implies the - * track should be solo'd, false implies the track should not be solo'd. + * @param track the track number. Tracks in the current sequence are + * numbered from 0 to the number of tracks in the sequence minus 1. + * @param solo the new solo state for the track. {@code true} implies the + * track should be solo'd, {@code false} implies the track should + * not be solo'd. * @see #getSequence */ - public void setTrackSolo(int track, boolean solo); - + void setTrackSolo(int track, boolean solo); /** - * Obtains the current solo state for a track. The default mute - * state for all tracks which have not been solo'd is false. In any - * case where the specified track has not been solo'd, this method should - * return false. This applies if the sequencer does not support soloing - * of tracks, and if the specified track index is not valid. + * Obtains the current solo state for a track. The default mute state for + * all tracks which have not been solo'd is false. In any case where the + * specified track has not been solo'd, this method should return false. + * This applies if the sequencer does not support soloing of tracks, and if + * the specified track index is not valid. * - * @param track the track number. Tracks in the current sequence are numbered - * from 0 to the number of tracks in the sequence minus 1. - * @return true if solo'd, false if not. + * @param track the track number. Tracks in the current sequence are + * numbered from 0 to the number of tracks in the sequence minus 1. + * @return {@code true} if solo'd, {@code false} if not */ - public boolean getTrackSolo(int track); - + boolean getTrackSolo(int track); /** - * Registers a meta-event listener to receive - * notification whenever a meta-event is encountered in the sequence - * and processed by the sequencer. This method can fail if, for - * instance,this class of sequencer does not support meta-event - * notification. - * - * @param listener listener to add - * @return true if the listener was successfully added, - * otherwise false + * Registers a meta-event listener to receive notification whenever a + * meta-event is encountered in the sequence and processed by the sequencer. + * This method can fail if, for instance,this class of sequencer does not + * support meta-event notification. * + * @param listener listener to add + * @return {@code true} if the listener was successfully added, otherwise + * {@code false} * @see #removeMetaEventListener * @see MetaEventListener * @see MetaMessage */ - public boolean addMetaEventListener(MetaEventListener listener); - + boolean addMetaEventListener(MetaEventListener listener); /** - * Removes the specified meta-event listener from this sequencer's - * list of registered listeners, if in fact the listener is registered. + * Removes the specified meta-event listener from this sequencer's list of + * registered listeners, if in fact the listener is registered. * - * @param listener the meta-event listener to remove + * @param listener the meta-event listener to remove * @see #addMetaEventListener */ - public void removeMetaEventListener(MetaEventListener listener); - + void removeMetaEventListener(MetaEventListener listener); /** - * Registers a controller event listener to receive notification - * whenever the sequencer processes a control-change event of the - * requested type or types. The types are specified by the - * controllers argument, which should contain an array of - * MIDI controller numbers. (Each number should be between 0 and 127, - * inclusive. See the MIDI 1.0 Specification for the numbers that - * correspond to various types of controllers.) + * Registers a controller event listener to receive notification whenever + * the sequencer processes a control-change event of the requested type or + * types. The types are specified by the {@code controllers} argument, which + * should contain an array of MIDI controller numbers. (Each number should + * be between 0 and 127, inclusive. See the MIDI 1.0 Specification for the + * numbers that correspond to various types of controllers.) *

    - * The returned array contains the MIDI controller - * numbers for which the listener will now receive events. - * Some sequencers might not support controller event notification, in - * which case the array has a length of 0. Other sequencers might - * support notification for some controllers but not all. - * This method may be invoked repeatedly. - * Each time, the returned array indicates all the controllers - * that the listener will be notified about, not only the controllers - * requested in that particular invocation. - * - * @param listener the controller event listener to add to the list of - * registered listeners - * @param controllers the MIDI controller numbers for which change - * notification is requested - * @return the numbers of all the MIDI controllers whose changes will - * now be reported to the specified listener + * The returned array contains the MIDI controller numbers for which the + * listener will now receive events. Some sequencers might not support + * controller event notification, in which case the array has a length of 0. + * Other sequencers might support notification for some controllers but not + * all. This method may be invoked repeatedly. Each time, the returned array + * indicates all the controllers that the listener will be notified about, + * not only the controllers requested in that particular invocation. * + * @param listener the controller event listener to add to the list of + * registered listeners + * @param controllers the MIDI controller numbers for which change + * notification is requested + * @return the numbers of all the MIDI controllers whose changes will now be + * reported to the specified listener * @see #removeControllerEventListener * @see ControllerEventListener */ - public int[] addControllerEventListener(ControllerEventListener listener, int[] controllers); - + int[] addControllerEventListener(ControllerEventListener listener, + int[] controllers); /** - * Removes a controller event listener's interest in one or more - * types of controller event. The controllers argument - * is an array of MIDI numbers corresponding to the controllers for - * which the listener should no longer receive change notifications. - * To completely remove this listener from the list of registered - * listeners, pass in null for controllers. - * The returned array contains the MIDI controller - * numbers for which the listener will now receive events. The - * array has a length of 0 if the listener will not receive - * change notifications for any controllers. - * - * @param listener old listener - * @param controllers the MIDI controller numbers for which change - * notification should be cancelled, or null to cancel - * for all controllers - * @return the numbers of all the MIDI controllers whose changes will - * now be reported to the specified listener + * Removes a controller event listener's interest in one or more types of + * controller event. The {@code controllers} argument is an array of MIDI + * numbers corresponding to the controllers for which the listener should no + * longer receive change notifications. To completely remove this listener + * from the list of registered listeners, pass in {@code null} for + * {@code controllers}. The returned array contains the MIDI controller + * numbers for which the listener will now receive events. The array has a + * length of 0 if the listener will not receive change notifications for any + * controllers. * + * @param listener old listener + * @param controllers the MIDI controller numbers for which change + * notification should be cancelled, or {@code null} to cancel for + * all controllers + * @return the numbers of all the MIDI controllers whose changes will now be + * reported to the specified listener * @see #addControllerEventListener */ - public int[] removeControllerEventListener(ControllerEventListener listener, int[] controllers); - + int[] removeControllerEventListener(ControllerEventListener listener, + int[] controllers); /** - * Sets the first MIDI tick that will be - * played in the loop. If the loop count is - * greater than 0, playback will jump to this - * point when reaching the loop end point. - * - *

    A value of 0 for the starting point means the - * beginning of the loaded sequence. The starting - * point must be lower than or equal to the ending - * point, and it must fall within the size of the - * loaded sequence. - * - *

    A sequencer's loop start point defaults to - * start of the sequence. - * - * @param tick the loop's starting position, - * in MIDI ticks (zero-based) - * @throws IllegalArgumentException if the requested - * loop start point cannot be set, usually because - * it falls outside the sequence's - * duration or because the start point is - * after the end point + * Sets the first MIDI tick that will be played in the loop. If the loop + * count is greater than 0, playback will jump to this point when reaching + * the loop end point. + *

    + * A value of 0 for the starting point means the beginning of the loaded + * sequence. The starting point must be lower than or equal to the ending + * point, and it must fall within the size of the loaded sequence. + *

    + * A sequencer's loop start point defaults to start of the sequence. * + * @param tick the loop's starting position, in MIDI ticks (zero-based) + * @throws IllegalArgumentException if the requested loop start point cannot + * be set, usually because it falls outside the sequence's duration + * or because the start point is after the end point * @see #setLoopEndPoint * @see #setLoopCount * @see #getLoopStartPoint * @see #start * @since 1.5 */ - public void setLoopStartPoint(long tick); - + void setLoopStartPoint(long tick); /** - * Obtains the start position of the loop, - * in MIDI ticks. + * Obtains the start position of the loop, in MIDI ticks. * - * @return the start position of the loop, - in MIDI ticks (zero-based) + * @return the start position of the loop, in MIDI ticks (zero-based) * @see #setLoopStartPoint * @since 1.5 */ - public long getLoopStartPoint(); - + long getLoopStartPoint(); /** - * Sets the last MIDI tick that will be played in - * the loop. If the loop count is 0, the loop end - * point has no effect and playback continues to + * Sets the last MIDI tick that will be played in the loop. If the loop + * count is 0, the loop end point has no effect and playback continues to * play when reaching the loop end point. + *

    + * A value of -1 for the ending point indicates the last tick of the + * sequence. Otherwise, the ending point must be greater than or equal to + * the starting point, and it must fall within the size of the loaded + * sequence. + *

    + * A sequencer's loop end point defaults to -1, meaning the end of the + * sequence. * - *

    A value of -1 for the ending point - * indicates the last tick of the sequence. - * Otherwise, the ending point must be greater - * than or equal to the starting point, and it must - * fall within the size of the loaded sequence. - * - *

    A sequencer's loop end point defaults to -1, - * meaning the end of the sequence. - * - * @param tick the loop's ending position, - * in MIDI ticks (zero-based), or - * -1 to indicate the final tick - * @throws IllegalArgumentException if the requested - * loop point cannot be set, usually because - * it falls outside the sequence's - * duration or because the ending point is - * before the starting point - * + * @param tick the loop's ending position, in MIDI ticks (zero-based), or + * -1 to indicate the final tick + * @throws IllegalArgumentException if the requested loop point cannot be + * set, usually because it falls outside the sequence's duration or + * because the ending point is before the starting point * @see #setLoopStartPoint * @see #setLoopCount * @see #getLoopEndPoint * @see #start * @since 1.5 */ - public void setLoopEndPoint(long tick); - + void setLoopEndPoint(long tick); /** - * Obtains the end position of the loop, - * in MIDI ticks. + * Obtains the end position of the loop, in MIDI ticks. * - * @return the end position of the loop, in MIDI - * ticks (zero-based), or -1 to indicate - * the end of the sequence + * @return the end position of the loop, in MIDI ticks (zero-based), or -1 + * to indicate the end of the sequence * @see #setLoopEndPoint * @since 1.5 */ - public long getLoopEndPoint(); - + long getLoopEndPoint(); /** - * Sets the number of repetitions of the loop for - * playback. - * When the playback position reaches the loop end point, - * it will loop back to the loop start point - * count times, after which playback will - * continue to play to the end of the sequence. + * Sets the number of repetitions of the loop for playback. When the + * playback position reaches the loop end point, it will loop back to the + * loop start point {@code count} times, after which playback will continue + * to play to the end of the sequence. *

    - * If the current position when this method is invoked - * is greater than the loop end point, playback - * continues to the end of the sequence without looping, - * unless the loop end point is changed subsequently. + * If the current position when this method is invoked is greater than the + * loop end point, playback continues to the end of the sequence without + * looping, unless the loop end point is changed subsequently. *

    - * A count value of 0 disables looping: - * playback will continue at the loop end point, and it - * will not loop back to the loop start point. + * A {@code count} value of 0 disables looping: playback will continue at + * the loop end point, and it will not loop back to the loop start point. * This is a sequencer's default. + *

    + * If playback is stopped during looping, the current loop status is + * cleared; subsequent start requests are not affected by an interrupted + * loop operation. * - *

    If playback is stopped during looping, the - * current loop status is cleared; subsequent start - * requests are not affected by an interrupted loop - * operation. - * - * @param count the number of times playback should - * loop back from the loop's end position - * to the loop's start position, or - * {@link #LOOP_CONTINUOUSLY} - * to indicate that looping should - * continue until interrupted - * - * @throws IllegalArgumentException if count is - * negative and not equal to {@link #LOOP_CONTINUOUSLY} - * + * @param count the number of times playback should loop back from the + * loop's end position to the loop's start position, or + * {@link #LOOP_CONTINUOUSLY} to indicate that looping should + * continue until interrupted + * @throws IllegalArgumentException if {@code count} is negative and not + * equal to {@link #LOOP_CONTINUOUSLY} * @see #setLoopStartPoint * @see #setLoopEndPoint * @see #getLoopCount * @see #start * @since 1.5 */ - public void setLoopCount(int count); - + void setLoopCount(int count); /** - * Obtains the number of repetitions for - * playback. + * Obtains the number of repetitions for playback. * - * @return the number of loops after which - * playback plays to the end of the + * @return the number of loops after which playback plays to the end of the * sequence * @see #setLoopCount * @see #start * @since 1.5 */ - public int getLoopCount(); + int getLoopCount(); /** - * A SyncMode object represents one of the ways in which - * a MIDI sequencer's notion of time can be synchronized with a master - * or slave device. - * If the sequencer is being synchronized to a master, the - * sequencer revises its current time in response to messages from - * the master. If the sequencer has a slave, the sequencer - * similarly sends messages to control the slave's timing. + * A {@code SyncMode} object represents one of the ways in which a MIDI + * sequencer's notion of time can be synchronized with a master or slave + * device. If the sequencer is being synchronized to a master, the sequencer + * revises its current time in response to messages from the master. If the + * sequencer has a slave, the sequencer similarly sends messages to control + * the slave's timing. *

    - * There are three predefined modes that specify possible masters - * for a sequencer: INTERNAL_CLOCK, - * MIDI_SYNC, and MIDI_TIME_CODE. The - * latter two work if the sequencer receives MIDI messages from - * another device. In these two modes, the sequencer's time gets reset - * based on system real-time timing clock messages or MIDI time code - * (MTC) messages, respectively. These two modes can also be used - * as slave modes, in which case the sequencer sends the corresponding - * types of MIDI messages to its receiver (whether or not the sequencer - * is also receiving them from a master). A fourth mode, - * NO_SYNC, is used to indicate that the sequencer should - * not control its receiver's timing. + * There are three predefined modes that specify possible masters for a + * sequencer: {@code INTERNAL_CLOCK}, {@code MIDI_SYNC}, and + * {@code MIDI_TIME_CODE}. The latter two work if the sequencer receives + * MIDI messages from another device. In these two modes, the sequencer's + * time gets reset based on system real-time timing clock messages or MIDI + * time code (MTC) messages, respectively. These two modes can also be used + * as slave modes, in which case the sequencer sends the corresponding types + * of MIDI messages to its receiver (whether or not the sequencer is also + * receiving them from a master). A fourth mode, {@code NO_SYNC}, is used to + * indicate that the sequencer should not control its receiver's timing. * - * @see Sequencer#setMasterSyncMode(Sequencer.SyncMode) - * @see Sequencer#setSlaveSyncMode(Sequencer.SyncMode) + * @see Sequencer#setMasterSyncMode(SyncMode) + * @see Sequencer#setSlaveSyncMode(SyncMode) */ - public static class SyncMode { + class SyncMode { /** * Synchronization mode name. @@ -779,27 +684,27 @@ public interface Sequencer extends MidiDevice { /** * Constructs a synchronization mode. - * @param name name of the synchronization mode + * + * @param name name of the synchronization mode */ protected SyncMode(String name) { this.name = name; } - /** - * Determines whether two objects are equal. - * Returns true if the objects are identical - * @param obj the reference object with which to compare - * @return true if this object is the same as the - * obj argument, false otherwise + * Determines whether two objects are equal. Returns {@code true} if the + * objects are identical. + * + * @param obj the reference object with which to compare + * @return {@code true} if this object is the same as the {@code obj} + * argument, {@code false} otherwise */ public final boolean equals(Object obj) { return super.equals(obj); } - /** * Finalizes the hashcode method. */ @@ -808,10 +713,10 @@ public interface Sequencer extends MidiDevice { return super.hashCode(); } - /** * Provides this synchronization mode's name as the string * representation of the mode. + * * @return the name of this synchronization mode */ public final String toString() { @@ -819,50 +724,41 @@ public interface Sequencer extends MidiDevice { return name; } - /** - * A master synchronization mode that makes the sequencer get - * its timing information from its internal clock. This is not - * a legal slave sync mode. + * A master synchronization mode that makes the sequencer get its timing + * information from its internal clock. This is not a legal slave sync + * mode. */ public static final SyncMode INTERNAL_CLOCK = new SyncMode("Internal Clock"); - /** - * A master or slave synchronization mode that specifies the - * use of MIDI clock - * messages. If this mode is used as the master sync mode, - * the sequencer gets its timing information from system real-time - * MIDI clock messages. This mode only applies as the master sync - * mode for sequencers that are also MIDI receivers. If this is the - * slave sync mode, the sequencer sends system real-time MIDI clock - * messages to its receiver. MIDI clock messages are sent at a rate - * of 24 per quarter note. + * A master or slave synchronization mode that specifies the use of MIDI + * clock messages. If this mode is used as the master sync mode, the + * sequencer gets its timing information from system real-time MIDI + * clock messages. This mode only applies as the master sync mode for + * sequencers that are also MIDI receivers. If this is the slave sync + * mode, the sequencer sends system real-time MIDI clock messages to its + * receiver. MIDI clock messages are sent at a rate of 24 per quarter + * note. */ public static final SyncMode MIDI_SYNC = new SyncMode("MIDI Sync"); - /** - * A master or slave synchronization mode that specifies the - * use of MIDI Time Code. - * If this mode is used as the master sync mode, - * the sequencer gets its timing information from MIDI Time Code - * messages. This mode only applies as the master sync - * mode to sequencers that are also MIDI receivers. If this - * mode is used as the - * slave sync mode, the sequencer sends MIDI Time Code - * messages to its receiver. (See the MIDI 1.0 Detailed - * Specification for a description of MIDI Time Code.) + * A master or slave synchronization mode that specifies the use of MIDI + * Time Code. If this mode is used as the master sync mode, the + * sequencer gets its timing information from MIDI Time Code messages. + * This mode only applies as the master sync mode to sequencers that are + * also MIDI receivers. If this mode is used as the slave sync mode, the + * sequencer sends MIDI Time Code messages to its receiver. (See the + * MIDI 1.0 Detailed Specification for a description of MIDI Time Code.) */ public static final SyncMode MIDI_TIME_CODE = new SyncMode("MIDI Time Code"); - /** * A slave synchronization mode indicating that no timing information - * should be sent to the receiver. This is not a legal master sync - * mode. + * should be sent to the receiver. This is not a legal master sync mode. */ public static final SyncMode NO_SYNC = new SyncMode("No Timing"); - } // class SyncMode + } } diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/ShortMessage.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/ShortMessage.java index 02301ca2a49..8dcf92f9552 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/ShortMessage.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/ShortMessage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -26,156 +26,158 @@ package javax.sound.midi; /** - * A ShortMessage contains a MIDI message that has at most - * two data bytes following its status byte. The types of MIDI message - * that satisfy this criterion are channel voice, channel mode, system common, - * and system real-time--in other words, everything except system exclusive - * and meta-events. The ShortMessage class provides methods - * for getting and setting the contents of the MIDI message. + * A {@code ShortMessage} contains a MIDI message that has at most two data + * bytes following its status byte. The types of MIDI message that satisfy this + * criterion are channel voice, channel mode, system common, and system + * real-time--in other words, everything except system exclusive and + * meta-events. The {@code ShortMessage} class provides methods for getting and + * setting the contents of the MIDI message. *

    - * A number of ShortMessage methods have integer parameters by which - * you specify a MIDI status or data byte. If you know the numeric value, you - * can express it directly. For system common and system real-time messages, - * you can often use the corresponding fields of ShortMessage, such as - * {@link #SYSTEM_RESET SYSTEM_RESET}. For channel messages, - * the upper four bits of the status byte are specified by a command value and - * the lower four bits are specified by a MIDI channel number. To - * convert incoming MIDI data bytes that are in the form of Java's signed bytes, - * you can use the conversion code - * given in the {@link MidiMessage} class description. - * - * @see SysexMessage - * @see MetaMessage + * A number of {@code ShortMessage} methods have integer parameters by which you + * specify a MIDI status or data byte. If you know the numeric value, you can + * express it directly. For system common and system real-time messages, you can + * often use the corresponding fields of {@code ShortMessage}, such as + * {@link #SYSTEM_RESET SYSTEM_RESET}. For channel messages, the upper four bits + * of the status byte are specified by a command value and the lower four bits + * are specified by a MIDI channel number. To convert incoming MIDI data bytes + * that are in the form of Java's signed bytes, you can use the + * conversion code given in the + * {@link MidiMessage} class description. * * @author David Rivas * @author Kara Kytle * @author Florian Bomers + * @see SysexMessage + * @see MetaMessage */ - public class ShortMessage extends MidiMessage { - // Status byte defines - // System common messages /** * Status byte for MIDI Time Code Quarter Frame message (0xF1, or 241). + * * @see MidiMessage#getStatus */ public static final int MIDI_TIME_CODE = 0xF1; // 241 /** * Status byte for Song Position Pointer message (0xF2, or 242). + * * @see MidiMessage#getStatus */ public static final int SONG_POSITION_POINTER = 0xF2; // 242 /** * Status byte for MIDI Song Select message (0xF3, or 243). + * * @see MidiMessage#getStatus */ public static final int SONG_SELECT = 0xF3; // 243 /** * Status byte for Tune Request message (0xF6, or 246). + * * @see MidiMessage#getStatus */ public static final int TUNE_REQUEST = 0xF6; // 246 /** * Status byte for End of System Exclusive message (0xF7, or 247). + * * @see MidiMessage#getStatus */ public static final int END_OF_EXCLUSIVE = 0xF7; // 247 - // System real-time messages /** * Status byte for Timing Clock message (0xF8, or 248). + * * @see MidiMessage#getStatus */ public static final int TIMING_CLOCK = 0xF8; // 248 /** * Status byte for Start message (0xFA, or 250). + * * @see MidiMessage#getStatus */ public static final int START = 0xFA; // 250 /** * Status byte for Continue message (0xFB, or 251). + * * @see MidiMessage#getStatus */ public static final int CONTINUE = 0xFB; // 251 /** * Status byte for Stop message (0xFC, or 252). + * * @see MidiMessage#getStatus */ public static final int STOP = 0xFC; //252 /** * Status byte for Active Sensing message (0xFE, or 254). + * * @see MidiMessage#getStatus */ public static final int ACTIVE_SENSING = 0xFE; // 254 /** * Status byte for System Reset message (0xFF, or 255). + * * @see MidiMessage#getStatus */ public static final int SYSTEM_RESET = 0xFF; // 255 - // Channel voice message upper nibble defines /** - * Command value for Note Off message (0x80, or 128) + * Command value for Note Off message (0x80, or 128). */ public static final int NOTE_OFF = 0x80; // 128 /** - * Command value for Note On message (0x90, or 144) + * Command value for Note On message (0x90, or 144). */ public static final int NOTE_ON = 0x90; // 144 /** - * Command value for Polyphonic Key Pressure (Aftertouch) message (0xA0, or 160) + * Command value for Polyphonic Key Pressure (Aftertouch) message (0xA0, or + * 160). */ public static final int POLY_PRESSURE = 0xA0; // 160 /** - * Command value for Control Change message (0xB0, or 176) + * Command value for Control Change message (0xB0, or 176). */ public static final int CONTROL_CHANGE = 0xB0; // 176 /** - * Command value for Program Change message (0xC0, or 192) + * Command value for Program Change message (0xC0, or 192). */ public static final int PROGRAM_CHANGE = 0xC0; // 192 /** - * Command value for Channel Pressure (Aftertouch) message (0xD0, or 208) + * Command value for Channel Pressure (Aftertouch) message (0xD0, or 208). */ public static final int CHANNEL_PRESSURE = 0xD0; // 208 /** - * Command value for Pitch Bend message (0xE0, or 224) + * Command value for Pitch Bend message (0xE0, or 224). */ public static final int PITCH_BEND = 0xE0; // 224 - - // Instance variables - /** - * Constructs a new ShortMessage. The - * contents of the new message are guaranteed to specify - * a valid MIDI message. Subsequently, you may set the - * contents of the message using one of the setMessage - * methods. + * Constructs a new {@code ShortMessage}. The contents of the new message + * are guaranteed to specify a valid MIDI message. Subsequently, you may set + * the contents of the message using one of the {@code setMessage} methods. + * * @see #setMessage */ public ShortMessage() { @@ -188,14 +190,13 @@ public class ShortMessage extends MidiMessage { } /** - * Constructs a new {@code ShortMessage} which represents a MIDI - * message that takes no data bytes. - * The contents of the message can be changed by using one of - * the {@code setMessage} methods. + * Constructs a new {@code ShortMessage} which represents a MIDI message + * that takes no data bytes. The contents of the message can be changed by + * using one of the {@code setMessage} methods. * - * @param status the MIDI status byte - * @throws InvalidMidiDataException if {@code status} does not specify - * a valid MIDI status byte for a message that requires no data bytes + * @param status the MIDI status byte + * @throws InvalidMidiDataException if {@code status} does not specify a + * valid MIDI status byte for a message that requires no data bytes * @see #setMessage(int) * @see #setMessage(int, int, int) * @see #setMessage(int, int, int, int) @@ -210,16 +211,15 @@ public class ShortMessage extends MidiMessage { /** * Constructs a new {@code ShortMessage} which represents a MIDI message * that takes up to two data bytes. If the message only takes one data byte, - * the second data byte is ignored. If the message does not take - * any data bytes, both data bytes are ignored. - * The contents of the message can be changed by using one of - * the {@code setMessage} methods. + * the second data byte is ignored. If the message does not take any data + * bytes, both data bytes are ignored. The contents of the message can be + * changed by using one of the {@code setMessage} methods. * - * @param status the MIDI status byte - * @param data1 the first data byte - * @param data2 the second data byte + * @param status the MIDI status byte + * @param data1 the first data byte + * @param data2 the second data byte * @throws InvalidMidiDataException if the status byte or all data bytes - * belonging to the message do not specify a valid MIDI message + * belonging to the message do not specify a valid MIDI message * @see #setMessage(int) * @see #setMessage(int, int, int) * @see #setMessage(int, int, int, int) @@ -235,20 +235,19 @@ public class ShortMessage extends MidiMessage { } /** - * Constructs a new {@code ShortMessage} which represents a channel - * MIDI message that takes up to two data bytes. If the message only takes - * one data byte, the second data byte is ignored. If the message does not - * take any data bytes, both data bytes are ignored. - * The contents of the message can be changed by using one of - * the {@code setMessage} methods. + * Constructs a new {@code ShortMessage} which represents a channel MIDI + * message that takes up to two data bytes. If the message only takes one + * data byte, the second data byte is ignored. If the message does not take + * any data bytes, both data bytes are ignored. The contents of the message + * can be changed by using one of the {@code setMessage} methods. * - * @param command the MIDI command represented by this message - * @param channel the channel associated with the message - * @param data1 the first data byte - * @param data2 the second data byte - * @throws InvalidMidiDataException if the command value, channel value - * or all data bytes belonging to the message do not specify - * a valid MIDI message + * @param command the MIDI command represented by this message + * @param channel the channel associated with the message + * @param data1 the first data byte + * @param data2 the second data byte + * @throws InvalidMidiDataException if the command value, channel value or + * all data bytes belonging to the message do not specify a valid + * MIDI message * @see #setMessage(int) * @see #setMessage(int, int, int) * @see #setMessage(int, int, int, int) @@ -264,12 +263,11 @@ public class ShortMessage extends MidiMessage { setMessage(command, channel, data1, data2); } - /** - * Constructs a new ShortMessage. - * @param data an array of bytes containing the complete message. - * The message data may be changed using the setMessage - * method. + * Constructs a new {@code ShortMessage}. + * + * @param data an array of bytes containing the complete message. The + * message data may be changed using the {@code setMessage} method. * @see #setMessage */ // $$fb this should throw an Exception in case of an illegal message! @@ -279,12 +277,12 @@ public class ShortMessage extends MidiMessage { super(data); } - /** * Sets the parameters for a MIDI message that takes no data bytes. - * @param status the MIDI status byte - * @throws InvalidMidiDataException if status does not - * specify a valid MIDI status byte for a message that requires no data bytes. + * + * @param status the MIDI status byte + * @throws InvalidMidiDataException if {@code status} does not specify a + * valid MIDI status byte for a message that requires no data bytes * @see #setMessage(int, int, int) * @see #setMessage(int, int, int, int) */ @@ -297,19 +295,17 @@ public class ShortMessage extends MidiMessage { setMessage(status, 0, 0); } - /** - * Sets the parameters for a MIDI message that takes one or two data - * bytes. If the message takes only one data byte, the second data - * byte is ignored; if the message does not take any data bytes, both - * data bytes are ignored. + * Sets the parameters for a MIDI message that takes one or two data bytes. + * If the message takes only one data byte, the second data byte is ignored; + * if the message does not take any data bytes, both data bytes are ignored. * - * @param status the MIDI status byte - * @param data1 the first data byte - * @param data2 the second data byte - * @throws InvalidMidiDataException if the - * the status byte, or all data bytes belonging to the message, do - * not specify a valid MIDI message. + * @param status the MIDI status byte + * @param data1 the first data byte + * @param data2 the second data byte + * @throws InvalidMidiDataException if the the status byte, or all data + * bytes belonging to the message, do not specify a valid MIDI + * message * @see #setMessage(int, int, int, int) * @see #setMessage(int) */ @@ -345,22 +341,18 @@ public class ShortMessage extends MidiMessage { } } - /** - * Sets the short message parameters for a channel message - * which takes up to two data bytes. If the message only - * takes one data byte, the second data byte is ignored; if - * the message does not take any data bytes, both data bytes - * are ignored. - * - * @param command the MIDI command represented by this message - * @param channel the channel associated with the message - * @param data1 the first data byte - * @param data2 the second data byte - * @throws InvalidMidiDataException if the - * status byte or all data bytes belonging to the message, do - * not specify a valid MIDI message + * Sets the short message parameters for a channel message which takes up to + * two data bytes. If the message only takes one data byte, the second data + * byte is ignored; if the message does not take any data bytes, both data + * bytes are ignored. * + * @param command the MIDI command represented by this message + * @param channel the channel associated with the message + * @param data1 the first data byte + * @param data2 the second data byte + * @throws InvalidMidiDataException if the status byte or all data bytes + * belonging to the message, do not specify a valid MIDI message * @see #setMessage(int, int, int) * @see #setMessage(int) * @see #getCommand @@ -379,12 +371,12 @@ public class ShortMessage extends MidiMessage { setMessage((command & 0xF0) | (channel & 0x0F), data1, data2); } - /** - * Obtains the MIDI channel associated with this event. This method - * assumes that the event is a MIDI channel message; if not, the return - * value will not be meaningful. - * @return MIDI channel associated with the message. + * Obtains the MIDI channel associated with this event. This method assumes + * that the event is a MIDI channel message; if not, the return value will + * not be meaningful. + * + * @return MIDI channel associated with the message * @see #setMessage(int, int, int, int) */ public int getChannel() { @@ -392,11 +384,11 @@ public class ShortMessage extends MidiMessage { return (getStatus() & 0x0F); } - /** - * Obtains the MIDI command associated with this event. This method - * assumes that the event is a MIDI channel message; if not, the return - * value will not be meaningful. + * Obtains the MIDI command associated with this event. This method assumes + * that the event is a MIDI channel message; if not, the return value will + * not be meaningful. + * * @return the MIDI command associated with this event * @see #setMessage(int, int, int, int) */ @@ -405,10 +397,10 @@ public class ShortMessage extends MidiMessage { return (getStatus() & 0xF0); } - /** * Obtains the first data byte in the message. - * @return the value of the data1 field + * + * @return the value of the {@code data1} field * @see #setMessage(int, int, int) */ public int getData1() { @@ -418,10 +410,10 @@ public class ShortMessage extends MidiMessage { return 0; } - /** * Obtains the second data byte in the message. - * @return the value of the data2 field + * + * @return the value of the {@code data2} field * @see #setMessage(int, int, int) */ public int getData2() { @@ -431,11 +423,11 @@ public class ShortMessage extends MidiMessage { return 0; } - /** - * Creates a new object of the same class and with the same contents - * as this object. - * @return a clone of this instance. + * Creates a new object of the same class and with the same contents as this + * object. + * + * @return a clone of this instance */ public Object clone() { byte[] newData = new byte[length]; @@ -445,15 +437,15 @@ public class ShortMessage extends MidiMessage { return msg; } - /** - * Retrieves the number of data bytes associated with a particular - * status byte value. - * @param status status byte value, which must represent a short MIDI message + * Retrieves the number of data bytes associated with a particular status + * byte value. + * + * @param status status byte value, which must represent a short MIDI + * message * @return data length in bytes (0, 1, or 2) - * @throws InvalidMidiDataException if the - * status argument does not represent the status byte for any - * short message + * @throws InvalidMidiDataException if the {@code status} argument does not + * represent the status byte for any short message */ protected final int getDataLength(int status) throws InvalidMidiDataException { // system common and system real-time messages diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/Soundbank.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/Soundbank.java index 7aba05711c9..727365ea442 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/Soundbank.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/Soundbank.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -25,109 +25,101 @@ package javax.sound.midi; -import java.net.URL; - - /** - * A Soundbank contains a set of Instruments - * that can be loaded into a Synthesizer. - * Note that a Java Sound Soundbank is different from a MIDI bank. - * MIDI permits up to 16383 banks, each containing up to 128 instruments - * (also sometimes called programs, patches, or timbres). - * However, a Soundbank can contain 16383 times 128 instruments, - * because the instruments within a Soundbank are indexed by both - * a MIDI program number and a MIDI bank number (via a Patch - * object). Thus, a Soundbank can be thought of as a collection - * of MIDI banks. + * A {@code Soundbank} contains a set of {@code Instruments} that can be loaded + * into a {@code Synthesizer}. Note that a Java Sound {@code Soundbank} is + * different from a MIDI bank. MIDI permits up to 16383 banks, each containing + * up to 128 instruments (also sometimes called programs, patches, or timbres). + * However, a {@code Soundbank} can contain 16383 times 128 instruments, because + * the instruments within a {@code Soundbank} are indexed by both a MIDI program + * number and a MIDI bank number (via a {@code Patch} object). Thus, a + * {@code Soundbank} can be thought of as a collection of MIDI banks. *

    - * Soundbank includes methods that return String - * objects containing the sound bank's name, manufacturer, version number, and - * description. The precise content and format of these strings is left - * to the implementor. + * {@code Soundbank} includes methods that return {@code String} objects + * containing the sound bank's name, manufacturer, version number, and + * description. The precise content and format of these strings is left to the + * implementor. *

    - * Different synthesizers use a variety of synthesis techniques. A common - * one is wavetable synthesis, in which a segment of recorded sound is - * played back, often with looping and pitch change. The Downloadable Sound - * (DLS) format uses segments of recorded sound, as does the Headspace Engine. - * Soundbanks and Instruments that are based on - * wavetable synthesis (or other uses of stored sound recordings) should - * typically implement the getResources() - * method to provide access to these recorded segments. This is optional, - * however; the method can return an zero-length array if the synthesis technique - * doesn't use sampled sound (FM synthesis and physical modeling are examples - * of such techniques), or if it does but the implementor chooses not to make the - * samples accessible. + * Different synthesizers use a variety of synthesis techniques. A common one is + * wavetable synthesis, in which a segment of recorded sound is played back, + * often with looping and pitch change. The Downloadable Sound (DLS) format uses + * segments of recorded sound, as does the Headspace Engine. {@code Soundbanks} + * and {@code Instruments} that are based on wavetable synthesis (or other uses + * of stored sound recordings) should typically implement the + * {@code getResources()} method to provide access to these recorded segments. + * This is optional, however; the method can return an zero-length array if the + * synthesis technique doesn't use sampled sound (FM synthesis and physical + * modeling are examples of such techniques), or if it does but the implementor + * chooses not to make the samples accessible. * + * @author David Rivas + * @author Kara Kytle * @see Synthesizer#getDefaultSoundbank * @see Synthesizer#isSoundbankSupported * @see Synthesizer#loadInstruments(Soundbank, Patch[]) * @see Patch * @see Instrument * @see SoundbankResource - * - * @author David Rivas - * @author Kara Kytle */ - public interface Soundbank { - /** * Obtains the name of the sound bank. - * @return a String naming the sound bank + * + * @return a {@code String} naming the sound bank */ - public String getName(); + String getName(); /** * Obtains the version string for the sound bank. - * @return a String that indicates the sound bank's version + * + * @return a {@code String} that indicates the sound bank's version */ - public String getVersion(); + String getVersion(); /** - * Obtains a string naming the company that provides the - * sound bank + * Obtains a {@code string} naming the company that provides the sound bank. + * * @return the vendor string */ - public String getVendor(); + String getVendor(); /** * Obtains a textual description of the sound bank, suitable for display. - * @return a String that describes the sound bank + * + * @return a {@code String} that describes the sound bank */ - public String getDescription(); - + String getDescription(); /** * Extracts a list of non-Instrument resources contained in the sound bank. - * @return an array of resources, excluding instruments. If the sound bank contains - * no resources (other than instruments), returns an array of length 0. + * + * @return an array of resources, excluding instruments. If the sound bank + * contains no resources (other than instruments), returns an array + * of length 0. */ - public SoundbankResource[] getResources(); - + SoundbankResource[] getResources(); /** * Obtains a list of instruments contained in this sound bank. - * @return an array of the Instruments in this - * SoundBank - * If the sound bank contains no instruments, returns an array of length 0. * + * @return an array of the {@code Instruments} in this {@code SoundBank}. If + * the sound bank contains no instruments, returns an array of + * length 0. * @see Synthesizer#getLoadedInstruments * @see #getInstrument(Patch) */ - public Instrument[] getInstruments(); + Instrument[] getInstruments(); /** - * Obtains an Instrument from the given Patch. - * @param patch a Patch object specifying the bank index - * and program change number - * @return the requested instrument, or null if the - * sound bank doesn't contain that instrument + * Obtains an {@code Instrument} from the given {@code Patch}. * + * @param patch a {@code Patch} object specifying the bank index and + * program change number + * @return the requested instrument, or {@code null} if the sound bank + * doesn't contain that instrument * @see #getInstruments * @see Synthesizer#loadInstruments(Soundbank, Patch[]) */ - public Instrument getInstrument(Patch patch); - - + Instrument getInstrument(Patch patch); } diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/SoundbankResource.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/SoundbankResource.java index 52ba8f78feb..8ac530105eb 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/SoundbankResource.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/SoundbankResource.java @@ -25,81 +25,72 @@ package javax.sound.midi; +import javax.sound.sampled.AudioInputStream; + /** - * A SoundbankResource represents any audio resource stored - * in a {@link Soundbank}. Common soundbank resources include: + * A {@code SoundbankResource} represents any audio resource stored in a + * {@link Soundbank}. Common soundbank resources include: *

      - *
    • Instruments. An instrument may be specified in a variety of - * ways. However, all soundbanks have some mechanism for defining - * instruments. In doing so, they may reference other resources - * stored in the soundbank. Each instrument has a Patch - * which specifies the MIDI program and bank by which it may be - * referenced in MIDI messages. Instrument information may be - * stored in {@link Instrument} objects. - *
    • Audio samples. A sample typically is a sampled audio waveform - * which contains a short sound recording whose duration is a fraction of - * a second, or at most a few seconds. These audio samples may be - * used by a {@link Synthesizer} to synthesize sound in response to MIDI - * commands, or extracted for use by an application. - * (The terminology reflects musicians' use of the word "sample" to refer - * collectively to a series of contiguous audio samples or frames, rather than - * to a single, instantaneous sample.) - * The data class for an audio sample will be an object - * that encapsulates the audio sample data itself and information - * about how to interpret it (the format of the audio data), such - * as an {@link javax.sound.sampled.AudioInputStream}.
    • - *
    • Embedded sequences. A sound bank may contain built-in - * song data stored in a data object such as a {@link Sequence}. + *
    • Instruments. An instrument may be specified in a variety of ways. + * However, all soundbanks have some mechanism for defining instruments. In + * doing so, they may reference other resources stored in the soundbank. Each + * instrument has a {@code Patch} which specifies the MIDI program and bank by + * which it may be referenced in MIDI messages. Instrument information may be + * stored in {@link Instrument} objects.
    • + *
    • Audio samples. A sample typically is a sampled audio waveform which + * contains a short sound recording whose duration is a fraction of a second, or + * at most a few seconds. These audio samples may be used by a + * {@link Synthesizer} to synthesize sound in response to MIDI commands, or + * extracted for use by an application. (The terminology reflects musicians' use + * of the word "sample" to refer collectively to a series of contiguous audio + * samples or frames, rather than to a single, instantaneous sample.) The data + * class for an audio sample will be an object that encapsulates the audio + * sample data itself and information about how to interpret it (the format of + * the audio data), such as an {@link AudioInputStream}.
    • + *
    • Embedded sequences. A sound bank may contain built-in song data stored in + * a data object such as a {@link Sequence}.
    • *
    - *

    - * Synthesizers that use wavetable synthesis or related - * techniques play back the audio in a sample when - * synthesizing notes, often when emulating the real-world instrument that - * was originally recorded. However, there is not necessarily a one-to-one - * correspondence between the Instruments and samples - * in a Soundbank. A single Instrument can use - * multiple SoundbankResources (typically for notes of dissimilar pitch or - * brightness). Also, more than one Instrument can use the same - * sample. + * Synthesizers that use wavetable synthesis or related techniques play back the + * audio in a sample when synthesizing notes, often when emulating the + * real-world instrument that was originally recorded. However, there is not + * necessarily a one-to-one correspondence between the {@code Instruments} and + * samples in a {@code Soundbank}. A single {@code Instrument} can use multiple + * SoundbankResources (typically for notes of dissimilar pitch or brightness). + * Also, more than one {@code Instrument} can use the same sample. * * @author Kara Kytle */ - public abstract class SoundbankResource { - /** - * The sound bank that contains the SoundbankResources + * The sound bank that contains the {@code SoundbankResources}. */ private final Soundbank soundBank; - /** - * The name of the SoundbankResource + * The name of the {@code SoundbankResource}. */ private final String name; - /** * The class used to represent the sample's data. */ private final Class dataClass; - /** * The wavetable index. */ //private final int index; - /** - * Constructs a new SoundbankResource from the given sound bank - * and wavetable index. (Setting the SoundbankResource's name, - * sampled audio data, and instruments is a subclass responsibility.) - * @param soundBank the sound bank containing this SoundbankResource - * @param name the name of the sample - * @param dataClass the class used to represent the sample's data + * Constructs a new {@code SoundbankResource} from the given sound bank and + * wavetable index. (Setting the {@code SoundbankResource's} name, sampled + * audio data, and instruments is a subclass responsibility.) * + * @param soundBank the sound bank containing this + * {@code SoundbankResource} + * @param name the name of the sample + * @param dataClass the class used to represent the sample's data * @see #getSoundbank * @see #getName * @see #getDataClass @@ -112,65 +103,65 @@ public abstract class SoundbankResource { this.dataClass = dataClass; } - /** - * Obtains the sound bank that contains this SoundbankResource. - * @return the sound bank in which this SoundbankResource is stored + * Obtains the sound bank that contains this {@code SoundbankResource}. + * + * @return the sound bank in which this {@code SoundbankResource} is stored */ public Soundbank getSoundbank() { return soundBank; } - /** - * Obtains the name of the resource. This should generally be a string + * Obtains the name of the resource. This should generally be a string * descriptive of the resource. + * * @return the instrument's name */ public String getName() { return name; } - /** - * Obtains the class used by this sample to represent its data. - * The object returned by getData will be of this - * class. If this SoundbankResource object does not support - * direct access to its data, returns null. - * @return the class used to represent the sample's data, or - * null if the data is not accessible + * Obtains the class used by this sample to represent its data. The object + * returned by {@code getData} will be of this class. If this + * {@code SoundbankResource} object does not support direct access to its + * data, returns {@code null}. + * + * @return the class used to represent the sample's data, or null if the + * data is not accessible */ public Class getDataClass() { return dataClass; } - /** - * Obtains the sampled audio that is stored in this SoundbankResource. - * The type of object returned depends on the implementation of the - * concrete class, and may be queried using getDataClass. + * Obtains the sampled audio that is stored in this + * {@code SoundbankResource}. The type of object returned depends on the + * implementation of the concrete class, and may be queried using + * {@code getDataClass}. + * * @return an object containing the sampled audio data * @see #getDataClass */ public abstract Object getData(); - /** - * Obtains the index of this SoundbankResource into the - * Soundbank's set of SoundbankResources. + * Obtains the index of this {@code SoundbankResource} into the + * {@code Soundbank's} set of {@code SoundbankResources}. + * * @return the wavetable index */ //public int getIndex() { // return index; //} - /** * Obtains a list of the instruments in the sound bank that use the - * SoundbankResource for sound synthesis. - * @return an array of Instruments that reference this - * SoundbankResource + * {@code SoundbankResource} for sound synthesis. * + * @return an array of {@code Instruments} that reference this + * {@code SoundbankResource} * @see Instrument#getSamples */ //public abstract Instrument[] getInstruments(); diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/Synthesizer.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/Synthesizer.java index 6763a969504..3d8c7a64d23 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/Synthesizer.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/Synthesizer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -25,46 +25,43 @@ package javax.sound.midi; -import javax.sound.sampled.Control; - - /** - * A Synthesizer generates sound. This usually happens when one of - * the Synthesizer's {@link MidiChannel} objects receives a - * {@link MidiChannel#noteOn(int, int) noteOn} message, either - * directly or via the Synthesizer object. - * Many Synthesizers support Receivers, through which - * MIDI events can be delivered to the Synthesizer. - * In such cases, the Synthesizer typically responds by sending - * a corresponding message to the appropriate MidiChannel, or by - * processing the event itself if the event isn't one of the MIDI channel - * messages. + * A {@code Synthesizer} generates sound. This usually happens when one of the + * {@code Synthesizer}'s {@link MidiChannel} objects receives a + * {@link MidiChannel#noteOn(int, int) noteOn} message, either directly or via + * the {@code Synthesizer} object. Many {@code Synthesizer}s support + * {@code Receivers}, through which MIDI events can be delivered to the + * {@code Synthesizer}. In such cases, the {@code Synthesizer} typically + * responds by sending a corresponding message to the appropriate + * {@code MidiChannel}, or by processing the event itself if the event isn't one + * of the MIDI channel messages. *

    - * The Synthesizer interface includes methods for loading and - * unloading instruments from soundbanks. An instrument is a specification for synthesizing a - * certain type of sound, whether that sound emulates a traditional instrument or is - * some kind of sound effect or other imaginary sound. A soundbank is a collection of instruments, organized - * by bank and program number (via the instrument's Patch object). - * Different Synthesizer classes might implement different sound-synthesis - * techniques, meaning that some instruments and not others might be compatible with a - * given synthesizer. - * Also, synthesizers may have a limited amount of memory for instruments, meaning - * that not every soundbank and instrument can be used by every synthesizer, even if - * the synthesis technique is compatible. - * To see whether the instruments from - * a certain soundbank can be played by a given synthesizer, invoke the - * {@link #isSoundbankSupported(Soundbank) isSoundbankSupported} method of - * Synthesizer. + * The {@code Synthesizer} interface includes methods for loading and unloading + * instruments from soundbanks. An instrument is a specification for + * synthesizing a certain type of sound, whether that sound emulates a + * traditional instrument or is some kind of sound effect or other imaginary + * sound. A soundbank is a collection of instruments, organized by bank and + * program number (via the instrument's {@code Patch} object). Different + * {@code Synthesizer} classes might implement different sound-synthesis + * techniques, meaning that some instruments and not others might be compatible + * with a given synthesizer. Also, synthesizers may have a limited amount of + * memory for instruments, meaning that not every soundbank and instrument can + * be used by every synthesizer, even if the synthesis technique is compatible. + * To see whether the instruments from a certain soundbank can be played by a + * given synthesizer, invoke the + * {@link #isSoundbankSupported(Soundbank) isSoundbankSupported} + * method of {@code Synthesizer}. *

    * "Loading" an instrument means that that instrument becomes available for - * synthesizing notes. The instrument is loaded into the bank and - * program location specified by its Patch object. Loading does - * not necessarily mean that subsequently played notes will immediately have - * the sound of this newly loaded instrument. For the instrument to play notes, - * one of the synthesizer's MidiChannel objects must receive (or have received) - * a program-change message that causes that particular instrument's - * bank and program number to be selected. + * synthesizing notes. The instrument is loaded into the bank and program + * location specified by its {@code Patch} object. Loading does not necessarily + * mean that subsequently played notes will immediately have the sound of this + * newly loaded instrument. For the instrument to play notes, one of the + * synthesizer's {@code MidiChannel} objects must receive (or have received) a + * program-change message that causes that particular instrument's bank and + * program number to be selected. * + * @author Kara Kytle * @see MidiSystem#getSynthesizer * @see Soundbank * @see Instrument @@ -72,107 +69,103 @@ import javax.sound.sampled.Control; * @see Receiver * @see Transmitter * @see MidiDevice - * - * @author Kara Kytle */ public interface Synthesizer extends MidiDevice { - // SYNTHESIZER METHODS - /** - * Obtains the maximum number of notes that this synthesizer can sound simultaneously. + * Obtains the maximum number of notes that this synthesizer can sound + * simultaneously. + * * @return the maximum number of simultaneous notes * @see #getVoiceStatus */ - public int getMaxPolyphony(); - + int getMaxPolyphony(); /** * Obtains the processing latency incurred by this synthesizer, expressed in - * microseconds. This latency measures the worst-case delay between the - * time a MIDI message is delivered to the synthesizer and the time that the + * microseconds. This latency measures the worst-case delay between the time + * a MIDI message is delivered to the synthesizer and the time that the * synthesizer actually produces the corresponding result. *

    - * Although the latency is expressed in microseconds, a synthesizer's actual measured - * delay may vary over a wider range than this resolution suggests. For example, - * a synthesizer might have a worst-case delay of a few milliseconds or more. + * Although the latency is expressed in microseconds, a synthesizer's actual + * measured delay may vary over a wider range than this resolution suggests. + * For example, a synthesizer might have a worst-case delay of a few + * milliseconds or more. * * @return the worst-case delay, in microseconds */ - public long getLatency(); - + long getLatency(); /** - * Obtains the set of MIDI channels controlled by this synthesizer. Each - * non-null element in the returned array is a MidiChannel that + * Obtains the set of MIDI channels controlled by this synthesizer. Each + * non-null element in the returned array is a {@code MidiChannel} that * receives the MIDI messages sent on that channel number. *

    - * The MIDI 1.0 specification provides for 16 channels, so this - * method returns an array of at least 16 elements. However, if this synthesizer + * The MIDI 1.0 specification provides for 16 channels, so this method + * returns an array of at least 16 elements. However, if this synthesizer * doesn't make use of all 16 channels, some of the elements of the array - * might be null, so you should check each element - * before using it. - * @return an array of the MidiChannel objects managed by this - * Synthesizer. Some of the array elements may be null. + * might be {@code null}, so you should check each element before using it. + * + * @return an array of the {@code MidiChannel} objects managed by this + * {@code Synthesizer}. Some of the array elements may be + * {@code null}. */ - public MidiChannel[] getChannels(); - + MidiChannel[] getChannels(); /** - * Obtains the current status of the voices produced by this synthesizer. - * If this class of Synthesizer does not provide voice - * information, the returned array will always be of length 0. Otherwise, - * its length is always equal to the total number of voices, as returned by - * getMaxPolyphony(). (See the VoiceStatus class - * description for an explanation of synthesizer voices.) + * Obtains the current status of the voices produced by this synthesizer. If + * this class of {@code Synthesizer} does not provide voice information, the + * returned array will always be of length 0. Otherwise, its length is + * always equal to the total number of voices, as returned by + * {@code getMaxPolyphony()}. (See the {@code VoiceStatus} class description + * for an explanation of synthesizer voices.) * - * @return an array of VoiceStatus objects that supply - * information about the corresponding synthesizer voices + * @return an array of {@code VoiceStatus} objects that supply information + * about the corresponding synthesizer voices * @see #getMaxPolyphony * @see VoiceStatus */ - public VoiceStatus[] getVoiceStatus(); - + VoiceStatus[] getVoiceStatus(); /** * Informs the caller whether this synthesizer is capable of loading - * instruments from the specified soundbank. - * If the soundbank is unsupported, any attempts to load instruments from - * it will result in an IllegalArgumentException. - * @param soundbank soundbank for which support is queried - * @return true if the soundbank is supported, otherwise false + * instruments from the specified soundbank. If the soundbank is + * unsupported, any attempts to load instruments from it will result in an + * {@code IllegalArgumentException}. + * + * @param soundbank soundbank for which support is queried + * @return {@code true} if the soundbank is supported, otherwise + * {@code false} * @see #loadInstruments * @see #loadAllInstruments * @see #unloadInstruments * @see #unloadAllInstruments * @see #getDefaultSoundbank */ - public boolean isSoundbankSupported(Soundbank soundbank); - + boolean isSoundbankSupported(Soundbank soundbank); /** - * Makes a particular instrument available for synthesis. This instrument - * is loaded into the patch location specified by its Patch - * object, so that if a program-change message is - * received (or has been received) that causes that patch to be selected, - * subsequent notes will be played using the sound of - * instrument. If the specified instrument is already loaded, - * this method does nothing and returns true. + * Makes a particular instrument available for synthesis. This instrument is + * loaded into the patch location specified by its {@code Patch} object, so + * that if a program-change message is received (or has been received) that + * causes that patch to be selected, subsequent notes will be played using + * the sound of {@code instrument}. If the specified instrument is already + * loaded, this method does nothing and returns {@code true}. *

    - * The instrument must be part of a soundbank - * that this Synthesizer supports. (To make sure, you can use - * the getSoundbank method of Instrument and the - * isSoundbankSupported method of Synthesizer.) - * @param instrument instrument to load - * @return true if the instrument is successfully loaded (or - * already had been), false if the instrument could not be - * loaded (for example, if the synthesizer has insufficient - * memory to load it) - * @throws IllegalArgumentException if this - * Synthesizer doesn't support the specified instrument's - * soundbank + * The instrument must be part of a soundbank that this {@code Synthesizer} + * supports. (To make sure, you can use the {@code getSoundbank} method of + * {@code Instrument} and the {@code isSoundbankSupported} method of + * {@code Synthesizer}.) + * + * @param instrument instrument to load + * @return {@code true} if the instrument is successfully loaded (or already + * had been), {@code false} if the instrument could not be loaded + * (for example, if the synthesizer has insufficient memory to load + * it) + * @throws IllegalArgumentException if this {@code Synthesizer} doesn't + * support the specified instrument's soundbank * @see #unloadInstrument * @see #loadInstruments * @see #loadAllInstruments @@ -180,138 +173,139 @@ public interface Synthesizer extends MidiDevice { * @see SoundbankResource#getSoundbank * @see MidiChannel#programChange(int, int) */ - public boolean loadInstrument(Instrument instrument); - + boolean loadInstrument(Instrument instrument); /** * Unloads a particular instrument. - * @param instrument instrument to unload - * @throws IllegalArgumentException if this - * Synthesizer doesn't support the specified instrument's - * soundbank + * + * @param instrument instrument to unload + * @throws IllegalArgumentException if this {@code Synthesizer} doesn't + * support the specified instrument's soundbank * @see #loadInstrument * @see #unloadInstruments * @see #unloadAllInstruments * @see #getLoadedInstruments * @see #remapInstrument */ - public void unloadInstrument(Instrument instrument); - + void unloadInstrument(Instrument instrument); /** - * Remaps an instrument. Instrument to takes the - * place of instrument from.
    - * For example, if from was located at bank number 2, - * program number 11, remapping causes that bank and program location - * to be occupied instead by to.
    - * If the function succeeds, instrument from is unloaded. - *

    To cancel the remapping reload instrument from by - * invoking one of {@link #loadInstrument}, {@link #loadInstruments} - * or {@link #loadAllInstruments}. + * Remaps an instrument. Instrument {@code to} takes the place of instrument + * {@code from}. + *
    + * For example, if {@code from} was located at bank number 2, program number + * 11, remapping causes that bank and program location to be occupied + * instead by {@code to}. + *
    + * If the function succeeds, instrument {@code from} is unloaded. + *

    + * To cancel the remapping reload instrument {@code from} by invoking one of + * {@link #loadInstrument}, {@link #loadInstruments} or + * {@link #loadAllInstruments}. * - * @param from the Instrument object to be replaced - * @param to the Instrument object to be used in place - * of the old instrument, it should be loaded into the synthesizer - * @return true if the instrument successfully remapped, - * false if feature is not implemented by synthesizer - * @throws IllegalArgumentException if instrument - * from or instrument to aren't supported by - * synthesizer or if instrument to is not loaded - * @throws NullPointerException if from or - * to parameters have null value + * @param from the {@code Instrument} object to be replaced + * @param to the {@code Instrument} object to be used in place of the old + * instrument, it should be loaded into the synthesizer + * @return {@code true} if the instrument successfully remapped, + * {@code false} if feature is not implemented by synthesizer + * @throws IllegalArgumentException if instrument {@code from} or instrument + * {@code to} aren't supported by synthesizer or if instrument + * {@code to} is not loaded + * @throws NullPointerException if {@code from} or {@code to} parameters + * have null value * @see #loadInstrument * @see #loadInstruments * @see #loadAllInstruments */ - public boolean remapInstrument(Instrument from, Instrument to); - + boolean remapInstrument(Instrument from, Instrument to); /** - * Obtains the default soundbank for the synthesizer, if one exists. - * (Some synthesizers provide a default or built-in soundbank.) - * If a synthesizer doesn't have a default soundbank, instruments must - * be loaded explicitly from an external soundbank. - * @return default soundbank, or null if one does not exist. + * Obtains the default soundbank for the synthesizer, if one exists. (Some + * synthesizers provide a default or built-in soundbank.) If a synthesizer + * doesn't have a default soundbank, instruments must be loaded explicitly + * from an external soundbank. + * + * @return default soundbank, or {@code null} if one does not exist * @see #isSoundbankSupported */ - public Soundbank getDefaultSoundbank(); - + Soundbank getDefaultSoundbank(); /** - * Obtains a list of instruments that come with the synthesizer. These - * instruments might be built into the synthesizer, or they might be - * part of a default soundbank provided with the synthesizer, etc. + * Obtains a list of instruments that come with the synthesizer. These + * instruments might be built into the synthesizer, or they might be part of + * a default soundbank provided with the synthesizer, etc. *

    - * Note that you don't use this method to find out which instruments are + * Note that you don't use this method to find out which instruments are * currently loaded onto the synthesizer; for that purpose, you use - * getLoadedInstruments(). - * Nor does the method indicate all the instruments that can be loaded onto - * the synthesizer; it only indicates the subset that come with the synthesizer. - * To learn whether another instrument can be loaded, you can invoke - * isSoundbankSupported(), and if the instrument's - * Soundbank is supported, you can try loading the instrument. + * {@code getLoadedInstruments()}. Nor does the method indicate all the + * instruments that can be loaded onto the synthesizer; it only indicates + * the subset that come with the synthesizer. To learn whether another + * instrument can be loaded, you can invoke {@code isSoundbankSupported()}, + * and if the instrument's {@code Soundbank} is supported, you can try + * loading the instrument. * - * @return list of available instruments. If the synthesizer - * has no instruments coming with it, an array of length 0 is returned. + * @return list of available instruments. If the synthesizer has no + * instruments coming with it, an array of length 0 is returned. * @see #getLoadedInstruments * @see #isSoundbankSupported(Soundbank) * @see #loadInstrument */ - public Instrument[] getAvailableInstruments(); - + Instrument[] getAvailableInstruments(); /** * Obtains a list of the instruments that are currently loaded onto this - * Synthesizer. + * {@code Synthesizer}. + * * @return a list of currently loaded instruments * @see #loadInstrument * @see #getAvailableInstruments * @see Soundbank#getInstruments */ - public Instrument[] getLoadedInstruments(); - + Instrument[] getLoadedInstruments(); /** - * Loads onto the Synthesizer all instruments contained - * in the specified Soundbank. - * @param soundbank the Soundbank whose are instruments are - * to be loaded - * @return true if the instruments are all successfully loaded (or - * already had been), false if any instrument could not be - * loaded (for example, if the Synthesizer had insufficient memory) + * Loads onto the {@code Synthesizer} all instruments contained in the + * specified {@code Soundbank}. + * + * @param soundbank the {@code Soundbank} whose are instruments are to be + * loaded + * @return {@code true} if the instruments are all successfully loaded (or + * already had been), {@code false} if any instrument could not be + * loaded (for example, if the {@code Synthesizer} had insufficient + * memory) * @throws IllegalArgumentException if the requested soundbank is - * incompatible with this synthesizer. + * incompatible with this synthesizer * @see #isSoundbankSupported * @see #loadInstrument * @see #loadInstruments */ - public boolean loadAllInstruments(Soundbank soundbank); - - + boolean loadAllInstruments(Soundbank soundbank); /** - * Unloads all instruments contained in the specified Soundbank. - * @param soundbank soundbank containing instruments to unload - * @throws IllegalArgumentException thrown if the soundbank is not supported. + * Unloads all instruments contained in the specified {@code Soundbank}. + * + * @param soundbank soundbank containing instruments to unload + * @throws IllegalArgumentException thrown if the soundbank is not supported * @see #isSoundbankSupported * @see #unloadInstrument * @see #unloadInstruments */ - public void unloadAllInstruments(Soundbank soundbank); - + void unloadAllInstruments(Soundbank soundbank); /** * Loads the instruments referenced by the specified patches, from the - * specified Soundbank. Each of the Patch objects - * indicates a bank and program number; the Instrument that - * has the matching Patch is loaded into that bank and program - * location. - * @param soundbank the Soundbank containing the instruments to load - * @param patchList list of patches for which instruments should be loaded - * @return true if the instruments are all successfully loaded (or - * already had been), false if any instrument could not be - * loaded (for example, if the Synthesizer had insufficient memory) - * @throws IllegalArgumentException thrown if the soundbank is not supported. + * specified {@code Soundbank}. Each of the {@code Patch} objects indicates + * a bank and program number; the {@code Instrument} that has the matching + * {@code Patch} is loaded into that bank and program location. + * + * @param soundbank the {@code Soundbank} containing the instruments to + * load + * @param patchList list of patches for which instruments should be loaded + * @return {@code true} if the instruments are all successfully loaded (or + * already had been), {@code false} if any instrument could not be + * loaded (for example, if the {@code Synthesizer} had insufficient + * memory) + * @throws IllegalArgumentException thrown if the soundbank is not supported * @see #isSoundbankSupported * @see Instrument#getPatch * @see #loadAllInstruments @@ -319,76 +313,76 @@ public interface Synthesizer extends MidiDevice { * @see Soundbank#getInstrument(Patch) * @see Sequence#getPatchList() */ - public boolean loadInstruments(Soundbank soundbank, Patch[] patchList); + boolean loadInstruments(Soundbank soundbank, Patch[] patchList); /** - * Unloads the instruments referenced by the specified patches, from the MIDI sound bank specified. - * @param soundbank soundbank containing instruments to unload - * @param patchList list of patches for which instruments should be unloaded - * @throws IllegalArgumentException thrown if the soundbank is not supported. + * Unloads the instruments referenced by the specified patches, from the + * MIDI sound bank specified. * + * @param soundbank soundbank containing instruments to unload + * @param patchList list of patches for which instruments should be + * unloaded + * @throws IllegalArgumentException thrown if the soundbank is not supported * @see #unloadInstrument * @see #unloadAllInstruments * @see #isSoundbankSupported * @see Instrument#getPatch * @see #loadInstruments */ - public void unloadInstruments(Soundbank soundbank, Patch[] patchList); - + void unloadInstruments(Soundbank soundbank, Patch[] patchList); // RECEIVER METHODS /** * Obtains the name of the receiver. + * * @return receiver name */ - // public abstract String getName(); - + // abstract String getName(); /** * Opens the receiver. + * * @throws MidiUnavailableException if the receiver is cannot be opened, - * usually because the MIDI device is in use by another application. - * @throws SecurityException if the receiver cannot be opened due to security - * restrictions. + * usually because the MIDI device is in use by another application. + * @throws SecurityException if the receiver cannot be opened due to + * security restrictions */ - // public abstract void open() throws MidiUnavailableException, SecurityException; - + // abstract void open() throws MidiUnavailableException, SecurityException; /** * Closes the receiver. */ - // public abstract void close(); - + // abstract void close(); /** * Sends a MIDI event to the receiver. - * @param event event to send. - * @throws IllegalStateException if the receiver is not open. + * + * @param event event to send + * @throws IllegalStateException if the receiver is not open */ - // public void send(MidiEvent event) throws IllegalStateException { + // void send(MidiEvent event) throws IllegalStateException { // // } - /** - * Obtains the set of controls supported by the - * element. If no controls are supported, returns an - * array of length 0. + * Obtains the set of controls supported by the element. If no controls are + * supported, returns an array of length 0. + * * @return set of controls */ // $$kk: 03.04.99: josh bloch recommends getting rid of this: // what can you really do with a set of untyped controls?? - // $$kk: 03.05.99: i am putting this back in. for one thing, + // $$kk: 03.05.99: i am putting this back in. for one thing, // you can check the length and know whether you should keep // looking.... - // public Control[] getControls(); + // Control[] getControls(); /** * Obtains the specified control. - * @param controlClass class of the requested control - * @return requested control object, or null if the - * control is not supported. + * + * @param controlClass class of the requested control + * @return requested control object, or null if the control is not supported */ - // public Control getControl(Class controlClass); + // Control getControl(Class controlClass); } diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/SysexMessage.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/SysexMessage.java index ae4e418e8e6..8bcd00a9030 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/SysexMessage.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/SysexMessage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -26,47 +26,47 @@ package javax.sound.midi; /** - * A SysexMessage object represents a MIDI system exclusive message. + * A {@code SysexMessage} object represents a MIDI system exclusive message. *

    - * When a system exclusive message is read from a MIDI file, it always has - * a defined length. Data from a system exclusive message from a MIDI file - * should be stored in the data array of a SysexMessage as - * follows: the system exclusive message status byte (0xF0 or 0xF7), all - * message data bytes, and finally the end-of-exclusive flag (0xF7). - * The length reported by the SysexMessage object is therefore - * the length of the system exclusive data plus two: one byte for the status - * byte and one for the end-of-exclusive flag. + * When a system exclusive message is read from a MIDI file, it always has a + * defined length. Data from a system exclusive message from a MIDI file should + * be stored in the data array of a {@code SysexMessage} as follows: the system + * exclusive message status byte (0xF0 or 0xF7), all message data bytes, and + * finally the end-of-exclusive flag (0xF7). The length reported by the + * {@code SysexMessage} object is therefore the length of the system exclusive + * data plus two: one byte for the status byte and one for the end-of-exclusive + * flag. *

    - * As dictated by the Standard MIDI Files specification, two status byte values are legal - * for a SysexMessage read from a MIDI file: + * As dictated by the Standard MIDI Files specification, two status byte values + * are legal for a {@code SysexMessage} read from a MIDI file: *

      *
    • 0xF0: System Exclusive message (same as in MIDI wire protocol)
    • *
    • 0xF7: Special System Exclusive message
    • *
    - *

    - * When Java Sound is used to handle system exclusive data that is being received - * using MIDI wire protocol, it should place the data in one or more - * SysexMessages. In this case, the length of the system exclusive data + * When Java Sound is used to handle system exclusive data that is being + * received using MIDI wire protocol, it should place the data in one or more + * {@code SysexMessages}. In this case, the length of the system exclusive data * is not known in advance; the end of the system exclusive data is marked by an * end-of-exclusive flag (0xF7) in the MIDI wire byte stream. *

      *
    • 0xF0: System Exclusive message (same as in MIDI wire protocol)
    • *
    • 0xF7: End of Exclusive (EOX)
    • *
    - * The first SysexMessage object containing data for a particular system - * exclusive message should have the status value 0xF0. If this message contains all - * the system exclusive data - * for the message, it should end with the status byte 0xF7 (EOX). - * Otherwise, additional system exclusive data should be sent in one or more - * SysexMessages with a status value of 0xF7. The SysexMessage - * containing the last of the data for the system exclusive message should end with the - * value 0xF7 (EOX) to mark the end of the system exclusive message. + * The first {@code SysexMessage} object containing data for a particular system + * exclusive message should have the status value 0xF0. If this message contains + * all the system exclusive data for the message, it should end with the status + * byte 0xF7 (EOX). Otherwise, additional system exclusive data should be sent + * in one or more {@code SysexMessages} with a status value of 0xF7. The + * {@code SysexMessage} containing the last of the data for the system exclusive + * message should end with the value 0xF7 (EOX) to mark the end of the system + * exclusive message. *

    - * If system exclusive data from SysexMessages objects is being transmitted - * using MIDI wire protocol, only the initial 0xF0 status byte, the system exclusive - * data itself, and the final 0xF7 (EOX) byte should be propagated; any 0xF7 status - * bytes used to indicate that a SysexMessage contains continuing system - * exclusive data should not be propagated via MIDI wire protocol. + * If system exclusive data from {@code SysexMessages} objects is being + * transmitted using MIDI wire protocol, only the initial 0xF0 status byte, the + * system exclusive data itself, and the final 0xF7 (EOX) byte should be + * propagated; any 0xF7 status bytes used to indicate that a + * {@code SysexMessage} contains continuing system exclusive data should not be + * propagated via MIDI wire protocol. * * @author David Rivas * @author Kara Kytle @@ -74,43 +74,36 @@ package javax.sound.midi; */ public class SysexMessage extends MidiMessage { - // Status byte defines - /** * Status byte for System Exclusive message (0xF0, or 240). + * * @see MidiMessage#getStatus */ public static final int SYSTEM_EXCLUSIVE = 0xF0; // 240 - /** - * Status byte for Special System Exclusive message (0xF7, or 247), which is used - * in MIDI files. It has the same value as END_OF_EXCLUSIVE, which - * is used in the real-time "MIDI wire" protocol. + * Status byte for Special System Exclusive message (0xF7, or 247), which is + * used in MIDI files. It has the same value as END_OF_EXCLUSIVE, which is + * used in the real-time "MIDI wire" protocol. + * * @see MidiMessage#getStatus */ public static final int SPECIAL_SYSTEM_EXCLUSIVE = 0xF7; // 247 - - // Instance variables - - - /* - * The data bytes for this system exclusive message. These are - * initialized to null and are set explicitly - * by {@link #setMessage(int, byte[], int, long) setMessage}. + /** + * The data bytes for this system exclusive message. These are initialized + * to {@code null} and are set explicitly by + * {@link #setMessage(int, byte[], int, long) setMessage}. */ //protected byte[] data = null; - /** - * Constructs a new SysexMessage. The - * contents of the new message are guaranteed to specify - * a valid MIDI message. Subsequently, you may set the - * contents of the message using one of the setMessage - * methods. + * Constructs a new {@code SysexMessage}. The contents of the new message + * are guaranteed to specify a valid MIDI message. Subsequently, you may set + * the contents of the message using one of the {@code setMessage} methods. + * * @see #setMessage */ public SysexMessage() { @@ -121,18 +114,17 @@ public class SysexMessage extends MidiMessage { } /** - * Constructs a new {@code SysexMessage} and sets the data for - * the message. The first byte of the data array must be a valid system - * exclusive status byte (0xF0 or 0xF7). - * The contents of the message can be changed by using one of - * the {@code setMessage} methods. + * Constructs a new {@code SysexMessage} and sets the data for the message. + * The first byte of the data array must be a valid system exclusive status + * byte (0xF0 or 0xF7). The contents of the message can be changed by using + * one of the {@code setMessage} methods. * - * @param data the system exclusive message data including the status byte - * @param length the length of the valid message data in the array, - * including the status byte; it should be non-negative and less than - * or equal to {@code data.length} - * @throws InvalidMidiDataException if the parameter values - * do not specify a valid MIDI meta message. + * @param data the system exclusive message data including the status byte + * @param length the length of the valid message data in the array, + * including the status byte; it should be non-negative and less + * than or equal to {@code data.length} + * @throws InvalidMidiDataException if the parameter values do not specify a + * valid MIDI meta message. * @see #setMessage(byte[], int) * @see #setMessage(int, byte[], int) * @see #getData() @@ -146,17 +138,17 @@ public class SysexMessage extends MidiMessage { /** * Constructs a new {@code SysexMessage} and sets the data for the message. - * The contents of the message can be changed by using one of - * the {@code setMessage} methods. + * The contents of the message can be changed by using one of the + * {@code setMessage} methods. * - * @param status the status byte for the message; it must be a valid system - * exclusive status byte (0xF0 or 0xF7) - * @param data the system exclusive message data (without the status byte) - * @param length the length of the valid message data in the array; - * it should be non-negative and less than or equal to - * {@code data.length} - * @throws InvalidMidiDataException if the parameter values - * do not specify a valid MIDI meta message. + * @param status the status byte for the message; it must be a valid system + * exclusive status byte (0xF0 or 0xF7) + * @param data the system exclusive message data (without the status byte) + * @param length the length of the valid message data in the array; it + * should be non-negative and less than or equal to + * {@code data.length} + * @throws InvalidMidiDataException if the parameter values do not specify a + * valid MIDI meta message * @see #setMessage(byte[], int) * @see #setMessage(int, byte[], int) * @see #getData() @@ -168,26 +160,24 @@ public class SysexMessage extends MidiMessage { setMessage(status, data, length); } - /** - * Constructs a new SysexMessage. - * @param data an array of bytes containing the complete message. - * The message data may be changed using the setMessage - * method. + * Constructs a new {@code SysexMessage}. + * + * @param data an array of bytes containing the complete message. The + * message data may be changed using the {@code setMessage} method. * @see #setMessage */ protected SysexMessage(byte[] data) { super(data); } - /** - * Sets the data for the system exclusive message. The - * first byte of the data array must be a valid system - * exclusive status byte (0xF0 or 0xF7). - * @param data the system exclusive message data - * @param length the length of the valid message data in - * the array, including the status byte. + * Sets the data for the system exclusive message. The first byte of the + * data array must be a valid system exclusive status byte (0xF0 or 0xF7). + * + * @param data the system exclusive message data + * @param length the length of the valid message data in the array, + * including the status byte */ public void setMessage(byte[] data, int length) throws InvalidMidiDataException { int status = (data[0] & 0xFF); @@ -197,14 +187,14 @@ public class SysexMessage extends MidiMessage { super.setMessage(data, length); } - /** * Sets the data for the system exclusive message. - * @param status the status byte for the message (0xF0 or 0xF7) - * @param data the system exclusive message data - * @param length the length of the valid message data in - * the array - * @throws InvalidMidiDataException if the status byte is invalid for a sysex message + * + * @param status the status byte for the message (0xF0 or 0xF7) + * @param data the system exclusive message data + * @param length the length of the valid message data in the array + * @throws InvalidMidiDataException if the status byte is invalid for a + * sysex message */ public void setMessage(int status, byte[] data, int length) throws InvalidMidiDataException { if ( (status != 0xF0) && (status != 0xF7) ) { @@ -225,11 +215,11 @@ public class SysexMessage extends MidiMessage { } } - /** - * Obtains a copy of the data for the system exclusive message. - * The returned array of bytes does not include the status byte. - * @return array containing the system exclusive message data. + * Obtains a copy of the data for the system exclusive message. The returned + * array of bytes does not include the status byte. + * + * @return array containing the system exclusive message data */ public byte[] getData() { byte[] returnedArray = new byte[length - 1]; @@ -237,10 +227,10 @@ public class SysexMessage extends MidiMessage { return returnedArray; } - /** - * Creates a new object of the same class and with the same contents - * as this object. + * Creates a new object of the same class and with the same contents as this + * object. + * * @return a clone of this instance */ public Object clone() { diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/Track.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/Track.java index d9e0f438b6c..95a42c7f703 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/Track.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/Track.java @@ -25,41 +25,40 @@ package javax.sound.midi; -import java.util.Vector; import java.util.ArrayList; import java.util.HashSet; + import com.sun.media.sound.MidiUtils; /** - * A MIDI track is an independent stream of MIDI events (time-stamped MIDI - * data) that can be stored along with other tracks in a standard MIDI file. - * The MIDI specification allows only 16 channels of MIDI data, but tracks - * are a way to get around this limitation. A MIDI file can contain any number - * of tracks, each containing its own stream of up to 16 channels of MIDI data. + * A MIDI track is an independent stream of MIDI events (time-stamped MIDI data) + * that can be stored along with other tracks in a standard MIDI file. The MIDI + * specification allows only 16 channels of MIDI data, but tracks are a way to + * get around this limitation. A MIDI file can contain any number of tracks, + * each containing its own stream of up to 16 channels of MIDI data. *

    - * A Track occupies a middle level in the hierarchy of data played - * by a {@link Sequencer}: sequencers play sequences, which contain tracks, - * which contain MIDI events. A sequencer may provide controls that mute - * or solo individual tracks. + * A {@code Track} occupies a middle level in the hierarchy of data played by a + * {@link Sequencer}: sequencers play sequences, which contain tracks, which + * contain MIDI events. A sequencer may provide controls that mute or solo + * individual tracks. *

    * The timing information and resolution for a track is controlled by and stored - * in the sequence containing the track. A given Track - * is considered to belong to the particular {@link Sequence} that - * maintains its timing. For this reason, a new (empty) track is created by calling the - * {@link Sequence#createTrack} method, rather than by directly invoking a - * Track constructor. + * in the sequence containing the track. A given {@code Track} is considered to + * belong to the particular {@link Sequence} that maintains its timing. For this + * reason, a new (empty) track is created by calling the + * {@link Sequence#createTrack} method, rather than by directly invoking a + * {@code Track} constructor. *

    - * The Track class provides methods to edit the track by adding - * or removing MidiEvent objects from it. These operations keep - * the event list in the correct time order. Methods are also - * included to obtain the track's size, in terms of either the number of events - * it contains or its duration in ticks. - * - * @see Sequencer#setTrackMute - * @see Sequencer#setTrackSolo + * The {@code Track} class provides methods to edit the track by adding or + * removing {@code MidiEvent} objects from it. These operations keep the event + * list in the correct time order. Methods are also included to obtain the + * track's size, in terms of either the number of events it contains or its + * duration in ticks. * * @author Kara Kytle * @author Florian Bomers + * @see Sequencer#setTrackMute + * @see Sequencer#setTrackSolo */ public class Track { @@ -73,10 +72,9 @@ public class Track { private MidiEvent eotEvent; - /** - * Package-private constructor. Constructs a new, empty Track object, - * which initially contains one event, the meta-event End of Track. + * Package-private constructor. Constructs a new, empty Track object, which + * initially contains one event, the meta-event End of Track. */ Track() { // start with the end of track event @@ -87,14 +85,14 @@ public class Track { } /** - * Adds a new event to the track. However, if the event is already - * contained in the track, it is not added again. The list of events - * is kept in time order, meaning that this event inserted at the - * appropriate place in the list, not necessarily at the end. + * Adds a new event to the track. However, if the event is already contained + * in the track, it is not added again. The list of events is kept in time + * order, meaning that this event inserted at the appropriate place in the + * list, not necessarily at the end. * - * @param event the event to add - * @return true if the event did not already exist in the - * track and was added, otherwise false + * @param event the event to add + * @return {@code true} if the event did not already exist in the track and + * was added, otherwise {@code false} */ public boolean add(MidiEvent event) { if (event == null) { @@ -176,12 +174,12 @@ public class Track { return false; } - /** * Removes the specified event from the track. - * @param event the event to remove - * @return true if the event existed in the track and was removed, - * otherwise false + * + * @param event the event to remove + * @return {@code true} if the event existed in the track and was removed, + * otherwise {@code false} */ public boolean remove(MidiEvent event) { @@ -207,15 +205,14 @@ public class Track { return false; } - /** * Obtains the event at the specified index. - * @param index the location of the desired event in the event vector - * @throws ArrayIndexOutOfBoundsException if the - * specified index is negative or not less than the current size of - * this track. - * @see #size + * + * @param index the location of the desired event in the event vector * @return the event at the specified index + * @throws ArrayIndexOutOfBoundsException if the specified index is negative + * or not less than the current size of this track + * @see #size */ public MidiEvent get(int index) throws ArrayIndexOutOfBoundsException { try { @@ -227,9 +224,9 @@ public class Track { } } - /** * Obtains the number of events in this track. + * * @return the size of the track's event vector */ public int size() { @@ -238,12 +235,12 @@ public class Track { } } - /** - * Obtains the length of the track, expressed in MIDI ticks. (The - * duration of a tick in seconds is determined by the timing resolution - * of the Sequence containing this track, and also by - * the tempo of the music as set by the sequencer.) + * Obtains the length of the track, expressed in MIDI ticks. (The duration + * of a tick in seconds is determined by the timing resolution of the + * {@code Sequence} containing this track, and also by the tempo of the + * music as set by the sequencer.) + * * @return the duration, in ticks * @see Sequence#Sequence(float, int) * @see Sequencer#setTempoInBPM(float) @@ -271,5 +268,4 @@ public class Track { throw new InvalidMidiDataException("cannot modify end of track message"); } } - } diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/Transmitter.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/Transmitter.java index e78b800c728..639aa2c750d 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/Transmitter.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/Transmitter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -25,52 +25,49 @@ package javax.sound.midi; - /** - * A Transmitter sends {@link MidiEvent} objects to one or more - * {@link Receiver Receivers}. Common MIDI transmitters include sequencers - * and MIDI input ports. - * - * @see Receiver + * A {@code Transmitter} sends {@link MidiEvent} objects to one or more + * {@link Receiver Receivers}. Common MIDI transmitters include sequencers and + * MIDI input ports. * * @author Kara Kytle + * @see Receiver */ public interface Transmitter extends AutoCloseable { - /** * Sets the receiver to which this transmitter will deliver MIDI messages. * If a receiver is currently set, it is replaced with this one. - * @param receiver the desired receiver. + * + * @param receiver the desired receiver */ - public void setReceiver(Receiver receiver); - + void setReceiver(Receiver receiver); /** - * Obtains the current receiver to which this transmitter will deliver MIDI messages. - * @return the current receiver. If no receiver is currently set, - * returns null + * Obtains the current receiver to which this transmitter will deliver MIDI + * messages. + * + * @return the current receiver. If no receiver is currently set, returns + * {@code null}. */ - public Receiver getReceiver(); - + Receiver getReceiver(); /** * Indicates that the application has finished using the transmitter, and * that limited resources it requires may be released or made available. - * - *

    If the creation of this Transmitter resulted in - * implicitly opening the underlying device, the device is - * implicitly closed by this method. This is true unless the device is - * kept open by other Receiver or Transmitter - * instances that opened the device implicitly, and unless the device - * has been opened explicitly. If the device this - * Transmitter is retrieved from is closed explicitly - * by calling {@link MidiDevice#close MidiDevice.close}, the - * Transmitter is closed, too. For a detailed - * description of open/close behaviour see the class description - * of {@link javax.sound.midi.MidiDevice MidiDevice}. + *

    + * If the creation of this {@code Transmitter} resulted in implicitly + * opening the underlying device, the device is implicitly closed by this + * method. This is true unless the device is kept open by other + * {@code Receiver} or {@code Transmitter} instances that opened the device + * implicitly, and unless the device has been opened explicitly. If the + * device this {@code Transmitter} is retrieved from is closed explicitly by + * calling {@link MidiDevice#close MidiDevice.close}, the + * {@code Transmitter} is closed, too. For a detailed description of + * open/close behaviour see the class description of + * {@link MidiDevice MidiDevice}. * * @see javax.sound.midi.MidiSystem#getTransmitter */ - public void close(); + void close(); } diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/VoiceStatus.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/VoiceStatus.java index 45f2e4d964c..2d679613e01 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/VoiceStatus.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/VoiceStatus.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -25,93 +25,83 @@ package javax.sound.midi; - /** - * A VoiceStatus object contains information about the current - * status of one of the voices produced by a {@link Synthesizer}. + * A {@code VoiceStatus} object contains information about the current status of + * one of the voices produced by a {@link Synthesizer}. *

    * MIDI synthesizers are generally capable of producing some maximum number of - * simultaneous notes, also referred to as voices. A voice is a stream - * of successive single notes, and the process of assigning incoming MIDI notes to - * specific voices is known as voice allocation. - * However, the voice-allocation algorithm and the contents of each voice are - * normally internal to a MIDI synthesizer and hidden from outside view. One can, of - * course, learn from MIDI messages which notes the synthesizer is playing, and - * one might be able deduce something about the assignment of notes to voices. - * But MIDI itself does not provide a means to report which notes a - * synthesizer has assigned to which voice, nor even to report how many voices - * the synthesizer is capable of synthesizing. + * simultaneous notes, also referred to as voices. A voice is a stream of + * successive single notes, and the process of assigning incoming MIDI notes to + * specific voices is known as voice allocation. However, the voice-allocation + * algorithm and the contents of each voice are normally internal to a MIDI + * synthesizer and hidden from outside view. One can, of course, learn from MIDI + * messages which notes the synthesizer is playing, and one might be able deduce + * something about the assignment of notes to voices. But MIDI itself does not + * provide a means to report which notes a synthesizer has assigned to which + * voice, nor even to report how many voices the synthesizer is capable of + * synthesizing. *

    - * In Java Sound, however, a - * Synthesizer class can expose the contents of its voices through its - * {@link Synthesizer#getVoiceStatus() getVoiceStatus()} method. - * This behavior is recommended but optional; - * synthesizers that don't expose their voice allocation simply return a - * zero-length array. A Synthesizer that does report its voice status - * should maintain this information at - * all times for all of its voices, whether they are currently sounding or - * not. In other words, a given type of Synthesizer always has a fixed - * number of voices, equal to the maximum number of simultaneous notes it is - * capable of sounding. + * In Java Sound, however, a {@code Synthesizer} class can expose the contents + * of its voices through its + * {@link Synthesizer#getVoiceStatus() getVoiceStatus()} method. This behavior + * is recommended but optional; synthesizers that don't expose their voice + * allocation simply return a zero-length array. A {@code Synthesizer} that does + * report its voice status should maintain this information at all times for all + * of its voices, whether they are currently sounding or not. In other words, a + * given type of {@code Synthesizer} always has a fixed number of voices, equal + * to the maximum number of simultaneous notes it is capable of sounding. *

    - * - * If the voice is not currently processing a MIDI note, it - * is considered inactive. A voice is inactive when it has - * been given no note-on commands, or when every note-on command received has - * been terminated by a corresponding note-off (or by an "all notes off" - * message). For example, this happens when a synthesizer capable of playing 16 - * simultaneous notes is told to play a four-note chord; only - * four voices are active in this case (assuming no earlier notes are still playing). - * Usually, a voice whose status is reported as active is producing audible sound, but this - * is not always true; it depends on the details of the instrument (that - * is, the synthesis algorithm) and how long the note has been going on. - * For example, a voice may be synthesizing the sound of a single hand-clap. Because - * this sound dies away so quickly, it may become inaudible before a note-off - * message is received. In such a situation, the voice is still considered active - * even though no sound is currently being produced. + * If the voice is not currently processing + * a MIDI note, it is considered inactive. A voice is inactive when it has been + * given no note-on commands, or when every note-on command received has been + * terminated by a corresponding note-off (or by an "all notes off" message). + * For example, this happens when a synthesizer capable of playing 16 + * simultaneous notes is told to play a four-note chord; only four voices are + * active in this case (assuming no earlier notes are still playing). Usually, a + * voice whose status is reported as active is producing audible sound, but this + * is not always true; it depends on the details of the instrument (that is, the + * synthesis algorithm) and how long the note has been going on. For example, a + * voice may be synthesizing the sound of a single hand-clap. Because this sound + * dies away so quickly, it may become inaudible before a note-off message is + * received. In such a situation, the voice is still considered active even + * though no sound is currently being produced. *

    - * Besides its active or inactive status, the VoiceStatus class - * provides fields that reveal the voice's current MIDI channel, bank and - * program number, MIDI note number, and MIDI volume. All of these can - * change during the course of a voice. While the voice is inactive, each - * of these fields has an unspecified value, so you should check the active - * field first. - * - * @see Synthesizer#getMaxPolyphony - * @see Synthesizer#getVoiceStatus + * Besides its active or inactive status, the {@code VoiceStatus} class provides + * fields that reveal the voice's current MIDI channel, bank and program number, + * MIDI note number, and MIDI volume. All of these can change during the course + * of a voice. While the voice is inactive, each of these fields has an + * unspecified value, so you should check the active field first. * * @author David Rivas * @author Kara Kytle + * @see Synthesizer#getMaxPolyphony + * @see Synthesizer#getVoiceStatus */ - public class VoiceStatus { - /** - * Indicates whether the voice is currently processing a MIDI note. - * See the explanation of - * active and inactive voices. + * Indicates whether the voice is currently processing a MIDI note. See the + * explanation of + * active and inactive voices. */ public boolean active = false; - /** - * The MIDI channel on which this voice is playing. The value is a - * zero-based channel number if the voice is active, or - * unspecified if the voice is inactive. + * The MIDI channel on which this voice is playing. The value is a + * zero-based channel number if the voice is active, or unspecified if the + * voice is inactive. * * @see MidiChannel * @see #active */ public int channel = 0; - /** * The bank number of the instrument that this voice is currently using. * This is a number dictated by the MIDI bank-select message; it does not - * refer to a SoundBank object. - * The value ranges from 0 to 16383 if the voice is active, and is - * unspecified if the voice is inactive. + * refer to a {@code SoundBank} object. The value ranges from 0 to 16383 if + * the voice is active, and is unspecified if the voice is inactive. + * * @see Patch * @see Soundbank * @see #active @@ -119,11 +109,10 @@ public class VoiceStatus { */ public int bank = 0; - /** * The program number of the instrument that this voice is currently using. - * The value ranges from 0 to 127 if the voice is active, and is - * unspecified if the voice is inactive. + * The value ranges from 0 to 127 if the voice is active, and is unspecified + * if the voice is inactive. * * @see MidiChannel#getProgram * @see Patch @@ -131,28 +120,24 @@ public class VoiceStatus { */ public int program = 0; - /** - * The MIDI note that this voice is playing. The range for an active voice - * is from 0 to 127 in semitones, with 60 referring to Middle C. - * The value is unspecified if the voice is inactive. + * The MIDI note that this voice is playing. The range for an active voice + * is from 0 to 127 in semitones, with 60 referring to Middle C. The value + * is unspecified if the voice is inactive. * * @see MidiChannel#noteOn * @see #active */ public int note = 0; - /** - * The current MIDI volume level for the voice. - * The value ranges from 0 to 127 if the voice is active, and is - * unspecified if the voice is inactive. + * The current MIDI volume level for the voice. The value ranges from 0 to + * 127 if the voice is active, and is unspecified if the voice is inactive. *

    - * Note that this value does not necessarily reflect - * the instantaneous level of the sound produced by this - * voice; that level is the result of many contributing - * factors, including the current instrument and the - * shape of the amplitude envelope it produces. + * Note that this value does not necessarily reflect the instantaneous level + * of the sound produced by this voice; that level is the result of many + * contributing factors, including the current instrument and the shape of + * the amplitude envelope it produces. * * @see #active */ diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/spi/MidiFileReader.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/spi/MidiFileReader.java index ecb72b32dd2..bbdca9e97bb 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/spi/MidiFileReader.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/spi/MidiFileReader.java @@ -26,13 +26,13 @@ package javax.sound.midi.spi; import java.io.File; -import java.io.InputStream; import java.io.IOException; +import java.io.InputStream; import java.net.URL; +import javax.sound.midi.InvalidMidiDataException; import javax.sound.midi.MidiFileFormat; import javax.sound.midi.Sequence; -import javax.sound.midi.InvalidMidiDataException; /** * A {@code MidiFileReader} supplies MIDI file-reading services. Classes @@ -106,7 +106,7 @@ public abstract class MidiFileReader { * @param stream the input stream from which the {@code Sequence} should * be constructed * @return a {@code Sequence} object based on the MIDI file data contained - * in the input stream. + * in the input stream * @throws InvalidMidiDataException if the stream does not point to valid * MIDI file data recognized by the system * @throws IOException if an I/O exception occurs diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/spi/SoundbankReader.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/spi/SoundbankReader.java index c7e82d9960f..501c18b6ad5 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/spi/SoundbankReader.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/spi/SoundbankReader.java @@ -32,12 +32,12 @@ import java.net.URL; import javax.sound.midi.InvalidMidiDataException; import javax.sound.midi.Soundbank; +import javax.sound.midi.Synthesizer; /** * A {@code SoundbankReader} supplies soundbank file-reading services. Concrete * subclasses of {@code SoundbankReader} parse a given soundbank file, producing - * a {@link javax.sound.midi.Soundbank} object that can be loaded into a - * {@link javax.sound.midi.Synthesizer}. + * a {@link Soundbank} object that can be loaded into a {@link Synthesizer}. * * @since 1.3 * @author Kara Kytle @@ -47,7 +47,7 @@ public abstract class SoundbankReader { /** * Obtains a soundbank object from the URL provided. * - * @param url URL representing the soundbank. + * @param url URL representing the soundbank * @return soundbank object * @throws InvalidMidiDataException if the URL does not point to valid MIDI * soundbank data recognized by this soundbank reader diff --git a/jdk/src/java.desktop/share/classes/javax/sound/sampled/AudioSystem.java b/jdk/src/java.desktop/share/classes/javax/sound/sampled/AudioSystem.java index 459ef997855..db528aebb83 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/AudioSystem.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/AudioSystem.java @@ -26,19 +26,19 @@ package javax.sound.sampled; import java.io.File; -import java.io.InputStream; import java.io.IOException; +import java.io.InputStream; import java.io.OutputStream; import java.net.URL; - +import java.util.ArrayList; import java.util.HashSet; import java.util.List; +import java.util.Properties; import java.util.Set; import java.util.Vector; -import java.util.ArrayList; -import javax.sound.sampled.spi.AudioFileWriter; import javax.sound.sampled.spi.AudioFileReader; +import javax.sound.sampled.spi.AudioFileWriter; import javax.sound.sampled.spi.FormatConversionProvider; import javax.sound.sampled.spi.MixerProvider; @@ -60,14 +60,14 @@ import com.sun.media.sound.JDK13Services; *

    * Properties can be used to specify the default mixer for specific line types. * Both system properties and a properties file are considered. The - * {@code sound.properties} properties file is read from an - * implementation-specific location (typically it is the {@code lib} directory - * in the Java installation directory). If a property exists both as a system - * property and in the properties file, the system property takes precedence. - * If none is specified, a suitable default is chosen among the available - * devices. The syntax of the properties file is specified in - * {@link java.util.Properties#load(InputStream) Properties.load}. The following - * table lists the available property keys and which methods consider them: + * "sound.properties" properties file is read from an implementation-specific + * location (typically it is the {@code lib} directory in the Java installation + * directory). If a property exists both as a system property and in the + * properties file, the system property takes precedence. If none is specified, + * a suitable default is chosen among the available devices. The syntax of the + * properties file is specified in + * {@link Properties#load(InputStream) Properties.load}. The following table + * lists the available property keys and which methods consider them: * * * @@ -100,12 +100,11 @@ import com.sun.media.sound.JDK13Services; * * The property value consists of the provider class name and the mixer name, * separated by the hash mark ("#"). The provider class name is the - * fully-qualified name of a concrete - * {@link javax.sound.sampled.spi.MixerProvider mixer provider} class. The mixer - * name is matched against the {@code String} returned by the {@code getName} - * method of {@code Mixer.Info}. Either the class name, or the mixer name may be - * omitted. If only the class name is specified, the trailing hash mark is - * optional. + * fully-qualified name of a concrete {@link MixerProvider mixer provider} + * class. The mixer name is matched against the {@code String} returned by the + * {@code getName} method of {@code Mixer.Info}. Either the class name, or the + * mixer name may be omitted. If only the class name is specified, the trailing + * hash mark is optional. *

    * If the provider class is specified, and it can be successfully retrieved from * the installed providers, the list of {@code Mixer.Info} objects is retrieved @@ -1324,10 +1323,9 @@ public class AudioSystem { * Obtains the set of format converters (codecs, transcoders, etc.) that are * currently installed on the system. * - * @return an array of {@link javax.sound.sampled.spi.FormatConversionProvider - * FormatConversionProvider} objects representing the available - * format converters. If no format converters readers are available - * on the system, an array of length 0 is returned. + * @return an array of {@link FormatConversionProvider} objects representing + * the available format converters. If no format converters readers + * are available on the system, an array of length 0 is returned. */ @SuppressWarnings("unchecked") private static List getFormatConversionProviders() { @@ -1338,10 +1336,9 @@ public class AudioSystem { * Obtains the set of audio file readers that are currently installed on the * system. * - * @return a List of {@link javax.sound.sampled.spi.AudioFileReader - * AudioFileReader} objects representing the installed audio file - * readers. If no audio file readers are available on the system, an - * empty List is returned. + * @return a List of {@link AudioFileReader} objects representing the + * installed audio file readers. If no audio file readers are + * available on the system, an empty List is returned. */ @SuppressWarnings("unchecked") private static List getAudioFileReaders() { @@ -1352,10 +1349,9 @@ public class AudioSystem { * Obtains the set of audio file writers that are currently installed on the * system. * - * @return a List of {@link javax.sound.sampled.spi.AudioFileWriter - * AudioFileWriter} objects representing the available audio file - * writers. If no audio file writers are available on the system, an - * empty List is returned. + * @return a List of {@link AudioFileWriter} objects representing the + * available audio file writers. If no audio file writers are + * available on the system, an empty List is returned. */ @SuppressWarnings("unchecked") private static List getAudioFileWriters() { diff --git a/jdk/src/java.desktop/share/classes/javax/sound/sampled/DataLine.java b/jdk/src/java.desktop/share/classes/javax/sound/sampled/DataLine.java index 9a81a76c5b6..6246a40d64f 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/DataLine.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/DataLine.java @@ -355,11 +355,11 @@ public interface DataLine extends Line { * {@code true} for all formats returned by {@code getFormats()}. *

    * Some fields in the AudioFormat instances can be set to - * {@link javax.sound.sampled.AudioSystem#NOT_SPECIFIED NOT_SPECIFIED} - * if that field does not apply to the format, or if the format supports - * a wide range of values for that field. For example, a multi-channel - * device supporting up to 64 channels, could set the channel field in - * the {@code AudioFormat} instances returned by this method to + * {@link AudioSystem#NOT_SPECIFIED NOT_SPECIFIED} if that field does + * not apply to the format, or if the format supports a wide range of + * values for that field. For example, a multi-channel device supporting + * up to 64 channels, could set the channel field in the + * {@code AudioFormat} instances returned by this method to * {@code NOT_SPECIFIED}. * * @return a set of supported audio formats diff --git a/jdk/src/java.desktop/share/classes/javax/sound/sampled/spi/AudioFileReader.java b/jdk/src/java.desktop/share/classes/javax/sound/sampled/spi/AudioFileReader.java index daa75556785..818df436f49 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/spi/AudioFileReader.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/spi/AudioFileReader.java @@ -26,8 +26,8 @@ package javax.sound.sampled.spi; import java.io.File; -import java.io.InputStream; import java.io.IOException; +import java.io.InputStream; import java.net.URL; import javax.sound.sampled.AudioFileFormat; diff --git a/jdk/src/java.desktop/share/classes/javax/sound/sampled/spi/AudioFileWriter.java b/jdk/src/java.desktop/share/classes/javax/sound/sampled/spi/AudioFileWriter.java index a4cc31bdf18..0cb6dc6acae 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/spi/AudioFileWriter.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/spi/AudioFileWriter.java @@ -30,6 +30,7 @@ import java.io.IOException; import java.io.OutputStream; import javax.sound.sampled.AudioInputStream; +import javax.sound.sampled.AudioSystem; import static javax.sound.sampled.AudioFileFormat.Type; @@ -110,8 +111,7 @@ public abstract class AudioFileWriter { * the length be written into the file header, and cannot be written from * start to finish unless the length is known in advance. An attempt to * write such a file type will fail with an IOException if the length in the - * audio file format is {@link javax.sound.sampled.AudioSystem#NOT_SPECIFIED - * AudioSystem.NOT_SPECIFIED}. + * audio file format is {@link AudioSystem#NOT_SPECIFIED}. * * @param stream the audio input stream containing audio data to be written * to the output stream diff --git a/jdk/src/java.desktop/share/classes/javax/swing/CellEditor.java b/jdk/src/java.desktop/share/classes/javax/swing/CellEditor.java index f1b625b7969..bf9a23d2f77 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/CellEditor.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/CellEditor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -47,7 +47,7 @@ import javax.swing.event.*; * new component implement the interface. Or the developer can * choose a wrapper based approach and provide a companion object which * implements the CellEditor interface (See - * JCellEditor for example). The wrapper approach + * DefaultCellEditor for example). The wrapper approach * is particularly useful if the user want to use a 3rd party ISV * editor with JTable, but the ISV didn't implement the * CellEditor interface. The user can simply create an object diff --git a/jdk/src/java.desktop/share/classes/javax/swing/ImageIcon.java b/jdk/src/java.desktop/share/classes/javax/swing/ImageIcon.java index 8f7812e5919..564e173c5c8 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/ImageIcon.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/ImageIcon.java @@ -490,12 +490,33 @@ public class ImageIcon implements Icon, Serializable, Accessible { private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException { - s.defaultReadObject(); + ObjectInputStream.GetField f = s.readFields(); + + imageObserver = (ImageObserver) f.get("imageObserver", null); + description = (String) f.get("description", null); + width = f.get("width", -1); + height = f.get("height", -1); + accessibleContext = (AccessibleImageIcon) f.get("accessibleContext", null); int w = s.readInt(); int h = s.readInt(); int[] pixels = (int[])(s.readObject()); + if (pixels == null && (w != -1 || h != -1)) { + throw new IllegalStateException("Inconsistent width and height" + + " for null image [" + w + ", " + h + "]"); + } + + if (pixels != null && (w < 0 || h < 0)) { + throw new IllegalStateException("Inconsistent width and height" + + " for image [" + w + ", " + h + "]"); + } + + if (w != getIconWidth() || h != getIconHeight()) { + throw new IllegalStateException("Inconsistent width and height" + + " for image [" + w + ", " + h + "]"); + } + if (pixels != null) { Toolkit tk = Toolkit.getDefaultToolkit(); ColorModel cm = ColorModel.getRGBdefault(); diff --git a/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java b/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java index 765610ebbad..17cbf60100b 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java @@ -1888,7 +1888,7 @@ public abstract class JComponent extends Container implements Serializable, * description: The preferred vertical alignment of the component. */ public void setAlignmentY(float alignmentY) { - this.alignmentY = alignmentY > 1.0f ? 1.0f : alignmentY < 0.0f ? 0.0f : alignmentY; + this.alignmentY = validateAlignment(alignmentY); isAlignmentYSet = true; } @@ -1917,10 +1917,14 @@ public abstract class JComponent extends Container implements Serializable, * description: The preferred horizontal alignment of the component. */ public void setAlignmentX(float alignmentX) { - this.alignmentX = alignmentX > 1.0f ? 1.0f : alignmentX < 0.0f ? 0.0f : alignmentX; + this.alignmentX = validateAlignment(alignmentX); isAlignmentXSet = true; } + private float validateAlignment(float alignment) { + return alignment > 1.0f ? 1.0f : alignment < 0.0f ? 0.0f : alignment; + } + /** * Sets the input verifier for this component. * @@ -5514,7 +5518,24 @@ public abstract class JComponent extends Container implements Serializable, private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { - s.defaultReadObject(); + ObjectInputStream.GetField f = s.readFields(); + + isAlignmentXSet = f.get("isAlignmentXSet", false); + alignmentX = validateAlignment(f.get("alignmentX", 0f)); + isAlignmentYSet = f.get("isAlignmentYSet", false); + alignmentY = validateAlignment(f.get("alignmentY", 0f)); + listenerList = (EventListenerList) f.get("listenerList", null); + vetoableChangeSupport = (VetoableChangeSupport) f.get("vetoableChangeSupport", null); + autoscrolls = f.get("autoscrolls", false); + border = (Border) f.get("border", null); + flags = f.get("flags", 0); + inputVerifier = (InputVerifier) f.get("inputVerifier", null); + verifyInputWhenFocusTarget = f.get("verifyInputWhenFocusTarget", false); + popupMenu = (JPopupMenu) f.get("popupMenu", null); + focusInputMap = (InputMap) f.get("focusInputMap", null); + ancestorInputMap = (InputMap) f.get("ancestorInputMap", null); + windowInputMap = (ComponentInputMap) f.get("windowInputMap", null); + actionMap = (ActionMap) f.get("actionMap", null); /* If there's no ReadObjectCallback for this stream yet, that is, if * this is the first call to JComponent.readObject() for this diff --git a/jdk/src/java.desktop/share/classes/javax/swing/JFileChooser.java b/jdk/src/java.desktop/share/classes/javax/swing/JFileChooser.java index bf690ddbb5b..1edf4943357 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/JFileChooser.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/JFileChooser.java @@ -50,6 +50,8 @@ import java.awt.Toolkit; import java.awt.event.*; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeEvent; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; import java.lang.ref.WeakReference; /** @@ -460,10 +462,14 @@ public class JFileChooser extends JComponent implements Accessible { * bound: false */ public void setDragEnabled(boolean b) { + checkDragEnabled(b); + dragEnabled = b; + } + + private static void checkDragEnabled(boolean b) { if (b && GraphicsEnvironment.isHeadless()) { throw new HeadlessException(); } - dragEnabled = b; } /** @@ -949,9 +955,7 @@ public class JFileChooser extends JComponent implements Accessible { if(this.dialogType == dialogType) { return; } - if(!(dialogType == OPEN_DIALOG || dialogType == SAVE_DIALOG || dialogType == CUSTOM_DIALOG)) { - throw new IllegalArgumentException("Incorrect Dialog Type: " + dialogType); - } + checkDialogType(dialogType); int oldValue = this.dialogType; this.dialogType = dialogType; if(dialogType == OPEN_DIALOG || dialogType == SAVE_DIALOG) { @@ -960,6 +964,14 @@ public class JFileChooser extends JComponent implements Accessible { firePropertyChange(DIALOG_TYPE_CHANGED_PROPERTY, oldValue, dialogType); } + private static void checkDialogType(int dialogType) { + if (!(dialogType == OPEN_DIALOG || dialogType == SAVE_DIALOG + || dialogType == CUSTOM_DIALOG)) { + throw new IllegalArgumentException( + "Incorrect Dialog Type: " + dialogType); + } + } + /** * Sets the string that goes in the JFileChooser window's * title bar. @@ -1349,12 +1361,17 @@ public class JFileChooser extends JComponent implements Accessible { return; } - if ((mode == FILES_ONLY) || (mode == DIRECTORIES_ONLY) || (mode == FILES_AND_DIRECTORIES)) { + checkFileSelectionMode(mode); int oldValue = fileSelectionMode; fileSelectionMode = mode; firePropertyChange(FILE_SELECTION_MODE_CHANGED_PROPERTY, oldValue, fileSelectionMode); - } else { - throw new IllegalArgumentException("Incorrect Mode for file selection: " + mode); + } + + private static void checkFileSelectionMode(int mode) { + if ((mode != FILES_ONLY) && (mode != DIRECTORIES_ONLY) + && (mode != FILES_AND_DIRECTORIES)) { + throw new IllegalArgumentException( + "Incorrect Mode for file selection: " + mode); } } @@ -1901,7 +1918,43 @@ public class JFileChooser extends JComponent implements Accessible { */ private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); + ObjectInputStream.GetField f = in.readFields(); + + dialogTitle = (String) f.get("dialogTitle", null); + approveButtonText = (String) f.get("approveButtonText", null); + approveButtonToolTipText = + (String) f.get("approveButtonToolTipText", null); + approveButtonMnemonic = f.get("approveButtonMnemonic", 0); + @SuppressWarnings("unchecked") + Vector newFilters = (Vector) f.get("filters", null); + if (newFilters == null) { + throw new InvalidObjectException("Null filters"); + } + filters = newFilters; + dialog = (JDialog) f.get("dialog", null); + int newDialogType = f.get("dialogType", OPEN_DIALOG); + checkDialogType(newDialogType); + dialogType = newDialogType; + returnValue = f.get("returnValue", 0); + accessory = (JComponent) f.get("accessory", null); + fileView = (FileView) f.get("fileView", null); + controlsShown = f.get("controlsShown", false); + useFileHiding = f.get("useFileHiding", false); + int newFileSelectionMode = f.get("fileSelectionMode", FILES_ONLY); + checkFileSelectionMode(newFileSelectionMode); + fileSelectionMode = newFileSelectionMode; + multiSelectionEnabled = f.get("multiSelectionEnabled", false); + useAcceptAllFileFilter = f.get("useAcceptAllFileFilter", false); + boolean newDragEnabled = f.get("dragEnabled", false); + checkDragEnabled(newDragEnabled); + dragEnabled = newDragEnabled; + fileFilter = (FileFilter) f.get("fileFilter", null); + fileSystemView = (FileSystemView) f.get("fileSystemView", null); + currentDirectory = (File) f.get("currentDirectory", null); + selectedFile = (File) f.get("selectedFile", null); + selectedFiles = (File[]) f.get("selectedFiles", null); + accessibleContext = (AccessibleContext) f.get("accessibleContext", null); + installShowFilesListener(); } diff --git a/jdk/src/java.desktop/share/classes/javax/swing/JFrame.java b/jdk/src/java.desktop/share/classes/javax/swing/JFrame.java index cc3b0807f96..9de3edef45a 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/JFrame.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/JFrame.java @@ -24,14 +24,22 @@ */ package javax.swing; -import java.awt.*; -import java.awt.event.*; -import java.beans.PropertyChangeListener; -import java.util.Locale; -import java.util.Vector; -import java.io.Serializable; +import java.awt.AWTEvent; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Container; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.GraphicsConfiguration; +import java.awt.HeadlessException; +import java.awt.Image; +import java.awt.LayoutManager; +import java.awt.event.WindowEvent; -import javax.accessibility.*; +import javax.accessibility.Accessible; +import javax.accessibility.AccessibleContext; +import javax.accessibility.AccessibleState; +import javax.accessibility.AccessibleStateSet; /** @@ -297,33 +305,28 @@ public class JFrame extends Frame implements WindowConstants, * @see #setDefaultCloseOperation * @see java.awt.Window#processWindowEvent */ - protected void processWindowEvent(WindowEvent e) { + protected void processWindowEvent(final WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { - switch(defaultCloseOperation) { - case HIDE_ON_CLOSE: - setVisible(false); - break; - case DISPOSE_ON_CLOSE: - dispose(); - break; - case DO_NOTHING_ON_CLOSE: - default: - break; - case EXIT_ON_CLOSE: - // This needs to match the checkExit call in - // setDefaultCloseOperation - System.exit(0); - break; + switch (defaultCloseOperation) { + case HIDE_ON_CLOSE: + setVisible(false); + break; + case DISPOSE_ON_CLOSE: + dispose(); + break; + case EXIT_ON_CLOSE: + // This needs to match the checkExit call in + // setDefaultCloseOperation + System.exit(0); + break; + case DO_NOTHING_ON_CLOSE: + default: } } } -// public void setMenuBar(MenuBar menu) { -// throw new IllegalComponentStateException("Please use setJMenuBar() with JFrame."); -// } - /** * Sets the operation that will happen by default when * the user initiates a "close" on this frame. diff --git a/jdk/src/java.desktop/share/classes/javax/swing/JLayer.java b/jdk/src/java.desktop/share/classes/javax/swing/JLayer.java index 57bccae7ec6..8c58c916a4e 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/JLayer.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/JLayer.java @@ -158,8 +158,9 @@ public final class JLayer private LayerUI layerUI; private JPanel glassPane; private long eventMask; - private transient boolean isPainting; - private transient boolean isPaintingImmediately; + private transient boolean isPaintCalling; + private transient boolean isPaintImmediatelyCalling; + private transient boolean isImageUpdateCalling; private static final LayerEventController eventController = new LayerEventController(); @@ -405,30 +406,57 @@ public final class JLayer * @param h the height of the region to be painted */ public void paintImmediately(int x, int y, int w, int h) { - if (!isPaintingImmediately && getUI() != null) { - isPaintingImmediately = true; + if (!isPaintImmediatelyCalling && getUI() != null) { + isPaintImmediatelyCalling = true; try { getUI().paintImmediately(x, y, w, h, this); } finally { - isPaintingImmediately = false; + isPaintImmediatelyCalling = false; } } else { super.paintImmediately(x, y, w, h); } } + /** + * Delegates its functionality to the + * {@link javax.swing.plaf.LayerUI#imageUpdate(java.awt.Image, int, int, int, int, int, JLayer)} method, + * if the {@code LayerUI} is set. + * + * @param img the image being observed + * @param infoflags see {@code imageUpdate} for more information + * @param x the x coordinate + * @param y the y coordinate + * @param w the width + * @param h the height + * @return {@code false} if the infoflags indicate that the + * image is completely loaded; {@code true} otherwise. + */ + public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h) { + if (!isImageUpdateCalling && getUI() != null) { + isImageUpdateCalling = true; + try { + return getUI().imageUpdate(img, infoflags, x, y, w, h, this); + } finally { + isImageUpdateCalling = false; + } + } else { + return super.imageUpdate(img, infoflags, x, y, w, h); + } + } + /** * Delegates all painting to the {@link javax.swing.plaf.LayerUI} object. * * @param g the {@code Graphics} to render to */ public void paint(Graphics g) { - if (!isPainting) { - isPainting = true; + if (!isPaintCalling) { + isPaintCalling = true; try { super.paintComponent(g); } finally { - isPainting = false; + isPaintCalling = false; } } else { super.paint(g); @@ -646,15 +674,21 @@ public final class JLayer return 1; } + @SuppressWarnings("unchecked") private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { - s.defaultReadObject(); - if (layerUI != null) { - setUI(layerUI); - } + ObjectInputStream.GetField f = s.readFields(); + + view = (V) f.get("view", null); + glassPane = (JPanel) f.get("glassPane", null); + eventMask = f.get("eventMask", 0l); if (eventMask != 0) { eventController.updateAWTEventListener(0, eventMask); } + LayerUI newLayerUI = (LayerUI) f.get("layerUI", null); + if (newLayerUI != null) { + setUI(newLayerUI); + } } /** diff --git a/jdk/src/java.desktop/share/classes/javax/swing/JOptionPane.java b/jdk/src/java.desktop/share/classes/javax/swing/JOptionPane.java index b3d52fc5274..413b3cfab73 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/JOptionPane.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/JOptionPane.java @@ -43,13 +43,10 @@ import java.awt.event.WindowEvent; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; import java.io.IOException; +import java.io.InvalidObjectException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; -import java.lang.reflect.Method; -import java.lang.reflect.InvocationTargetException; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.Vector; import javax.swing.plaf.OptionPaneUI; import javax.swing.event.InternalFrameEvent; @@ -2055,15 +2052,22 @@ public class JOptionPane extends JComponent implements Accessible * description: The option pane's message type. */ public void setMessageType(int newType) { + checkMessageType(newType); + int oldType = messageType; + messageType = newType; + firePropertyChange(MESSAGE_TYPE_PROPERTY, oldType, messageType); + } + + private static void checkMessageType(int newType){ if(newType != ERROR_MESSAGE && newType != INFORMATION_MESSAGE && newType != WARNING_MESSAGE && newType != QUESTION_MESSAGE && newType != PLAIN_MESSAGE) - throw new RuntimeException("JOptionPane: type must be one of JOptionPane.ERROR_MESSAGE, JOptionPane.INFORMATION_MESSAGE, JOptionPane.WARNING_MESSAGE, JOptionPane.QUESTION_MESSAGE or JOptionPane.PLAIN_MESSAGE"); - - int oldType = messageType; - - messageType = newType; - firePropertyChange(MESSAGE_TYPE_PROPERTY, oldType, messageType); + throw new RuntimeException("JOptionPane: type must be one of" + + " JOptionPane.ERROR_MESSAGE," + + " JOptionPane.INFORMATION_MESSAGE," + + " JOptionPane.WARNING_MESSAGE," + + " JOptionPane.QUESTION_MESSAGE" + + " or JOptionPane.PLAIN_MESSAGE"); } /** @@ -2097,16 +2101,23 @@ public class JOptionPane extends JComponent implements Accessible * description: The option pane's option type. */ public void setOptionType(int newType) { - if(newType != DEFAULT_OPTION && newType != YES_NO_OPTION && - newType != YES_NO_CANCEL_OPTION && newType != OK_CANCEL_OPTION) - throw new RuntimeException("JOptionPane: option type must be one of JOptionPane.DEFAULT_OPTION, JOptionPane.YES_NO_OPTION, JOptionPane.YES_NO_CANCEL_OPTION or JOptionPane.OK_CANCEL_OPTION"); - + checkOptionType(newType); int oldType = optionType; - optionType = newType; firePropertyChange(OPTION_TYPE_PROPERTY, oldType, optionType); } + private static void checkOptionType(int newType) { + if (newType != DEFAULT_OPTION && newType != YES_NO_OPTION + && newType != YES_NO_CANCEL_OPTION + && newType != OK_CANCEL_OPTION) { + throw new RuntimeException("JOptionPane: option type must be one of" + + " JOptionPane.DEFAULT_OPTION, JOptionPane.YES_NO_OPTION," + + " JOptionPane.YES_NO_CANCEL_OPTION" + + " or JOptionPane.OK_CANCEL_OPTION"); + } + } + /** * Returns the type of options that are displayed. * @@ -2385,7 +2396,15 @@ public class JOptionPane extends JComponent implements Accessible private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { - s.defaultReadObject(); + ObjectInputStream.GetField f = s.readFields(); + + int newMessageType = f.get("messageType", 0); + checkMessageType(newMessageType); + messageType = newMessageType; + int newOptionType = f.get("optionType", 0); + checkOptionType(newOptionType); + optionType = newOptionType; + wantsInput = f.get("wantsInput", false); Vector values = (Vector)s.readObject(); int indexCounter = 0; diff --git a/jdk/src/java.desktop/share/classes/javax/swing/JPopupMenu.java b/jdk/src/java.desktop/share/classes/javax/swing/JPopupMenu.java index ca00144b774..89311ba1228 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/JPopupMenu.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/JPopupMenu.java @@ -1345,7 +1345,20 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement { // implements javax.swing.MenuElement private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { - s.defaultReadObject(); + ObjectInputStream.GetField f = s.readFields(); + + int newDesiredLocationX = f.get("desiredLocationX", 0); + int newDesiredLocationY = f.get("desiredLocationY", 0); + Point p = adjustPopupLocationToFitScreen( + newDesiredLocationX, newDesiredLocationY); + desiredLocationX = p.x; + desiredLocationY = p.y; + + label = (String) f.get("label", null); + paintBorder = f.get("paintBorder", false); + margin = (Insets) f.get("margin", null); + lightWeightPopup = f.get("lightWeightPopup", false); + selectionModel = (SingleSelectionModel) f.get("selectionModel", null); Vector values = (Vector)s.readObject(); int indexCounter = 0; diff --git a/jdk/src/java.desktop/share/classes/javax/swing/JTabbedPane.java b/jdk/src/java.desktop/share/classes/javax/swing/JTabbedPane.java index 96c050529fe..ffde325f8d8 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/JTabbedPane.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/JTabbedPane.java @@ -495,10 +495,7 @@ public class JTabbedPane extends JComponent * */ public void setTabPlacement(int tabPlacement) { - if (tabPlacement != TOP && tabPlacement != LEFT && - tabPlacement != BOTTOM && tabPlacement != RIGHT) { - throw new IllegalArgumentException("illegal tab placement: must be TOP, BOTTOM, LEFT, or RIGHT"); - } + checkTabPlacement(tabPlacement); if (this.tabPlacement != tabPlacement) { int oldValue = this.tabPlacement; this.tabPlacement = tabPlacement; @@ -508,6 +505,14 @@ public class JTabbedPane extends JComponent } } + private static void checkTabPlacement(int tabPlacement) { + if (tabPlacement != TOP && tabPlacement != LEFT && + tabPlacement != BOTTOM && tabPlacement != RIGHT) { + throw new IllegalArgumentException("illegal tab placement:" + + " must be TOP, BOTTOM, LEFT, or RIGHT"); + } + } + /** * Returns the policy used by the tabbedpane to layout the tabs when all the * tabs will not fit within a single run. @@ -551,9 +556,7 @@ public class JTabbedPane extends JComponent * */ public void setTabLayoutPolicy(int tabLayoutPolicy) { - if (tabLayoutPolicy != WRAP_TAB_LAYOUT && tabLayoutPolicy != SCROLL_TAB_LAYOUT) { - throw new IllegalArgumentException("illegal tab layout policy: must be WRAP_TAB_LAYOUT or SCROLL_TAB_LAYOUT"); - } + checkTabLayoutPolicy(tabLayoutPolicy); if (this.tabLayoutPolicy != tabLayoutPolicy) { int oldValue = this.tabLayoutPolicy; this.tabLayoutPolicy = tabLayoutPolicy; @@ -563,6 +566,14 @@ public class JTabbedPane extends JComponent } } + private static void checkTabLayoutPolicy(int tabLayoutPolicy) { + if (tabLayoutPolicy != WRAP_TAB_LAYOUT + && tabLayoutPolicy != SCROLL_TAB_LAYOUT) { + throw new IllegalArgumentException("illegal tab layout policy:" + + " must be WRAP_TAB_LAYOUT or SCROLL_TAB_LAYOUT"); + } + } + /** * Returns the currently selected index for this tabbedpane. * Returns -1 if there is no currently selected tab. @@ -1816,7 +1827,19 @@ public class JTabbedPane extends JComponent private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { - s.defaultReadObject(); + ObjectInputStream.GetField f = s.readFields(); + + int newTabPlacement = f.get("tabPlacement", TOP); + checkTabPlacement(newTabPlacement); + tabPlacement = newTabPlacement; + int newTabLayoutPolicy = f.get("tabLayoutPolicy", 0); + checkTabLayoutPolicy(newTabLayoutPolicy); + tabLayoutPolicy = newTabLayoutPolicy; + model = (SingleSelectionModel) f.get("model", null); + haveRegistered = f.get("haveRegistered", false); + changeListener = (ChangeListener) f.get("changeListener", null); + visComp = (Component) f.get("visComp", null); + if ((ui != null) && (getUIClassID().equals(uiClassID))) { ui.installUI(this); } diff --git a/jdk/src/java.desktop/share/classes/javax/swing/JTable.java b/jdk/src/java.desktop/share/classes/javax/swing/JTable.java index a4f30ac33a5..d88dbed9985 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/JTable.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/JTable.java @@ -37,6 +37,7 @@ import java.beans.*; import java.io.ObjectOutputStream; import java.io.ObjectInputStream; import java.io.IOException; +import java.io.InvalidObjectException; import javax.accessibility.*; @@ -1203,11 +1204,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable * AUTO_RESIZE_ALL_COLUMNS JTable.AUTO_RESIZE_ALL_COLUMNS */ public void setAutoResizeMode(int mode) { - if ((mode == AUTO_RESIZE_OFF) || - (mode == AUTO_RESIZE_NEXT_COLUMN) || - (mode == AUTO_RESIZE_SUBSEQUENT_COLUMNS) || - (mode == AUTO_RESIZE_LAST_COLUMN) || - (mode == AUTO_RESIZE_ALL_COLUMNS)) { + if (isValidAutoResizeMode(mode)) { int old = autoResizeMode; autoResizeMode = mode; resizeAndRepaint(); @@ -1218,6 +1215,14 @@ public class JTable extends JComponent implements TableModelListener, Scrollable } } + private static boolean isValidAutoResizeMode(int mode) { + return (mode == AUTO_RESIZE_OFF) + || (mode == AUTO_RESIZE_NEXT_COLUMN) + || (mode == AUTO_RESIZE_SUBSEQUENT_COLUMNS) + || (mode == AUTO_RESIZE_LAST_COLUMN) + || (mode == AUTO_RESIZE_ALL_COLUMNS); + } + /** * Returns the auto resize mode of the table. The default mode * is AUTO_RESIZE_SUBSEQUENT_COLUMNS. @@ -1439,10 +1444,14 @@ public class JTable extends JComponent implements TableModelListener, Scrollable * bound: false */ public void setDragEnabled(boolean b) { + checkDragEnabled(b); + dragEnabled = b; + } + + private void checkDragEnabled(boolean b) { if (b && GraphicsEnvironment.isHeadless()) { throw new HeadlessException(); } - dragEnabled = b; } /** @@ -1489,6 +1498,11 @@ public class JTable extends JComponent implements TableModelListener, Scrollable * @since 1.6 */ public final void setDropMode(DropMode dropMode) { + checkDropMode(dropMode); + this.dropMode = dropMode; + } + + private static void checkDropMode(DropMode dropMode) { if (dropMode != null) { switch (dropMode) { case USE_SELECTION: @@ -1499,14 +1513,12 @@ public class JTable extends JComponent implements TableModelListener, Scrollable case ON_OR_INSERT: case ON_OR_INSERT_ROWS: case ON_OR_INSERT_COLS: - this.dropMode = dropMode; return; } } - - throw new IllegalArgumentException(dropMode + ": Unsupported drop mode for table"); + throw new IllegalArgumentException(dropMode + + ": Unsupported drop mode for table"); } - /** * Returns the drop mode for this component. * @@ -5865,7 +5877,75 @@ public class JTable extends JComponent implements TableModelListener, Scrollable private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { - s.defaultReadObject(); + ObjectInputStream.GetField f = s.readFields(); + + TableModel newDataModel = (TableModel) f.get("dataModel", null); + if (newDataModel == null) { + throw new InvalidObjectException("Null dataModel"); + } + dataModel = newDataModel; + + TableColumnModel newColumnModel = (TableColumnModel) f.get("columnModel", null); + if (newColumnModel == null) { + throw new InvalidObjectException("Null columnModel"); + } + columnModel = newColumnModel; + + ListSelectionModel newSelectionModel = (ListSelectionModel) f.get("selectionModel", null); + if (newSelectionModel == null) { + throw new InvalidObjectException("Null selectionModel"); + } + selectionModel = newSelectionModel; + + tableHeader = (JTableHeader) f.get("tableHeader", null); + int newRowHeight = f.get("rowHeight", 0); + if (newRowHeight <= 0) { + throw new InvalidObjectException("Row height less than 1"); + } + rowHeight = newRowHeight; + + rowMargin = f.get("rowMargin", 0); + Color newGridColor = (Color) f.get("gridColor", null); + if (newGridColor == null) { + throw new InvalidObjectException("Null gridColor"); + } + gridColor = newGridColor; + + showHorizontalLines = f.get("showHorizontalLines", false); + showVerticalLines = f.get("showVerticalLines", false); + int newAutoResizeMode = f.get("autoResizeMode", 0); + if (!isValidAutoResizeMode(newAutoResizeMode)) { + throw new InvalidObjectException("autoResizeMode is not valid"); + } + autoResizeMode = newAutoResizeMode; + autoCreateColumnsFromModel = f.get("autoCreateColumnsFromModel", false); + preferredViewportSize = (Dimension) f.get("preferredViewportSize", null); + rowSelectionAllowed = f.get("rowSelectionAllowed", false); + cellSelectionEnabled = f.get("cellSelectionEnabled", false); + selectionForeground = (Color) f.get("selectionForeground", null); + selectionBackground = (Color) f.get("selectionBackground", null); + rowModel = (SizeSequence) f.get("rowModel", null); + + boolean newDragEnabled = f.get("dragEnabled", false); + checkDragEnabled(newDragEnabled); + dragEnabled = newDragEnabled; + + surrendersFocusOnKeystroke = f.get("surrendersFocusOnKeystroke", false); + editorRemover = (PropertyChangeListener) f.get("editorRemover", null); + columnSelectionAdjusting = f.get("columnSelectionAdjusting", false); + rowSelectionAdjusting = f.get("rowSelectionAdjusting", false); + printError = (Throwable) f.get("printError", null); + isRowHeightSet = f.get("isRowHeightSet", false); + updateSelectionOnSort = f.get("updateSelectionOnSort", false); + ignoreSortChange = f.get("ignoreSortChange", false); + sorterChanged = f.get("sorterChanged", false); + autoCreateRowSorter = f.get("autoCreateRowSorter", false); + fillsViewportHeight = f.get("fillsViewportHeight", false); + DropMode newDropMode = (DropMode) f.get("dropMode", + DropMode.USE_SELECTION); + checkDropMode(newDropMode); + dropMode = newDropMode; + if ((ui != null) && (getUIClassID().equals(uiClassID))) { ui.installUI(this); } diff --git a/jdk/src/java.desktop/share/classes/javax/swing/JTree.java b/jdk/src/java.desktop/share/classes/javax/swing/JTree.java index 3188156e347..6d50f6f653a 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/JTree.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/JTree.java @@ -1216,10 +1216,14 @@ public class JTree extends JComponent implements Scrollable, Accessible * bound: false */ public void setDragEnabled(boolean b) { + checkDragEnabled(b); + dragEnabled = b; + } + + private static void checkDragEnabled(boolean b) { if (b && GraphicsEnvironment.isHeadless()) { throw new HeadlessException(); } - dragEnabled = b; } /** @@ -1262,18 +1266,23 @@ public class JTree extends JComponent implements Scrollable, Accessible * @since 1.6 */ public final void setDropMode(DropMode dropMode) { + checkDropMode(dropMode); + this.dropMode = dropMode; + } + + private static void checkDropMode(DropMode dropMode) { if (dropMode != null) { switch (dropMode) { case USE_SELECTION: case ON: case INSERT: case ON_OR_INSERT: - this.dropMode = dropMode; return; } } - throw new IllegalArgumentException(dropMode + ": Unsupported drop mode for tree"); + throw new IllegalArgumentException(dropMode + + ": Unsupported drop mode for tree"); } /** @@ -3089,7 +3098,34 @@ public class JTree extends JComponent implements Scrollable, Accessible private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { - s.defaultReadObject(); + ObjectInputStream.GetField f = s.readFields(); + + rootVisible = f.get("rootVisible", false); + rowHeight = f.get("rowHeight", 0); + rowHeightSet = f.get("rowHeightSet", false); + showsRootHandles = f.get("showsRootHandles", false); + showsRootHandlesSet = f.get("showsRootHandlesSet", false); + editable = f.get("editable", false); + largeModel = f.get("largeModel", false); + visibleRowCount = f.get("visibleRowCount", 0); + invokesStopCellEditing = f.get("invokesStopCellEditing", false); + scrollsOnExpand = f.get("scrollsOnExpand", false); + scrollsOnExpandSet = f.get("scrollsOnExpandSet", false); + toggleClickCount = f.get("toggleClickCount", 0); + leadPath = (TreePath) f.get("leadPath", null); + anchorPath = (TreePath) f.get("anchorPath", null); + expandsSelectedPaths = f.get("expandsSelectedPaths", false); + settingUI = f.get("settingUI", false); + boolean newDragEnabled = f.get("dragEnabled", false); + checkDragEnabled(newDragEnabled); + dragEnabled = newDragEnabled; + DropMode newDropMode = (DropMode) f.get("dropMode", + DropMode.USE_SELECTION); + checkDropMode(newDropMode); + dropMode = newDropMode; + + expandRow = f.get("expandRow", -1); + dropTimer = (TreeTimer) f.get("dropTimer", null); // Create an instance of expanded state. diff --git a/jdk/src/java.desktop/share/classes/javax/swing/LegacyGlueFocusTraversalPolicy.java b/jdk/src/java.desktop/share/classes/javax/swing/LegacyGlueFocusTraversalPolicy.java index de33d4c4dae..ac366ca8df6 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/LegacyGlueFocusTraversalPolicy.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/LegacyGlueFocusTraversalPolicy.java @@ -194,7 +194,23 @@ final class LegacyGlueFocusTraversalPolicy extends FocusTraversalPolicy private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); + ObjectInputStream.GetField f = in.readFields(); + + @SuppressWarnings("unchecked") + HashMap newForwardMap = + (HashMap ) f.get("forwardMap", null); + if (newForwardMap == null) { + throw new InvalidObjectException("Null forwardMap"); + } + forwardMap = newForwardMap; + @SuppressWarnings("unchecked") + HashMap newBackwardMap = + (HashMap) f.get("backwardMap", null); + if (newBackwardMap == null) { + throw new InvalidObjectException("Null backwardMap"); + } + backwardMap = newBackwardMap; + delegatePolicy = (FocusTraversalPolicy)in.readObject(); delegateManager = (DefaultFocusManager)in.readObject(); } diff --git a/jdk/src/java.desktop/share/classes/javax/swing/SwingUtilities.java b/jdk/src/java.desktop/share/classes/javax/swing/SwingUtilities.java index fb7b2820fd2..07705f4a812 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/SwingUtilities.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/SwingUtilities.java @@ -374,7 +374,8 @@ public class SwingUtilities implements SwingConstants sourceWheelEvent.isPopupTrigger(), sourceWheelEvent.getScrollType(), sourceWheelEvent.getScrollAmount(), - sourceWheelEvent.getWheelRotation()); + sourceWheelEvent.getWheelRotation(), + sourceWheelEvent.getPreciseWheelRotation()); } else if (sourceEvent instanceof MenuDragMouseEvent) { MenuDragMouseEvent sourceMenuDragEvent = (MenuDragMouseEvent)sourceEvent; diff --git a/jdk/src/java.desktop/share/classes/javax/swing/Timer.java b/jdk/src/java.desktop/share/classes/javax/swing/Timer.java index 6caced7dd8d..ffaa9d53b3c 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/Timer.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/Timer.java @@ -401,14 +401,15 @@ public class Timer implements Serializable * @see #setInitialDelay */ public void setDelay(int delay) { - if (delay < 0) { - throw new IllegalArgumentException("Invalid delay: " + delay); - } - else { + checkDelay(delay, "Invalid delay: "); this.delay = delay; } - } + private static void checkDelay(int delay, String message) { + if (delay < 0) { + throw new IllegalArgumentException(message + delay); + } + } /** * Returns the delay, in milliseconds, @@ -435,14 +436,9 @@ public class Timer implements Serializable * @see #setDelay */ public void setInitialDelay(int initialDelay) { - if (initialDelay < 0) { - throw new IllegalArgumentException("Invalid initial delay: " + - initialDelay); - } - else { + checkDelay(initialDelay, "Invalid initial delay: "); this.initialDelay = initialDelay; } - } /** @@ -638,7 +634,26 @@ public class Timer implements Serializable throws ClassNotFoundException, IOException { this.acc = AccessController.getContext(); - in.defaultReadObject(); + ObjectInputStream.GetField f = in.readFields(); + + EventListenerList newListenerList = (EventListenerList) + f.get("listenerList", null); + if (newListenerList == null) { + throw new InvalidObjectException("Null listenerList"); + } + listenerList = newListenerList; + + int newInitialDelay = f.get("initialDelay", 0); + checkDelay(newInitialDelay, "Invalid initial delay: "); + initialDelay = newInitialDelay; + + int newDelay = f.get("delay", 0); + checkDelay(newDelay, "Invalid delay: "); + delay = newDelay; + + repeats = f.get("repeats", false); + coalesce = f.get("coalesce", false); + actionCommand = (String) f.get("actionCommand", null); } /* diff --git a/jdk/src/java.desktop/share/classes/javax/swing/event/SwingPropertyChangeSupport.java b/jdk/src/java.desktop/share/classes/javax/swing/event/SwingPropertyChangeSupport.java index 817a2f79bb8..3543e1c3720 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/event/SwingPropertyChangeSupport.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/event/SwingPropertyChangeSupport.java @@ -107,7 +107,7 @@ public final class SwingPropertyChangeSupport extends PropertyChangeSupport { * @see #SwingPropertyChangeSupport(Object sourceBean, boolean notifyOnEDT) * @since 1.6 */ - public final boolean isNotifyOnEDT() { + public boolean isNotifyOnEDT() { return notifyOnEDT; } diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/ComboBoxUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/ComboBoxUI.java index e0d9f1fb7f9..2ba9741c770 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/ComboBoxUI.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/ComboBoxUI.java @@ -37,16 +37,25 @@ public abstract class ComboBoxUI extends ComponentUI { /** * Set the visibility of the popup + * + * @param c a {@code JComboBox} + * @param v a {@code boolean} determining the visibilty of the popup */ public abstract void setPopupVisible( JComboBox c, boolean v ); /** * Determine the visibility of the popup + * + * @param c a {@code JComboBox} + * @return true if popup of the {@code JComboBox} is visible */ public abstract boolean isPopupVisible( JComboBox c ); /** * Determine whether or not the combo box itself is traversable + * + * @param c a {@code JComboBox} + * @return true if the given {@code JComboBox} is traversable */ public abstract boolean isFocusTraversable( JComboBox c ); } diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/ComponentUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/ComponentUI.java index 190d450e09a..15a05cdd6b0 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/ComponentUI.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/ComponentUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -173,7 +173,8 @@ public abstract class ComponentUI { * this argument is often ignored, * but might be used if the UI object is stateless * and shared by multiple components - * + * @return a {@code Dimension} object containing given component's preferred + * size appropriate for the look and feel * @see javax.swing.JComponent#getPreferredSize * @see java.awt.LayoutManager#preferredLayoutSize */ @@ -240,7 +241,8 @@ public abstract class ComponentUI { * and shared by multiple components * @param x the x coordinate of the point * @param y the y coordinate of the point - * + * @return {@code true} if the specified {@code x,y} location is contained + * within the look and feel's defined shape for the given component * @see javax.swing.JComponent#contains * @see java.awt.Component#contains */ @@ -258,6 +260,9 @@ public abstract class ComponentUI { * stateful, then it should return a new instance per component. * The default implementation of this method throws an error, as it * should never be invoked. + * + * @param c a {@code JComponent} for which to create a UI delegate + * @return a {@code ComponentUI} object for {@code c} */ public static ComponentUI createUI(JComponent c) { throw new Error("ComponentUI.createUI not implemented."); @@ -332,8 +337,9 @@ public abstract class ComponentUI { * Component.AccessibleAWTComponent.getAccessibleChildrenCount() instead * of this method. * - * @see #getAccessibleChild + * @param c {@code JComponent} for which to get count of accessible children * @return the number of accessible children in the object + * @see #getAccessibleChild */ public int getAccessibleChildrenCount(JComponent c) { return SwingUtilities.getAccessibleChildrenCount(c); @@ -351,9 +357,10 @@ public abstract class ComponentUI { * Component.AccessibleAWTComponent.getAccessibleChild() instead of * this method. * - * @see #getAccessibleChildrenCount + * @param c a {@code JComponent} for which to get a child object * @param i zero-based index of child * @return the ith Accessible child of the object + * @see #getAccessibleChildrenCount */ public Accessible getAccessibleChild(JComponent c, int i) { return SwingUtilities.getAccessibleChild(c, i); diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/FileChooserUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/FileChooserUI.java index d9b4361ae47..e3f2373b4cd 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/FileChooserUI.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/FileChooserUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -52,6 +52,8 @@ public abstract class FileChooserUI extends ComponentUI * JFileChooser will use this button as default button * for dialog windows. * + * @param fc the {@code JFileChooser} whose default button is requested + * @return the default JButton for current look and feel * @since 1.7 */ public JButton getDefaultButton(JFileChooser fc) { diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/LayerUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/LayerUI.java index a8584fd0fdc..a60da23517a 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/LayerUI.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/LayerUI.java @@ -716,10 +716,22 @@ public class LayerUI * @param y the y value of the region to be painted * @param width the width of the region to be painted * @param height the height of the region to be painted - * + * @param l a {@code JLayer} component * @see JComponent#paintImmediately(int, int, int, int) */ public void paintImmediately(int x, int y, int width, int height, JLayer l) { l.paintImmediately(x, y, width, height); } + + /** + * Delegates its functionality to the default implementation of the {@code JLayer.imageUpdate} method + * which is inherited from {@code JLayer}'s base classes. + *

    + * This method is to be overridden instead of {@code JLayer.imageUpdate}. + *

    + * Note: This method is usually called not on the Event Dispatching Thread. + */ + public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h, JLayer l) { + return l.imageUpdate(img, infoflags, x, y, w, h); + } } diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/OptionPaneUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/OptionPaneUI.java index 49137e7a0db..fc967b84315 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/OptionPaneUI.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/OptionPaneUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -38,12 +38,18 @@ public abstract class OptionPaneUI extends ComponentUI /** * Requests the component representing the default value to have * focus. + * + * @param op a {@code JOptionPane} */ public abstract void selectInitialValue(JOptionPane op); /** * Returns true if the user has supplied instances of Component for * either the options or message. + * + * @param op a {@code JOptionPane} + * @return {@code true} if the given {@code JOptionPane} contains user + * created {@code Component}s */ public abstract boolean containsCustomComponents(JOptionPane op); } diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/PopupMenuUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/PopupMenuUI.java index 5f57c659258..ab485a2c4ad 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/PopupMenuUI.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/PopupMenuUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2000, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -39,6 +39,11 @@ import javax.swing.JPopupMenu; public abstract class PopupMenuUI extends ComponentUI { /** + * Returns whether or not the given {@code MouseEvent} is the popup menu + * trigger event for the platform + * + * @param e a {@code MouseEvent} + * @return true if the {@code MouseEvent e} is the popup menu trigger * @since 1.3 */ public boolean isPopupTrigger(MouseEvent e) { diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/SplitPaneUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/SplitPaneUI.java index ed62e39a4d7..15afcee9a0d 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/SplitPaneUI.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/SplitPaneUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -38,32 +38,49 @@ public abstract class SplitPaneUI extends ComponentUI /** * Messaged to relayout the JSplitPane based on the preferred size * of the children components. + * + * @param jc a {@code JSplitPane} */ public abstract void resetToPreferredSizes(JSplitPane jc); /** * Sets the location of the divider to location. + * + * @param jc a {@code JSplitPane} + * @param location an integer specifying the location of the divider */ public abstract void setDividerLocation(JSplitPane jc, int location); /** * Returns the location of the divider. + * + * @param jc a {@code JSplitPane} + * @return an integer specifying the location of the divider */ public abstract int getDividerLocation(JSplitPane jc); /** * Returns the minimum possible location of the divider. + * + * @param jc a {@code JSplitPane} + * @return and integer specifying the minimum location of the divider */ public abstract int getMinimumDividerLocation(JSplitPane jc); /** * Returns the maximum possible location of the divider. + * + * @param jc a {@code JSplitPane} + * @return an integer specifying the maximum location of the divider */ public abstract int getMaximumDividerLocation(JSplitPane jc); /** * Messaged after the JSplitPane the receiver is providing the look * and feel for paints its children. + * + * @param jc a {@code JSplitPane} + * @param g the {@code Graphics} context */ public abstract void finishedPaintingChildren(JSplitPane jc, Graphics g); } diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/TextUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/TextUI.java index 0ce25c19071..6332d1ddc23 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/TextUI.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/TextUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -42,8 +42,9 @@ public abstract class TextUI extends ComponentUI * Converts the given location in the model to a place in * the view coordinate system. * + * @param t the text component for which this UI is installed * @param pos the local location in the model to translate >= 0 - * @return the coordinates as a rectangle + * @return the coordinates as a {@code Rectangle} * @exception BadLocationException if the given position does not * represent a valid location in the associated document */ @@ -53,8 +54,10 @@ public abstract class TextUI extends ComponentUI * Converts the given location in the model to a place in * the view coordinate system. * + * @param t the text component for which this UI is installed * @param pos the local location in the model to translate >= 0 - * @return the coordinates as a rectangle + * @param bias the bias for the position + * @return the coordinates as a {@code Rectangle} * @exception BadLocationException if the given position does not * represent a valid location in the associated document */ @@ -64,6 +67,7 @@ public abstract class TextUI extends ComponentUI * Converts the given place in the view coordinate system * to the nearest representative location in the model. * + * @param t the text component for which this UI is installed * @param pt the location in the view to translate. This * should be in the same coordinate system as the mouse * events. @@ -75,6 +79,7 @@ public abstract class TextUI extends ComponentUI * Provides a mapping from the view coordinate space to the logical * coordinate space of the model. * + * @param t the text component for which this UI is installed * @param pt the location in the view to translate. * This should be in the same coordinate system * as the mouse events. @@ -117,6 +122,7 @@ public abstract class TextUI extends ComponentUI * Causes the portion of the view responsible for the * given part of the model to be repainted. * + * @param t the text component for which this UI is installed * @param p0 the beginning of the range >= 0 * @param p1 the end of the range >= p0 */ @@ -126,8 +132,13 @@ public abstract class TextUI extends ComponentUI * Causes the portion of the view responsible for the * given part of the model to be repainted. * + * @param t the text component for which this UI is installed * @param p0 the beginning of the range >= 0 * @param p1 the end of the range >= p0 + * @param firstBias the bias of the first character position, toward the + * previous character or the next character + * @param secondBias the bias of the second character position, toward the + * previous character or the next character */ public abstract void damageRange(JTextComponent t, int p0, int p1, Position.Bias firstBias, @@ -139,6 +150,7 @@ public abstract class TextUI extends ComponentUI * things like the commands available, stream readers and * writers, etc. * + * @param t the text component for which this UI is installed * @return the editor kit binding */ public abstract EditorKit getEditorKit(JTextComponent t); @@ -149,13 +161,18 @@ public abstract class TextUI extends ComponentUI * can be traversed to determine how the model is being * represented spatially. * - * @return the view + * @param t the text component for which this UI is installed + * @return a {@code View} with the allocation of the associated + * text component */ public abstract View getRootView(JTextComponent t); /** * Returns the string to be used as the tooltip at the passed in location. * + * @param t the text component for which this UI is installed + * @param pt a {@code Point} specifying location for which to get a tooltip + * @return a {@code String} containing the tooltip * @see javax.swing.text.JTextComponent#getToolTipText * @since 1.4 */ diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/TreeUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/TreeUI.java index d1ded67b15b..5968b335402 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/TreeUI.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/TreeUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -38,68 +38,109 @@ import javax.swing.tree.TreePath; public abstract class TreeUI extends ComponentUI { /** - * Returns the Rectangle enclosing the label portion that the - * last item in path will be drawn into. Will return null if - * any component in path is currently valid. - */ + * Returns the Rectangle enclosing the label portion that the + * last item in path will be drawn into. Will return null if + * any component in path is currently valid. + * + * @param tree the {@code JTree} for {@code path} + * @param path the {@code TreePath} identifying the node + * @return the {@code Rectangle} enclosing the label portion that the + * last item in path will be drawn into, {@code null} if any + * component in path is currently valid. + */ public abstract Rectangle getPathBounds(JTree tree, TreePath path); /** - * Returns the path for passed in row. If row is not visible - * null is returned. - */ + * Returns the path for passed in row. If row is not visible + * null is returned. + * + * @param tree a {@code JTree} object + * @param row an integer specifying a row + * @return the {@code path} for {@code row} or {@code null} if {@code row} + * is not visible + */ public abstract TreePath getPathForRow(JTree tree, int row); /** - * Returns the row that the last item identified in path is visible - * at. Will return -1 if any of the elements in path are not - * currently visible. - */ + * Returns the row that the last item identified in path is visible + * at. Will return -1 if any of the elements in path are not + * currently visible. + * + * @param tree the {@code JTree} for {@code path} + * @param path the {@code TreePath} object to look in + * @return an integer specifying the row at which the last item + * identified is visible, -1 if any of the elements in + * {@code path} are not currently visible + */ public abstract int getRowForPath(JTree tree, TreePath path); /** - * Returns the number of rows that are being displayed. - */ + * Returns the number of rows that are being displayed. + * + * @param tree the {@code JTree} for which to count rows + * @return an integer specifying the number of row being displayed + */ public abstract int getRowCount(JTree tree); /** - * Returns the path to the node that is closest to x,y. If - * there is nothing currently visible this will return null, otherwise - * it'll always return a valid path. If you need to test if the - * returned object is exactly at x, y you should get the bounds for - * the returned path and test x, y against that. - */ + * Returns the path to the node that is closest to x,y. If + * there is nothing currently visible this will return null, otherwise + * it'll always return a valid path. If you need to test if the + * returned object is exactly at x, y you should get the bounds for + * the returned path and test x, y against that. + * + * @param tree a {@code JTree} object + * @param x an integer giving the number of pixels horizontally from the + * left edge of the display area + * @param y an integer giving the number of pixels vertically from the top + * of the display area, minus any top margin + * @return the {@code TreePath} node closest to {@code x,y} or {@code null} + * if there is nothing currently visible + */ public abstract TreePath getClosestPathForLocation(JTree tree, int x, int y); /** - * Returns true if the tree is being edited. The item that is being - * edited can be returned by getEditingPath(). - */ + * Returns true if the tree is being edited. The item that is being + * edited can be returned by getEditingPath(). + * + * @param tree a {@code JTree} object + * @return true if {@code tree} is being edited + */ public abstract boolean isEditing(JTree tree); /** - * Stops the current editing session. This has no effect if the - * tree isn't being edited. Returns true if the editor allows the - * editing session to stop. - */ + * Stops the current editing session. This has no effect if the + * tree isn't being edited. Returns true if the editor allows the + * editing session to stop. + * + * @param tree a {@code JTree} object + * @return true if the editor allows the editing session to stop + */ public abstract boolean stopEditing(JTree tree); /** - * Cancels the current editing session. This has no effect if the - * tree isn't being edited. Returns true if the editor allows the - * editing session to stop. - */ + * Cancels the current editing session. This has no effect if the + * tree isn't being edited. + * + * @param tree a {@code JTree} object + */ public abstract void cancelEditing(JTree tree); /** - * Selects the last item in path and tries to edit it. Editing will - * fail if the CellEditor won't allow it for the selected item. - */ + * Selects the last item in path and tries to edit it. Editing will + * fail if the CellEditor won't allow it for the selected item. + * + * @param tree the {@code JTree} being edited + * @param path the {@code TreePath} to be edited + */ public abstract void startEditingAtPath(JTree tree, TreePath path); /** * Returns the path to the element that is being edited. + * + * @param tree the {@code JTree} for which to return a path + * @return a {@code TreePath} containing the path to {@code tree} */ public abstract TreePath getEditingPath(JTree tree); } diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicInternalFrameUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicInternalFrameUI.java index ffbd5ea628b..c7c5ad05a9d 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicInternalFrameUI.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicInternalFrameUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -351,10 +351,15 @@ public class BasicInternalFrameUI extends InternalFrameUI /** - * Installs necessary mouse handlers on newPane - * and adds it to the frame. - * Reverse process for the currentPane. - */ + * Installs necessary mouse handlers on newPane + * and adds it to the frame. + * Reverse process for the currentPane. + * + * @param currentPane this {@code Jcomponent} is the current pane being + * viewed that has mouse handlers installed + * @param newPane this {@code Jcomponent} is the pane which will be added + * and have mouse handlers installed + */ protected void replacePane(JComponent currentPane, JComponent newPane) { if(currentPane != null) { deinstallMouseHandlers(currentPane); @@ -517,11 +522,12 @@ public class BasicInternalFrameUI extends InternalFrameUI } /// DesktopManager methods - /** Returns the proper DesktopManager. Calls getDesktopPane() to - * find the JDesktop component and returns the desktopManager from - * it. If this fails, it will return a default DesktopManager that - * should work in arbitrary parents. - */ + /** + * Returns the proper DesktopManager. Calls getDesktopPane() to + * find the JDesktop component and returns the desktopManager from + * it. If this fails, it will return a default DesktopManager that + * should work in arbitrary parents. + */ protected DesktopManager getDesktopManager() { if(frame.getDesktopPane() != null && frame.getDesktopPane().getDesktopManager() != null) @@ -539,6 +545,8 @@ public class BasicInternalFrameUI extends InternalFrameUI * This method is called when the user wants to close the frame. * The playCloseSound Action is fired. * This action is delegated to the desktopManager. + * + * @param f the {@code JInternalFrame} being viewed */ protected void closeFrame(JInternalFrame f) { // Internal Frame Auditory Cue Activation @@ -551,6 +559,8 @@ public class BasicInternalFrameUI extends InternalFrameUI * This method is called when the user wants to maximize the frame. * The playMaximizeSound Action is fired. * This action is delegated to the desktopManager. + * + * @param f the {@code JInternalFrame} being viewed */ protected void maximizeFrame(JInternalFrame f) { // Internal Frame Auditory Cue Activation @@ -563,6 +573,8 @@ public class BasicInternalFrameUI extends InternalFrameUI * This method is called when the user wants to minimize the frame. * The playRestoreDownSound Action is fired. * This action is delegated to the desktopManager. + * + * @param f the {@code JInternalFrame} being viewed */ protected void minimizeFrame(JInternalFrame f) { // Internal Frame Auditory Cue Activation @@ -579,6 +591,8 @@ public class BasicInternalFrameUI extends InternalFrameUI * This method is called when the user wants to iconify the frame. * The playMinimizeSound Action is fired. * This action is delegated to the desktopManager. + * + * @param f the {@code JInternalFrame} being viewed */ protected void iconifyFrame(JInternalFrame f) { // Internal Frame Auditory Cue Activation @@ -591,6 +605,8 @@ public class BasicInternalFrameUI extends InternalFrameUI * This method is called when the user wants to deiconify the frame. * The playRestoreUpSound Action is fired. * This action is delegated to the desktopManager. + * + * @param f the {@code JInternalFrame} being viewed */ protected void deiconifyFrame(JInternalFrame f) { // Internal Frame Auditory Cue Activation @@ -603,15 +619,21 @@ public class BasicInternalFrameUI extends InternalFrameUI getDesktopManager().deiconifyFrame(f); } - /** This method is called when the frame becomes selected. + /** + * This method is called when the frame becomes selected. * This action is delegated to the desktopManager. + * + * @param f the {@code JInternalFrame} being viewed */ protected void activateFrame(JInternalFrame f) { getDesktopManager().activateFrame(f); } - /** This method is called when the frame is no longer selected. - * This action is delegated to the desktopManager. - */ + /** + * This method is called when the frame is no longer selected. + * This action is delegated to the desktopManager. + * + * @param f the {@code JInternalFrame} being viewed + */ protected void deactivateFrame(JInternalFrame f) { getDesktopManager().deactivateFrame(f); } @@ -769,7 +791,7 @@ public class BasicInternalFrameUI extends InternalFrameUI resizeDir = SOUTH; } } else { - /* the mouse press happened inside the frame, not in the + /* the mouse press happened inside the frame, not in the border */ discardRelease = true; return; diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicScrollBarUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicScrollBarUI.java index c7642f4e4c4..ebb0862587a 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicScrollBarUI.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicScrollBarUI.java @@ -93,8 +93,10 @@ public class BasicScrollBarUI private final static int scrollSpeedThrottle = 60; // delay in milli seconds - /** True indicates a middle click will absolutely position the - * scrollbar. */ + /** + * True indicates a middle click will absolutely position the + * scrollbar. + */ private boolean supportsAbsolutePositioning; /** @@ -877,6 +879,10 @@ public class BasicScrollBarUI * Set the bounds of the thumb and force a repaint that includes * the old thumbBounds and the new one. * + * @param x set the x location of the thumb + * @param y set the y location of the thumb + * @param width set the width of the thumb + * @param height set the height of the thumb * @see #getThumbBounds */ protected void setThumbBounds(int x, int y, int width, int height) diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSliderUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSliderUI.java index b6ca67de67e..bfd4e768ab1 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSliderUI.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSliderUI.java @@ -656,10 +656,15 @@ public class BasicSliderUI extends SliderUI{ } /** - * Gets the height of the tick area for horizontal sliders and the width of the - * tick area for vertical sliders. BasicSliderUI uses the returned value to - * determine the tick area rectangle. If you want to give your ticks some room, - * make this larger than you need and paint your ticks away from the sides in paintTicks(). + * Gets the height of the tick area for horizontal sliders and the width of + * the tick area for vertical sliders. BasicSliderUI uses the returned value + * to determine the tick area rectangle. If you want to give your ticks some + * room, make this larger than you need and paint your ticks away from the + * sides in paintTicks(). + * + * @return an integer representing the height of the tick area for + * horizontal sliders, and the width of the tick area for the vertical + * sliders */ protected int getTickLength() { return 8; @@ -867,7 +872,7 @@ public class BasicSliderUI extends SliderUI{ * Returns the smallest value that has an entry in the label table. * * @return smallest value that has an entry in the label table, or - * null. + * null. * @since 1.6 */ protected Integer getLowestValue() { @@ -894,7 +899,11 @@ public class BasicSliderUI extends SliderUI{ /** - * Returns the label that corresponds to the highest slider value in the label table. + * Returns the label that corresponds to the highest slider value in the + * label table. + * + * @return the label that corresponds to the highest slider value in the + * label table * @see JSlider#setLabelTable */ protected Component getLowestValueLabel() { @@ -906,7 +915,11 @@ public class BasicSliderUI extends SliderUI{ } /** - * Returns the label that corresponds to the lowest slider value in the label table. + * Returns the label that corresponds to the lowest slider value in the + * label table. + * + * @return the label that corresponds to the lowest slider value in the + * label table * @see JSlider#setLabelTable */ protected Component getHighestValueLabel() { @@ -1166,8 +1179,14 @@ public class BasicSliderUI extends SliderUI{ } /** - * Called for every label in the label table. Used to draw the labels for horizontal sliders. - * The graphics have been translated to labelRect.y already. + * Called for every label in the label table. Used to draw the labels for + * horizontal sliders. The graphics have been translated to labelRect.y + * already. + * + * @param g the graphics context in which to paint + * @param value the value of the slider + * @param label the component label in the label table that needs to be + * painted * @see JSlider#setLabelTable */ protected void paintHorizontalLabel( Graphics g, int value, Component label ) { @@ -1179,8 +1198,14 @@ public class BasicSliderUI extends SliderUI{ } /** - * Called for every label in the label table. Used to draw the labels for vertical sliders. - * The graphics have been translated to labelRect.x already. + * Called for every label in the label table. Used to draw the labels for + * vertical sliders. The graphics have been translated to labelRect.x + * already. + * + * @param g the graphics context in which to paint + * @param value the value of the slider + * @param label the component label in the label table that needs to be + * painted * @see JSlider#setLabelTable */ protected void paintVerticalLabel( Graphics g, int value, Component label ) { @@ -1342,9 +1367,12 @@ public class BasicSliderUI extends SliderUI{ } /** - * This function is called when a mousePressed was detected in the track, not - * in the thumb. The default behavior is to scroll by block. You can - * override this method to stop it from scrolling or to add additional behavior. + * This function is called when a mousePressed was detected in the track, + * not in the thumb. The default behavior is to scroll by block. You can + * override this method to stop it from scrolling or to add additional + * behavior. + * + * @param dir the direction and number of blocks to scroll */ protected void scrollDueToClickInTrack( int dir ) { scrollByBlock( dir ); @@ -1387,6 +1415,7 @@ public class BasicSliderUI extends SliderUI{ * @param value the slider value to get the location for * @param trackY y-origin of the track * @param trackHeight the height of the track + * @return the y location for the specified value of the slider * @since 1.6 */ protected int yPositionForValue(int value, int trackY, int trackHeight) { @@ -1417,6 +1446,9 @@ public class BasicSliderUI extends SliderUI{ * track at the the bottom or the top, this method sets the value to either * the minimum or maximum value of the slider, depending on if the slider * is inverted or not. + * + * @param yPos the location of the slider along the y axis + * @return the value at the y position */ public int valueForYPosition( int yPos ) { int value; @@ -1449,6 +1481,9 @@ public class BasicSliderUI extends SliderUI{ * track at the left or the right, this method sets the value to either the * minimum or maximum value of the slider, depending on if the slider is * inverted or not. + * + * @param xPos the location of the slider along the x axis + * @return the value of the x position */ public int valueForXPosition( int xPos ) { int value; diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java index bf27557ac99..7490b8ea458 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java @@ -1174,6 +1174,16 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants { * this function draws the border around each tab * note that this function does now draw the background of the tab. * that is done elsewhere + * + * @param g the graphics context in which to paint + * @param tabPlacement the placement (left, right, bottom, top) of the tab + * @param tabIndex the index of the tab with respect to other tabs + * @param x the x coordinate of tab + * @param y the y coordinate of tab + * @param w the width of the tab + * @param h the height of the tab + * @param isSelected a {@code boolean} which determines whether or not + * the tab is selected */ protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex, @@ -3530,12 +3540,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants { else if (name =="indexForTitle") { calculatedBaseline = false; Integer index = (Integer) e.getNewValue(); - // remove the current index - // to let updateHtmlViews() insert the correct one - if (htmlViews != null) { - htmlViews.removeElementAt(index); - } - updateHtmlViews(index); + updateHtmlViews(index, false); } else if (name == "tabLayoutPolicy") { BasicTabbedPaneUI.this.uninstallUI(pane); BasicTabbedPaneUI.this.installUI(pane); @@ -3574,13 +3579,13 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants { calculatedBaseline = false; } else if (name == "indexForNullComponent") { isRunsDirty = true; - updateHtmlViews((Integer)e.getNewValue()); + updateHtmlViews((Integer)e.getNewValue(), true); } else if (name == "font") { calculatedBaseline = false; } } - private void updateHtmlViews(int index) { + private void updateHtmlViews(int index, boolean inserted) { String title = tabPane.getTitleAt(index); boolean isHTML = BasicHTML.isHTMLString(title); if (isHTML) { @@ -3588,16 +3593,24 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants { htmlViews = createHTMLVector(); } else { // Vector already exists View v = BasicHTML.createHTMLView(tabPane, title); - htmlViews.insertElementAt(v, index); + setHtmlView(v, inserted, index); } } else { // Not HTML if (htmlViews!=null) { // Add placeholder - htmlViews.insertElementAt(null, index); + setHtmlView(null, inserted, index); } // else nada! } updateMnemonics(); } + private void setHtmlView(View v, boolean inserted, int index) { + if (inserted || index >= htmlViews.size()) { + htmlViews.insertElementAt(v, index); + } else { + htmlViews.setElementAt(v, index); + } + } + // // ChangeListener // @@ -3716,7 +3729,7 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants { return; } isRunsDirty = true; - updateHtmlViews(tp.indexOfComponent(child)); + updateHtmlViews(tp.indexOfComponent(child), true); } public void componentRemoved(ContainerEvent e) { JTabbedPane tp = (JTabbedPane)e.getContainer(); diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/AbstractDocument.java b/jdk/src/java.desktop/share/classes/javax/swing/text/AbstractDocument.java index 111ab923a85..6b1bf61bb00 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/text/AbstractDocument.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/text/AbstractDocument.java @@ -1426,11 +1426,18 @@ public abstract class AbstractDocument implements Document, Serializable { // --- serialization --------------------------------------------- + @SuppressWarnings("unchecked") private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException { - s.defaultReadObject(); + ObjectInputStream.GetField f = s.readFields(); + + documentProperties = + (Dictionary) f.get("documentProperties", null); listenerList = new EventListenerList(); + data = (Content) f.get("data", null); + context = (AttributeContext) f.get("context", null); + documentFilter = (DocumentFilter) f.get("documentFilter", null); // Restore bidi structure //REMIND(bcb) This creates an initial bidi element to account for diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/DefaultCaret.java b/jdk/src/java.desktop/share/classes/javax/swing/text/DefaultCaret.java index 5eb0b2b10fe..cd17fed60bd 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/text/DefaultCaret.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/text/DefaultCaret.java @@ -1516,7 +1516,30 @@ public class DefaultCaret extends Rectangle implements Caret, FocusListener, Mou private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException { - s.defaultReadObject(); + ObjectInputStream.GetField f = s.readFields(); + + EventListenerList newListenerList = (EventListenerList) f.get("listenerList", null); + if (newListenerList == null) { + throw new InvalidObjectException("Null listenerList"); + } + listenerList = newListenerList; + component = (JTextComponent) f.get("component", null); + updatePolicy = f.get("updatePolicy", 0); + visible = f.get("visible", false); + active = f.get("active", false); + dot = f.get("dot", 0); + mark = f.get("mark", 0); + selectionTag = f.get("selectionTag", null); + selectionVisible = f.get("selectionVisible", false); + flasher = (Timer) f.get("flasher", null); + magicCaretPosition = (Point) f.get("magicCaretPosition", null); + dotLTR = f.get("dotLTR", false); + markLTR = f.get("markLTR", false); + ownsSelection = f.get("ownsSelection", false); + forceCaretPositionChange = f.get("forceCaretPositionChange", false); + caretWidth = f.get("caretWidth", 0); + aspectRatio = f.get("aspectRatio", 0.0f); + handler = new Handler(); if (!s.readBoolean()) { dotBias = Position.Bias.Forward; diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/DefaultStyledDocument.java b/jdk/src/java.desktop/share/classes/javax/swing/text/DefaultStyledDocument.java index 78788cbfad1..09faa5671cb 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/text/DefaultStyledDocument.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/text/DefaultStyledDocument.java @@ -1082,8 +1082,9 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException { - listeningStyles = new Vector

    Audio System Property Keys